MCPcopy Create free account
hub / github.com/e2wugui/zeze / logDump

Method logDump

ZezeJava/ZezeJava/src/main/java/Zeze/Raft/Test.java:51–69  ·  view source on GitHub ↗
(String db)

Source from the content-addressed store, hash-verified

49 private boolean running = true;
50
51 private static void logDump(String db) throws IOException, RocksDBException {
52 RocksDB.loadLibrary();
53 try (var r1 = RocksDB.openReadOnly(RocksDatabase.getCommonOptions(), Paths.get(db, "logs").toString())) {
54 try (var it1 = r1.newIterator(RocksDatabase.getDefaultReadOptions())) {
55 var StateMachine = new TestStateMachine();
56 var snapshot = Paths.get(db, LogSequence.snapshotFileName).toString();
57 if (new File(snapshot).isFile())
58 StateMachine._loadSnapshot(snapshot);
59 try (var dumpFile = new FileOutputStream(db + ".txt")) {
60 dumpFile.write(String.format("SnapshotCount = %d\n", StateMachine.getCount()).getBytes(StandardCharsets.UTF_8));
61 for (it1.seekToFirst(); it1.isValid(); it1.next()) {
62 var l1 = RaftLog.decode(new Binary(it1.value()), StateMachine::logFactory);
63 dumpFile.write(l1.toString().getBytes(StandardCharsets.UTF_8));
64 dumpFile.write('\n');
65 }
66 }
67 }
68 }
69 }
70
71 public void run(String command, String[] args) throws InterruptedException {
72 System.out.println(command);

Callers 1

_runMethod · 0.95

Calls 13

getCommonOptionsMethod · 0.95
getDefaultReadOptionsMethod · 0.95
_loadSnapshotMethod · 0.95
getCountMethod · 0.95
decodeMethod · 0.95
formatMethod · 0.80
isValidMethod · 0.80
getMethod · 0.65
writeMethod · 0.65
getBytesMethod · 0.65
nextMethod · 0.65
valueMethod · 0.65

Tested by

no test coverage detected