use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class TransactionRecordStateTest method transactionRepresentationOf.
private PhysicalTransactionRepresentation transactionRepresentationOf(TransactionRecordState writeTransaction) throws TransactionFailureException {
List<StorageCommand> commands = new ArrayList<>();
writeTransaction.extractCommands(commands);
PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(commands);
tx.setHeader(new byte[0], 0, 0, 0, 0, 0, 0);
return tx;
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation 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);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class WriteTransactionCommandOrderingTest method shouldExecuteCommandsInTheSameOrderRegardlessOfItBeingRecoveredOrNot.
@Test
public void shouldExecuteCommandsInTheSameOrderRegardlessOfItBeingRecoveredOrNot() throws Exception {
// Given
TransactionRecordState tx = injectAllPossibleCommands();
// When
PhysicalTransactionRepresentation commands = transactionRepresentationOf(tx);
// Then
final OrderVerifyingCommandHandler orderVerifyingCommandHandler = new OrderVerifyingCommandHandler();
commands.accept(element -> ((Command) element).handle(orderVerifyingCommandHandler));
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class TransactionRepresentationCommitProcessTest method shouldSuccessfullyCommitTransactionWithNoCommands.
@Test
public void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception {
// GIVEN
long txId = 11;
long commitTimestamp = System.currentTimeMillis();
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
TransactionAppender appender = new TestableTransactionAppender(transactionIdStore);
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
StorageEngine storageEngine = mock(StorageEngine.class);
TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);
PhysicalTransactionRepresentation noCommandTx = new PhysicalTransactionRepresentation(Collections.emptyList());
noCommandTx.setHeader(new byte[0], -1, -1, -1, -1, -1, -1);
// WHEN
commitProcess.commit(new TransactionToApply(noCommandTx), commitEvent, INTERNAL);
verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class LegacyLogEntryWriterTest method shouldWriteAllTheEntryInSeveralCommitsToTheFile.
@Test
public void shouldWriteAllTheEntryInSeveralCommitsToTheFile() 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 start1 = new LogEntryStart(0, 1, 2L, 3L, EMPTY_ADDITIONAL_ARRAY, UNSPECIFIED);
final LogEntryCommand command1 = new LogEntryCommand(new Command.NodeCommand(nodeRecord, nodeRecord));
final LogEntryCommit commit1 = new OnePhaseCommit(42L, 43L);
final LogEntryStart start2 = new LogEntryStart(9, 8, 7L, 6L, EMPTY_ADDITIONAL_ARRAY, UNSPECIFIED);
final LogEntryCommand command2 = new LogEntryCommand(new Command.RelationshipCommand(relRecord, relRecord));
final LogEntryCommit commit2 = new OnePhaseCommit(84L, 85L);
// when
IOCursor<LogEntry> cursor = mockCursor(start1, command1, commit1, start2, command2, commit2);
writer.writeAllLogEntries(channel, cursor);
// then
verify(logEntryWriter, times(1)).writeStartEntry(0, 1, 2L, 3L, EMPTY_ADDITIONAL_ARRAY);
final TransactionRepresentation expected1 = new PhysicalTransactionRepresentation(Arrays.asList(command1.getXaCommand()));
verify(logEntryWriter, times(1)).serialize(eq(expected1));
verify(logEntryWriter, times(1)).writeCommitEntry(42L, 43L);
verify(logEntryWriter, times(1)).writeStartEntry(9, 8, 7L, 6L, EMPTY_ADDITIONAL_ARRAY);
final TransactionRepresentation expected2 = new PhysicalTransactionRepresentation(Arrays.asList(command2.getXaCommand()));
verify(logEntryWriter, times(1)).serialize(eq(expected2));
verify(logEntryWriter, times(1)).writeCommitEntry(84L, 85L);
}
Aggregations