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;
});
}
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)));
}
}
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);
}
}
}
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);
}
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));
}
}
Aggregations