use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class PhysicalTransactionCursorTest method shouldCallTheVisitorWithTheFoundTransaction.
@Test
void shouldCallTheVisitorWithTheFoundTransaction() throws IOException {
// given
when(entryReader.readLogEntry(channel)).thenReturn(A_START_ENTRY, A_COMMAND_ENTRY, A_COMMIT_ENTRY);
// when
cursor.next();
// then
PhysicalTransactionRepresentation txRepresentation = new PhysicalTransactionRepresentation(singletonList(A_COMMAND_ENTRY.getCommand()));
assertEquals(new CommittedTransactionRepresentation(A_START_ENTRY, txRepresentation, A_COMMIT_ENTRY), cursor.get());
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class RecoveryCorruptedTransactionLogIT method addCorruptedCommandsToLastLogFile.
private void addCorruptedCommandsToLastLogFile(LogEntryWriterWrapper logEntryWriterWrapper) throws IOException {
PositiveLogFilesBasedLogVersionRepository versionRepository = new PositiveLogFilesBasedLogVersionRepository(logFiles);
LogFiles internalLogFiles = LogFilesBuilder.builder(databaseLayout, fileSystem).withLogVersionRepository(versionRepository).withTransactionIdStore(new SimpleTransactionIdStore()).withStoreId(StoreId.UNKNOWN).withCommandReaderFactory(StorageEngineFactory.defaultStorageEngine().commandReaderFactory()).build();
try (Lifespan lifespan = new Lifespan(internalLogFiles)) {
LogFile transactionLogFile = internalLogFiles.getLogFile();
LogEntryWriter<FlushablePositionAwareChecksumChannel> realLogEntryWriter = transactionLogFile.getTransactionLogWriter().getWriter();
LogEntryWriter<FlushablePositionAwareChecksumChannel> wrappedLogEntryWriter = logEntryWriterWrapper.wrap(realLogEntryWriter);
StaticLogEntryWriterFactory<FlushablePositionAwareChecksumChannel> factory = new StaticLogEntryWriterFactory<>(wrappedLogEntryWriter);
TransactionLogWriter writer = new TransactionLogWriter(realLogEntryWriter.getChannel(), factory);
List<StorageCommand> commands = new ArrayList<>();
commands.add(new Command.PropertyCommand(new PropertyRecord(1), new PropertyRecord(2)));
commands.add(new Command.NodeCommand(new NodeRecord(2), new NodeRecord(3)));
PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(commands);
transaction.setHeader(new byte[0], 0, 0, 0, 0, ANONYMOUS);
writer.append(transaction, 1000, BASE_TX_CHECKSUM);
}
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation 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;
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class BatchingNeoStoresTest method apply.
private static void apply(TxState txState, CommandCreationContext commandCreationContext, RecordStorageEngine storageEngine) throws Exception {
List<StorageCommand> commands = new ArrayList<>();
try (RecordStorageReader storageReader = storageEngine.newReader()) {
storageEngine.createCommands(commands, txState, storageReader, commandCreationContext, ResourceLocker.IGNORE, LockTracer.NONE, BASE_TX_ID, v -> v, NULL, INSTANCE);
CommandsToApply apply = new TransactionToApply(new PhysicalTransactionRepresentation(commands, new byte[0], 0, 0, 0, 0, ANONYMOUS), NULL);
storageEngine.apply(apply, TransactionApplicationMode.INTERNAL);
}
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class CommitProcessTracingIT method tracePageCacheAccessOnTransactionApply.
@Test
void tracePageCacheAccessOnTransactionApply() throws TransactionFailureException {
var transaction = new PhysicalTransactionRepresentation(List.of(new Command.NodeCountsCommand(1, 2)), EMPTY_BYTE_ARRAY, 0, 0, 0, 0, ANONYMOUS);
var pageCacheTracer = new DefaultPageCacheTracer();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnTransactionApply"))) {
assertZeroCursor(cursorContext);
commitProcess.commit(new TransactionToApply(transaction, cursorContext), NULL, EXTERNAL);
assertCursor(cursorContext, 3);
}
}
Aggregations