Search in sources :

Example 31 with TransactionToApply

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

the class IndexBatchTransactionApplierTest method shouldProvideLabelScanStoreUpdatesSortedByNodeId.

@Test
public void shouldProvideLabelScanStoreUpdatesSortedByNodeId() throws Exception {
    // GIVEN
    IndexingService indexing = mock(IndexingService.class);
    LabelScanWriter writer = new OrderVerifyingLabelScanWriter(10, 15, 20);
    WorkSync<Supplier<LabelScanWriter>, LabelUpdateWork> labelScanSync = spy(new WorkSync<>(singletonProvider(writer)));
    WorkSync<IndexingService, IndexUpdatesWork> indexUpdatesSync = new WorkSync<>(indexing);
    TransactionToApply tx = mock(TransactionToApply.class);
    PropertyStore propertyStore = mock(PropertyStore.class);
    try (IndexBatchTransactionApplier applier = new IndexBatchTransactionApplier(indexing, labelScanSync, indexUpdatesSync, mock(NodeStore.class), mock(PropertyLoader.class), new PropertyPhysicalToLogicalConverter(propertyStore), TransactionApplicationMode.INTERNAL)) {
        try (TransactionApplier txApplier = applier.startTx(tx)) {
            // WHEN
            txApplier.visitNodeCommand(node(15));
            txApplier.visitNodeCommand(node(20));
            txApplier.visitNodeCommand(node(10));
        }
    }
    // THEN all assertions happen inside the LabelScanWriter#write and #close
    verify(labelScanSync).apply(any());
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) WorkSync(org.neo4j.concurrent.WorkSync) PropertyPhysicalToLogicalConverter(org.neo4j.kernel.impl.api.index.PropertyPhysicalToLogicalConverter) TransactionApplier(org.neo4j.kernel.impl.api.TransactionApplier) PropertyLoader(org.neo4j.kernel.impl.transaction.state.PropertyLoader) NodeStore(org.neo4j.kernel.impl.store.NodeStore) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) Supplier(java.util.function.Supplier) LabelScanWriter(org.neo4j.kernel.api.labelscan.LabelScanWriter) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) Test(org.junit.Test)

Example 32 with TransactionToApply

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

the class SchemaRuleCommandTest method visitSchemaRuleCommand.

private void visitSchemaRuleCommand(BatchTransactionApplier applier, SchemaRuleCommand command) throws Exception {
    TransactionToApply tx = new TransactionToApply(new PhysicalTransactionRepresentation(singletonList(command)), txId);
    CommandHandlerContract.apply(applier, tx);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 33 with TransactionToApply

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

the class RecordStorageEngineTest method executeFailingTransaction.

private Exception executeFailingTransaction(RecordStorageEngine engine) throws IOException {
    Exception applicationError = new UnderlyingStorageException("No space left on device");
    TransactionToApply txToApply = newTransactionThatFailsWith(applicationError);
    try {
        engine.apply(txToApply, TransactionApplicationMode.INTERNAL);
        fail("Exception expected");
    } catch (Exception e) {
        assertSame(applicationError, Exceptions.rootCause(e));
    }
    return applicationError;
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) IOException(java.io.IOException)

Example 34 with TransactionToApply

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

the class IndexWorkSyncTransactionApplicationStressIT method tx.

private static TransactionToApply tx(List<StorageCommand> commands) {
    PhysicalTransactionRepresentation txRepresentation = new PhysicalTransactionRepresentation(commands, new byte[0], -1, -1, -1, -1, ANONYMOUS);
    TransactionToApply tx = new TransactionToApply(txRepresentation, NULL);
    tx.commitment(NO_COMMITMENT, 0);
    return tx;
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 35 with TransactionToApply

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

the class ParallelRecoveryVisitor method apply.

private void apply(CommittedTransactionRepresentation transaction) throws Exception {
    try (CursorContext cursorContext = new CursorContext(cacheTracer.createPageCursorTracer(tracerTag))) {
        TransactionRepresentation txRepresentation = transaction.getTransactionRepresentation();
        long txId = transaction.getCommitEntry().getTxId();
        TransactionToApply tx = new TransactionToApply(txRepresentation, txId, cursorContext);
        tx.commitment(NO_COMMITMENT, txId);
        tx.logPosition(transaction.getStartEntry().getStartPosition());
        storageEngine.apply(tx, mode);
    }
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) CursorContext(org.neo4j.io.pagecache.context.CursorContext)

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