use of org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader in project neo4j by neo4j.
the class TestLogPruning method transactionCount.
private int transactionCount() throws IOException {
return aggregateLogData(version -> {
int counter = 0;
LogVersionBridge bridge = LogVersionBridge.NO_MORE_CHANNELS;
LogVersionedStoreChannel versionedStoreChannel = files.getLogFile().openForVersion(version);
try (ReadableLogChannel channel = new ReadAheadLogChannel(versionedStoreChannel, bridge, INSTANCE)) {
try (PhysicalTransactionCursor physicalTransactionCursor = new PhysicalTransactionCursor(channel, new VersionAwareLogEntryReader(db.getDependencyResolver().resolveDependency(StorageEngineFactory.class).commandReaderFactory()))) {
while (physicalTransactionCursor.next()) {
counter++;
}
}
}
return counter;
});
}
use of org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader in project neo4j by neo4j.
the class LogTestUtils method filterTransactionLogFile.
private static void filterTransactionLogFile(FileSystemAbstraction fileSystem, Path file, final LogHook<LogEntry> filter, ChannelNativeAccessor channelNativeAccessor) throws IOException {
filter.file(file);
try (StoreChannel in = fileSystem.read(file)) {
LogHeader logHeader = readLogHeader(ByteBuffers.allocate(CURRENT_FORMAT_LOG_HEADER_SIZE, INSTANCE), in, true, file);
assert logHeader != null : "Looks like we tried to read a log header of an empty pre-allocated file.";
PhysicalLogVersionedStoreChannel inChannel = new PhysicalLogVersionedStoreChannel(in, logHeader.getLogVersion(), logHeader.getLogFormatVersion(), file, channelNativeAccessor);
ReadableLogChannel inBuffer = new ReadAheadLogChannel(inChannel, INSTANCE);
LogEntryReader entryReader = new VersionAwareLogEntryReader(new TestCommandReaderFactory());
LogEntry entry;
while ((entry = entryReader.readLogEntry(inBuffer)) != null) {
filter.test(entry);
}
}
}
use of org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader in project neo4j by neo4j.
the class TransactionLogCatchUpWriterTest method verifyCheckpointInLog.
private void verifyCheckpointInLog() throws IOException {
LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>(new RecordStorageCommandReaderFactory());
PhysicalLogFiles logFiles = new PhysicalLogFiles(storeDir, fs);
final LatestCheckPointFinder checkPointFinder = new LatestCheckPointFinder(logFiles, fs, logEntryReader);
LatestCheckPointFinder.LatestCheckPoint checkPoint = checkPointFinder.find(0);
assertNotNull(checkPoint.checkPoint);
assertTrue(checkPoint.commitsAfterCheckPoint);
}
use of org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader in project neo4j by neo4j.
the class RebuildFromLogs method findLastTransactionId.
private long findLastTransactionId(PhysicalLogFiles logFiles, long highestVersion) throws IOException {
ReadableLogChannel logChannel = new ReadAheadLogChannel(PhysicalLogFile.openForVersion(logFiles, fs, highestVersion, false), NO_MORE_CHANNELS);
long lastTransactionId = -1;
LogEntryReader<ReadableClosablePositionAwareChannel> entryReader = new VersionAwareLogEntryReader<>();
try (IOCursor<CommittedTransactionRepresentation> cursor = new PhysicalTransactionCursor<>(logChannel, entryReader)) {
while (cursor.next()) {
lastTransactionId = cursor.get().getCommitEntry().getTxId();
}
}
return lastTransactionId;
}
use of org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader in project neo4j by neo4j.
the class MasterServerTest method shouldCleanExistentLockSessionOnFinishOffChannel.
@Test
public void shouldCleanExistentLockSessionOnFinishOffChannel() throws Exception {
Master master = mock(Master.class);
ConversationManager conversationManager = mock(ConversationManager.class);
LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>();
MasterServer masterServer = new MasterServer(master, mock(LogProvider.class), mock(Server.Configuration.class), mock(TxChecksumVerifier.class), mock(ByteCounterMonitor.class), mock(RequestMonitor.class), conversationManager, logEntryReader);
RequestContext requestContext = new RequestContext(1L, 1, 1, 0, 0L);
masterServer.stopConversation(requestContext);
Mockito.verify(conversationManager).stop(requestContext);
}
Aggregations