use of org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel 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.PhysicalLogVersionedStoreChannel 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)));
}
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel 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);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel 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));
}
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel in project neo4j by neo4j.
the class LogTestUtils method filterNeostoreLogicalLog.
public static File filterNeostoreLogicalLog(FileSystemAbstraction fileSystem, File file, final LogHook<LogEntry> filter) throws IOException {
filter.file(file);
File tempFile = new File(file.getAbsolutePath() + ".tmp");
fileSystem.deleteFile(tempFile);
try (StoreChannel in = fileSystem.open(file, "r");
StoreChannel out = fileSystem.open(tempFile, "rw")) {
LogHeader logHeader = transferLogicalLogHeader(in, out, ByteBuffer.allocate(LOG_HEADER_SIZE));
PhysicalLogVersionedStoreChannel outChannel = new PhysicalLogVersionedStoreChannel(out, logHeader.logVersion, logHeader.logFormatVersion);
PhysicalLogVersionedStoreChannel inChannel = new PhysicalLogVersionedStoreChannel(in, logHeader.logVersion, logHeader.logFormatVersion);
ReadableLogChannel inBuffer = new ReadAheadLogChannel(inChannel, LogVersionBridge.NO_MORE_CHANNELS);
LogEntryReader<ReadableLogChannel> entryReader = new VersionAwareLogEntryReader<>();
LogEntry entry;
while ((entry = entryReader.readLogEntry(inBuffer)) != null) {
if (filter.test(entry)) {
// TODO allright, write to outBuffer
}
}
}
return tempFile;
}
Aggregations