Search in sources :

Example 1 with PhysicalTransactionRepresentation

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

the class LegacyLogEntryWriterTest method shouldWriteAllTheEntryInACommitToTheFile.

@Test
public void shouldWriteAllTheEntryInACommitToTheFile() throws IOException {
    // given
    final LogVersionedStoreChannel channel = mock(LogVersionedStoreChannel.class);
    final LogEntryWriter logEntryWriter = mock(LogEntryWriter.class);
    final LegacyLogEntryWriter writer = new LegacyLogEntryWriter(fs, liftToFactory(logEntryWriter));
    final LogEntryStart start = new LogEntryStart(0, 1, 2L, 3L, EMPTY_ADDITIONAL_ARRAY, UNSPECIFIED);
    final LogEntryCommand command = new LogEntryCommand(new Command.NodeCommand(nodeRecord, nodeRecord));
    final LogEntryCommit commit = new OnePhaseCommit(42L, 43L);
    // when
    final IOCursor<LogEntry> cursor = mockCursor(start, command, commit);
    writer.writeAllLogEntries(channel, cursor);
    // then
    verify(logEntryWriter, times(1)).writeStartEntry(0, 1, 2L, 3L, EMPTY_ADDITIONAL_ARRAY);
    final TransactionRepresentation expected = new PhysicalTransactionRepresentation(Arrays.asList(command.getXaCommand()));
    verify(logEntryWriter, times(1)).serialize(eq(expected));
    verify(logEntryWriter, times(1)).writeCommitEntry(42L, 43L);
}
Also used : LogEntryStart(org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) LogEntryCommand(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) Command(org.neo4j.kernel.impl.transaction.command.Command) LogEntryCommand(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand) LogEntryCommit(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) OnePhaseCommit(org.neo4j.kernel.impl.transaction.log.entry.OnePhaseCommit) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) Test(org.junit.Test)

Example 2 with PhysicalTransactionRepresentation

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

the class Commands method transactionRepresentation.

public static TransactionRepresentation transactionRepresentation(Collection<StorageCommand> commands) {
    PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(commands);
    tx.setHeader(new byte[0], 0, 0, 0, 0, 0, 0);
    return tx;
}
Also used : PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 3 with PhysicalTransactionRepresentation

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

the class CommitProcessStateMachineCollaborationTest method physicalTx.

private PhysicalTransactionRepresentation physicalTx(int lockSessionId) {
    PhysicalTransactionRepresentation physicalTx = mock(PhysicalTransactionRepresentation.class);
    when(physicalTx.getLockSessionId()).thenReturn(lockSessionId);
    return physicalTx;
}
Also used : PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 4 with PhysicalTransactionRepresentation

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

the class ReplicatedTransactionStateMachineTest method physicalTx.

private PhysicalTransactionRepresentation physicalTx(int lockSessionId) {
    PhysicalTransactionRepresentation physicalTx = mock(PhysicalTransactionRepresentation.class);
    when(physicalTx.getLockSessionId()).thenReturn(lockSessionId);
    return physicalTx;
}
Also used : PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 5 with PhysicalTransactionRepresentation

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

the class CheckTxLogsTest method writeTxContent.

private void writeTxContent(File log, long txId, Command... commands) throws IOException {
    PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(Arrays.asList(commands));
    tx.setHeader(new byte[0], 0, 0, 0, 0, 0, 0);
    writeContent(log, (txWriter) -> txWriter.append(tx, txId));
}
Also used : 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