Search in sources :

Example 1 with LogHeaderReader.readLogHeader

use of org.neo4j.kernel.impl.transaction.log.entry.LogHeaderReader.readLogHeader in project neo4j by neo4j.

the class LogTestUtils method openLogEntryCursor.

private static LogEntryCursor openLogEntryCursor(FileSystemAbstraction fs, File firstFile, LogVersionBridge versionBridge) {
    StoreChannel channel = null;
    try {
        channel = fs.open(firstFile, "r");
        ByteBuffer buffer = ByteBuffer.allocate(LogHeader.LOG_HEADER_SIZE);
        LogHeader header = LogHeaderReader.readLogHeader(buffer, channel, true, firstFile);
        PhysicalLogVersionedStoreChannel logVersionedChannel = new PhysicalLogVersionedStoreChannel(channel, header.logVersion, header.logFormatVersion);
        ReadableLogChannel logChannel = new ReadAheadLogChannel(logVersionedChannel, versionBridge, ReadAheadLogChannel.DEFAULT_READ_AHEAD_SIZE);
        return new LogEntryCursor(new VersionAwareLogEntryReader<>(), logChannel);
    } catch (Throwable t) {
        if (channel != null) {
            try {
                channel.close();
            } catch (IOException e) {
                t.addSuppressed(e);
            }
        }
        throw new RuntimeException(t);
    }
}
Also used : ReadableLogChannel(org.neo4j.kernel.impl.transaction.log.ReadableLogChannel) StoreChannel(org.neo4j.io.fs.StoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer) ReadAheadLogChannel(org.neo4j.kernel.impl.transaction.log.ReadAheadLogChannel) LogEntryCursor(org.neo4j.kernel.impl.transaction.log.LogEntryCursor) LogHeaderReader.readLogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderReader.readLogHeader) LogHeaderWriter.writeLogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter.writeLogHeader) LogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeader)

Aggregations

IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 StoreChannel (org.neo4j.io.fs.StoreChannel)1 LogEntryCursor (org.neo4j.kernel.impl.transaction.log.LogEntryCursor)1 PhysicalLogVersionedStoreChannel (org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel)1 ReadAheadLogChannel (org.neo4j.kernel.impl.transaction.log.ReadAheadLogChannel)1 ReadableLogChannel (org.neo4j.kernel.impl.transaction.log.ReadableLogChannel)1 LogHeader (org.neo4j.kernel.impl.transaction.log.entry.LogHeader)1 LogHeaderReader.readLogHeader (org.neo4j.kernel.impl.transaction.log.entry.LogHeaderReader.readLogHeader)1 LogHeaderWriter.writeLogHeader (org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter.writeLogHeader)1