Search in sources :

Example 21 with VersionAwareLogEntryReader

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;
    });
}
Also used : PhysicalTransactionCursor(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionCursor) ReadableLogChannel(org.neo4j.kernel.impl.transaction.log.ReadableLogChannel) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) LogVersionBridge(org.neo4j.kernel.impl.transaction.log.LogVersionBridge) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) ReadAheadLogChannel(org.neo4j.kernel.impl.transaction.log.ReadAheadLogChannel)

Example 22 with VersionAwareLogEntryReader

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);
        }
    }
}
Also used : ReadableLogChannel(org.neo4j.kernel.impl.transaction.log.ReadableLogChannel) StoreChannel(org.neo4j.io.fs.StoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) LogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) TestCommandReaderFactory(org.neo4j.kernel.impl.api.TestCommandReaderFactory) ReadAheadLogChannel(org.neo4j.kernel.impl.transaction.log.ReadAheadLogChannel) LogHeaderReader.readLogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderReader.readLogHeader) LogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeader) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry)

Example 23 with VersionAwareLogEntryReader

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);
}
Also used : RecordStorageCommandReaderFactory(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory) LatestCheckPointFinder(org.neo4j.kernel.recovery.LatestCheckPointFinder) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)

Example 24 with VersionAwareLogEntryReader

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;
}
Also used : PhysicalTransactionCursor(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionCursor) ReadableLogChannel(org.neo4j.kernel.impl.transaction.log.ReadableLogChannel) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) ReadAheadLogChannel(org.neo4j.kernel.impl.transaction.log.ReadAheadLogChannel) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)

Example 25 with VersionAwareLogEntryReader

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);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) ByteCounterMonitor(org.neo4j.kernel.monitoring.ByteCounterMonitor) TxChecksumVerifier(org.neo4j.com.TxChecksumVerifier) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) RequestContext(org.neo4j.com.RequestContext) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) RequestMonitor(org.neo4j.com.monitor.RequestMonitor) Test(org.junit.Test)

Aggregations

VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)39 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)18 ReadableLogChannel (org.neo4j.kernel.impl.transaction.log.ReadableLogChannel)9 LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)9 IOException (java.io.IOException)8 ReadAheadLogChannel (org.neo4j.kernel.impl.transaction.log.ReadAheadLogChannel)8 LogEntry (org.neo4j.kernel.impl.transaction.log.entry.LogEntry)8 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)8 File (java.io.File)7 Test (org.junit.Test)7 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)7 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)7 LatestCheckPointFinder (org.neo4j.kernel.recovery.LatestCheckPointFinder)7 LogEntryCursor (org.neo4j.kernel.impl.transaction.log.LogEntryCursor)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)5 LogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader)5 LogFile (org.neo4j.kernel.impl.transaction.log.files.LogFile)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 StoreChannel (org.neo4j.io.fs.StoreChannel)4