Search in sources :

Example 11 with TransactionToApply

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

the class ApplyRecoveredTransactionsTest method applyExternalTransaction.

private void applyExternalTransaction(long transactionId, Command... commands) throws Exception {
    LockService lockService = mock(LockService.class);
    when(lockService.acquireNodeLock(anyLong(), any(LockService.LockType.class))).thenReturn(LockService.NO_LOCK);
    when(lockService.acquireRelationshipLock(anyLong(), any(LockService.LockType.class))).thenReturn(LockService.NO_LOCK);
    NeoStoreBatchTransactionApplier applier = new NeoStoreBatchTransactionApplier(neoStores, mock(CacheAccessBackDoor.class), lockService);
    TransactionRepresentation tx = new PhysicalTransactionRepresentation(Arrays.asList(commands));
    CommandHandlerContract.apply(applier, txApplier -> {
        tx.accept(txApplier);
        return false;
    }, new TransactionToApply(tx, transactionId));
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) LockService(org.neo4j.kernel.impl.locking.LockService) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) CacheAccessBackDoor(org.neo4j.kernel.impl.core.CacheAccessBackDoor) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 12 with TransactionToApply

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

the class BatchingTxApplierTest method assertTransactionsCommitted.

private void assertTransactionsCommitted(long startTxId, long expectedCount) throws TransactionFailureException {
    ArgumentCaptor<TransactionToApply> batchCaptor = ArgumentCaptor.forClass(TransactionToApply.class);
    verify(commitProcess).commit(batchCaptor.capture(), eq(NULL), eq(EXTERNAL));
    TransactionToApply batch = Iterables.single(batchCaptor.getAllValues());
    long expectedTxId = startTxId;
    long count = 0;
    while (batch != null) {
        assertEquals(expectedTxId, batch.transactionId());
        expectedTxId++;
        batch = batch.next();
        count++;
    }
    assertEquals(expectedCount, count);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply)

Example 13 with TransactionToApply

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

the class TransactionBatchCommitterTest method tx.

private TransactionToApply tx(long id, long commitTimestamp) {
    PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(emptyList());
    representation.setHeader(new byte[0], 0, 0, commitTimestamp - 10, id - 1, commitTimestamp, 0);
    return new TransactionToApply(representation, id);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 14 with TransactionToApply

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

the class TransactionBatchCommitterTest method createTxChain.

private TransactionChain createTxChain(int txCount, long firstCommitTimestamp, long commitTimestampInterval) {
    TransactionToApply first = null;
    TransactionToApply last = null;
    long commitTimestamp = firstCommitTimestamp;
    for (long i = BASE_TX_ID; i < BASE_TX_ID + txCount; i++) {
        TransactionToApply tx = tx(i, commitTimestamp);
        if (first == null) {
            first = tx;
            last = tx;
        } else {
            last.next(tx);
            last = tx;
        }
        commitTimestamp += commitTimestampInterval;
    }
    return new TransactionChain(first, last);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply)

Example 15 with TransactionToApply

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

the class BatchingTransactionAppenderTest method shouldKernelPanicIfTransactionIdsMismatch.

@Test
void shouldKernelPanicIfTransactionIdsMismatch() {
    // Given
    BatchingTransactionAppender appender = life.add(createTransactionAppender());
    when(transactionIdStore.nextCommittingTransactionId()).thenReturn(42L);
    TransactionToApply batch = new TransactionToApply(mock(TransactionRepresentation.class), 43L, NULL);
    // When
    var e = assertThrows(IllegalStateException.class, () -> appender.append(batch, LogAppendEvent.NULL));
    // Then
    verify(databaseHealth).panic(e);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) Test(org.junit.jupiter.api.Test)

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