Search in sources :

Example 11 with LogVersionedStoreChannel

use of org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel 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 12 with LogVersionedStoreChannel

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

the class CheckTxLogsTest method writeContent.

private void writeContent(File log, ThrowingConsumer<TransactionLogWriter, IOException> consumer) throws IOException {
    FileSystemAbstraction fs = ensureLogExists(log);
    try (StoreChannel channel = fs.open(log, "rw");
        LogVersionedStoreChannel versionedChannel = new PhysicalLogVersionedStoreChannel(channel, 0, (byte) 0);
        PhysicalFlushableChannel writableLogChannel = new PhysicalFlushableChannel(versionedChannel)) {
        long offset = channel.size();
        channel.position(offset);
        consumer.accept(new TransactionLogWriter(new LogEntryWriter(writableLogChannel)));
    }
}
Also used : FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) StoreChannel(org.neo4j.io.fs.StoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) TransactionLogWriter(org.neo4j.kernel.impl.transaction.log.TransactionLogWriter) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)

Example 13 with LogVersionedStoreChannel

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

the class LegacyLogs method migrateLogs.

public void migrateLogs(File storeDir, File migrationDir) throws IOException {
    File[] logFiles = fs.listFiles(storeDir, versionedLegacyLogFilesFilter);
    for (File file : logFiles) {
        final Pair<LogHeader, IOCursor<LogEntry>> pair = reader.openReadableChannel(file);
        final LogHeader header = pair.first();
        try (IOCursor<LogEntry> cursor = pair.other();
            LogVersionedStoreChannel channel = writer.openWritableChannel(new File(migrationDir, file.getName()))) {
            writer.writeLogHeader(channel, header);
            writer.writeAllLogEntries(channel, cursor);
        }
    }
}
Also used : IOCursor(org.neo4j.cursor.IOCursor) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) File(java.io.File) LogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeader) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry)

Example 14 with LogVersionedStoreChannel

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

the class LegacyLogEntryWriter method openWritableChannel.

public LogVersionedStoreChannel openWritableChannel(File file) throws IOException {
    final StoreChannel storeChannel = fs.open(file, "rw");
    final long version = getLegacyLogVersion(file.getName());
    return new PhysicalLogVersionedStoreChannel(storeChannel, version, CURRENT_LOG_VERSION);
}
Also used : LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) StoreChannel(org.neo4j.io.fs.StoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel)

Example 15 with LogVersionedStoreChannel

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

the class RecoveryTest method writeSomeData.

private void writeSomeData(File file, Visitor<Pair<LogEntryWriter, Consumer<LogPositionMarker>>, IOException> visitor) throws IOException {
    try (LogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel(fileSystemRule.get().open(file, "rw"), logVersion, CURRENT_LOG_VERSION);
        final PositionAwarePhysicalFlushableChannel writableLogChannel = new PositionAwarePhysicalFlushableChannel(versionedStoreChannel)) {
        writeLogHeader(writableLogChannel, logVersion, 2L);
        Consumer<LogPositionMarker> consumer = marker -> {
            try {
                writableLogChannel.getCurrentPosition(marker);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        };
        LogEntryWriter first = new LogEntryWriter(writableLogChannel);
        visitor.visit(Pair.of(first, consumer));
    }
}
Also used : LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) LogHeaderWriter.writeLogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter.writeLogHeader) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) DeadSimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.DeadSimpleTransactionIdStore) LogFile(org.neo4j.kernel.impl.transaction.log.LogFile) Assert.fail(org.junit.Assert.fail) DefaultRecoverySPI(org.neo4j.kernel.recovery.DefaultRecoverySPI) BASE_TX_COMMIT_TIMESTAMP(org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP) Recovery(org.neo4j.kernel.recovery.Recovery) StorageEngine(org.neo4j.storageengine.api.StorageEngine) LogVersionRepository(org.neo4j.kernel.impl.transaction.log.LogVersionRepository) CURRENT_LOG_VERSION(org.neo4j.kernel.impl.transaction.log.entry.LogVersions.CURRENT_LOG_VERSION) TestDirectory(org.neo4j.test.rule.TestDirectory) DeadSimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.DeadSimpleLogVersionRepository) LogPositionMarker(org.neo4j.kernel.impl.transaction.log.LogPositionMarker) LogEntryStart(org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) Matchers.any(org.mockito.Matchers.any) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) Mockito.inOrder(org.mockito.Mockito.inOrder) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry) LogHeaderCache(org.neo4j.kernel.impl.transaction.log.LogHeaderCache) Mockito.mock(org.mockito.Mockito.mock) PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Pair(org.neo4j.helpers.collection.Pair) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) Mockito.verifyZeroInteractions(org.mockito.Mockito.verifyZeroInteractions) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) PositionAwarePhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PositionAwarePhysicalFlushableChannel) NO_MONITOR(org.neo4j.kernel.recovery.PositionToRecoverFrom.NO_MONITOR) InOrder(org.mockito.InOrder) CheckPoint(org.neo4j.kernel.impl.transaction.log.entry.CheckPoint) LogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader) TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) Mockito.times(org.mockito.Mockito.times) OnePhaseCommit(org.neo4j.kernel.impl.transaction.log.entry.OnePhaseCommit) LatestCheckPointFinder(org.neo4j.kernel.recovery.LatestCheckPointFinder) File(java.io.File) Consumer(java.util.function.Consumer) Rule(org.junit.Rule) DefaultFileSystemRule(org.neo4j.test.rule.fs.DefaultFileSystemRule) Visitor(org.neo4j.helpers.collection.Visitor) Assert.assertEquals(org.junit.Assert.assertEquals) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PositionAwarePhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PositionAwarePhysicalFlushableChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) IOException(java.io.IOException) LogPositionMarker(org.neo4j.kernel.impl.transaction.log.LogPositionMarker)

Aggregations

LogVersionedStoreChannel (org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel)22 LogEntry (org.neo4j.kernel.impl.transaction.log.entry.LogEntry)11 PhysicalLogVersionedStoreChannel (org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel)10 StoreChannel (org.neo4j.io.fs.StoreChannel)8 ReadAheadLogChannel (org.neo4j.kernel.impl.transaction.log.ReadAheadLogChannel)8 File (java.io.File)6 Test (org.junit.Test)6 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)6 LogEntryCommit (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit)6 LogEntryStart (org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart)6 LogEntryWriter (org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)6 LogHeader (org.neo4j.kernel.impl.transaction.log.entry.LogHeader)6 Test (org.junit.jupiter.api.Test)5 LogEntryCursor (org.neo4j.kernel.impl.transaction.log.LogEntryCursor)5 ReaderLogVersionBridge (org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge)5 IOException (java.io.IOException)4 ByteBuffer (java.nio.ByteBuffer)4 Path (java.nio.file.Path)4 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)3 LogVersionBridge (org.neo4j.kernel.impl.transaction.log.LogVersionBridge)3