use of org.apache.ratis.server.raftlog.segmented.LogSegmentPath in project alluxio by Alluxio.
the class RaftJournalDumper method readRatisLogFromDir.
private void readRatisLogFromDir() {
try (PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(mJournalEntryFile)));
RaftStorage storage = new RaftStorageImpl(getJournalDir(), RaftServerConfigKeys.Log.CorruptionPolicy.getDefault())) {
List<LogSegmentPath> paths = LogSegmentPath.getLogSegmentPaths(storage);
for (LogSegmentPath path : paths) {
final int entryCount = LogSegment.readSegmentFile(path.getPath().toFile(), path.getStartEnd(), RaftServerConfigKeys.Log.CorruptionPolicy.EXCEPTION, null, (proto) -> {
if (proto.hasStateMachineLogEntry()) {
try {
Journal.JournalEntry entry = Journal.JournalEntry.parseFrom(proto.getStateMachineLogEntry().getLogData().asReadOnlyByteBuffer());
writeSelected(out, entry);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
LOG.info("Read {} entries from log {}.", entryCount, path.getPath());
}
} catch (Exception e) {
LOG.error("Failed to read logs from journal.", e);
}
}
Aggregations