Search in sources :

Example 46 with PhysicalTransactionRepresentation

use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.

the class InternalTransactionCommitProcessTest method shouldSuccessfullyCommitTransactionWithNoCommands.

@Test
void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception {
    // GIVEN
    long txId = 11;
    TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
    TransactionAppender appender = new TestableTransactionAppender(transactionIdStore);
    when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
    StorageEngine storageEngine = mock(StorageEngine.class);
    TransactionCommitProcess commitProcess = new InternalTransactionCommitProcess(appender, storageEngine);
    PhysicalTransactionRepresentation noCommandTx = new PhysicalTransactionRepresentation(Collections.emptyList());
    noCommandTx.setHeader(new byte[0], -1, -1, -1, -1, ANONYMOUS);
    // WHEN
    commitProcess.commit(new TransactionToApply(noCommandTx, NULL), commitEvent, INTERNAL);
    verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP, NULL);
}
Also used : TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) TestableTransactionAppender(org.neo4j.kernel.impl.transaction.log.TestableTransactionAppender) TestableTransactionAppender(org.neo4j.kernel.impl.transaction.log.TestableTransactionAppender) TransactionAppender(org.neo4j.kernel.impl.transaction.log.TransactionAppender) StorageEngine(org.neo4j.storageengine.api.StorageEngine) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) Test(org.junit.jupiter.api.Test)

Example 47 with PhysicalTransactionRepresentation

use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.

the class TransactionRepresentationFactory method nextTransaction.

TransactionToApply nextTransaction(long txId) {
    PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(createRandomCommands());
    representation.setHeader(new byte[0], currentTimeMillis(), txId, currentTimeMillis(), 42, ANONYMOUS);
    return new TransactionToApply(representation, NULL);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 48 with PhysicalTransactionRepresentation

use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.

the class TransactionWriter method representation.

public TransactionRepresentation representation(byte[] additionalHeader, long startTime, long lastCommittedTx, long committedTime) {
    prepareForCommit();
    PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(allCommands());
    representation.setHeader(additionalHeader, startTime, lastCommittedTx, committedTime, -1, AuthSubject.ANONYMOUS);
    return representation;
}
Also used : PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 49 with PhysicalTransactionRepresentation

use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.

the class NeoStoresTest method commitTx.

private void commitTx() throws Exception {
    try (CommandCreationContext commandCreationContext = storageEngine.newCommandCreationContext(INSTANCE)) {
        CursorContext cursorContext = NULL;
        commandCreationContext.initialize(cursorContext);
        List<StorageCommand> commands = new ArrayList<>();
        storageEngine.createCommands(commands, transactionState, storageReader, commandCreationContext, IGNORE, NONE, storageEngine.testAccessNeoStores().getMetaDataStore().getLastClosedTransactionId(), tx -> tx, cursorContext, INSTANCE);
        PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(commands);
        tx.setHeader(EMPTY_BYTE_ARRAY, -1, -1, -1, -1, AUTH_DISABLED);
        storageEngine.apply(new TransactionToApply(tx, cursorContext), INTERNAL);
    }
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) CommandCreationContext(org.neo4j.storageengine.api.CommandCreationContext) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) CursorContext(org.neo4j.io.pagecache.context.CursorContext) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Aggregations

PhysicalTransactionRepresentation (org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)49 StorageCommand (org.neo4j.storageengine.api.StorageCommand)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 TransactionToApply (org.neo4j.kernel.impl.api.TransactionToApply)11 TransactionRepresentation (org.neo4j.kernel.impl.transaction.TransactionRepresentation)6 LogEntryCommand (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand)6 Test (org.junit.jupiter.api.Test)5 LogEntryStart (org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart)5 CursorContext (org.neo4j.io.pagecache.context.CursorContext)4 LogEntry (org.neo4j.kernel.impl.transaction.log.entry.LogEntry)4 LogEntryCommit (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit)4 ByteBuf (io.netty.buffer.ByteBuf)3 NetworkFlushableByteBuf (org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf)3 NeoStores (org.neo4j.kernel.impl.store.NeoStores)3 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)3 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)3 Command (org.neo4j.kernel.impl.transaction.command.Command)3 LogEntryWriter (org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)3 ReplicatedTransaction (org.neo4j.causalclustering.core.state.machines.tx.ReplicatedTransaction)2