Github user enixon commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/619#discussion_r217561003
--- Diff: src/java/main/org/apache/zookeeper/server/SnapshotFormatter.java
---
@@ -34,79 +36,133 @@
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.zookeeper.data.StatPersisted;
import org.apache.zookeeper.server.persistence.FileSnap;
+import org.apache.zookeeper.server.persistence.Util;
+import org.json.simple.JSONValue;
+
+import static
org.apache.zookeeper.server.persistence.FileSnap.SNAPSHOT_FILE_PREFIX;
/**
* Dump a snapshot file to stdout.
+ *
+ * For JSON format, followed https://dev.yorhel.nl/ncdu/jsonfmt
*/
@InterfaceAudience.Public
public class SnapshotFormatter {
+ private static Integer INODE_IDX = 1000;
+
/**
* USAGE: SnapshotFormatter snapshot_file
*/
public static void main(String[] args) throws Exception {
- if (args.length != 1) {
- System.err.println("USAGE: SnapshotFormatter snapshot_file");
+ String snapshotFile = null;
+ boolean dumpData = false;
+ boolean dumpJson = false;
+
+ int i;
+ for (i = 0; i < args.length; i++) {
+ if (args[i].equals("-d")) {
+ dumpData = true;
+ } else if (args[i].equals("-json")) {
+ dumpJson = true;
+ } else {
--- End diff --
If both `-d` and `-json` are specified then the `-d` is ignored. Just an
oversight, not a feature. Let me print out an error message or something in
that case.
---