Search in sources :

Example 6 with TransactionToApply

use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.

the class SlaveTransactionCommitProcessTest method mustTranslateIOExceptionsToKernelTransactionFailures.

@Test
public void mustTranslateIOExceptionsToKernelTransactionFailures() throws Exception {
    when(master.commit(requestContext, tx)).thenThrow(new IOException());
    try {
        commitProcess.commit(new TransactionToApply(tx), CommitEvent.NULL, TransactionApplicationMode.INTERNAL);
        fail("commit should have thrown");
    } catch (TransactionFailureException e) {
        assertThat(e.status(), is((Status) Status.Transaction.TransactionCommitFailed));
    }
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) TransientTransactionFailureException(org.neo4j.graphdb.TransientTransactionFailureException) TransactionFailureException(org.neo4j.kernel.api.exceptions.TransactionFailureException) IOException(java.io.IOException) Test(org.junit.Test)

Example 7 with TransactionToApply

use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.

the class RecordStorageEngineTest method newTransactionThatFailsWith.

private static TransactionToApply newTransactionThatFailsWith(Exception error) throws IOException {
    TransactionRepresentation transaction = mock(TransactionRepresentation.class);
    when(transaction.additionalHeader()).thenReturn(new byte[0]);
    // allow to build validated index updates but fail on actual tx application
    doThrow(error).when(transaction).accept(any());
    long txId = ThreadLocalRandom.current().nextLong(0, 1000);
    TransactionToApply txToApply = new TransactionToApply(transaction);
    FakeCommitment commitment = new FakeCommitment(txId, mock(TransactionIdStore.class));
    commitment.setHasLegacyIndexChanges(false);
    txToApply.commitment(commitment, txId);
    return txToApply;
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) FakeCommitment(org.neo4j.kernel.impl.transaction.log.FakeCommitment)

Example 8 with TransactionToApply

use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.

the class BatchingTransactionAppenderConcurrencyTest method tx.

protected TransactionToApply tx() {
    NodeRecord before = new NodeRecord(0);
    NodeRecord after = new NodeRecord(0);
    after.setInUse(true);
    Command.NodeCommand nodeCommand = new Command.NodeCommand(before, after);
    PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(asList((Command) nodeCommand));
    tx.setHeader(new byte[0], 0, 0, 0, 0, 0, 0);
    return new TransactionToApply(tx);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command)

Example 9 with TransactionToApply

use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.

the class IndexWorkSyncTransactionApplicationStressIT method tx.

private static TransactionToApply tx(Collection<StorageCommand> commands) {
    TransactionToApply tx = new TransactionToApply(transactionRepresentation(commands));
    tx.commitment(NO_COMMITMENT, 0);
    return tx;
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply)

Example 10 with TransactionToApply

use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.

the class PhysicalLogicalTransactionStoreTest method addATransactionAndRewind.

private void addATransactionAndRewind(LifeSupport life, LogFile logFile, TransactionMetadataCache positionCache, TransactionIdStore transactionIdStore, byte[] additionalHeader, int masterId, int authorId, long timeStarted, long latestCommittedTxWhenStarted, long timeCommitted) throws IOException {
    TransactionAppender appender = life.add(new BatchingTransactionAppender(logFile, NO_ROTATION, positionCache, transactionIdStore, BYPASS, DATABASE_HEALTH));
    PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(singleCreateNodeCommand());
    transaction.setHeader(additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted, -1);
    appender.append(new TransactionToApply(transaction), LogAppendEvent.NULL);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply)

Aggregations

TransactionToApply (org.neo4j.kernel.impl.api.TransactionToApply)46 TransactionRepresentation (org.neo4j.kernel.impl.transaction.TransactionRepresentation)14 Test (org.junit.jupiter.api.Test)11 PhysicalTransactionRepresentation (org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)11 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)9 Test (org.junit.Test)7 IOException (java.io.IOException)6 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6 DbmsLogEntryWriterFactory (org.neo4j.kernel.database.DbmsLogEntryWriterFactory)6 TransactionFailureException (org.neo4j.kernel.api.exceptions.TransactionFailureException)4 TransactionId (org.neo4j.storageengine.api.TransactionId)4 TransactionCommitProcess (org.neo4j.kernel.impl.api.TransactionCommitProcess)3 CommitEvent (org.neo4j.kernel.impl.transaction.tracing.CommitEvent)3 ArrayList (java.util.ArrayList)2 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)2 TransactionApplier (org.neo4j.kernel.impl.api.TransactionApplier)2 LockGroup (org.neo4j.kernel.impl.locking.LockGroup)2 FakeCommitment (org.neo4j.kernel.impl.transaction.log.FakeCommitment)2 LogEntryCommit (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit)2 LogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader)2