You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2019/07/23 13:51:49 UTC

[GitHub] [zookeeper] eolivelli commented on a change in pull request #984: ZOOKEEPER-3427: Introduce SnapshotComparer that assists debugging with snapshots.

eolivelli commented on a change in pull request #984: ZOOKEEPER-3427: Introduce SnapshotComparer that assists debugging with snapshots.
URL: https://github.com/apache/zookeeper/pull/984#discussion_r293713176
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/SnapshotComparer.java
 ##########
 @@ -0,0 +1,455 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.server;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+import java.util.zip.Adler32;
+import java.util.zip.CheckedInputStream;
+
+import org.apache.commons.cli.BasicParser;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.ParseException;
+import org.apache.jute.BinaryInputArchive;
+import org.apache.jute.InputArchive;
+import org.apache.zookeeper.server.persistence.FileSnap;
+
+/**
+ * Compare two data tree snapshots, output information about the delta.
+ * Only outputs information about permanent nodes, ignoring both sessions
+ * and ephemeral nodes.
+ */
+public class SnapshotComparer {
+  private final Options options;
+  private static final String leftOption = "left";
+  private static final String rightOption = "right";
+  private static final String byteThresholdOption = "bytes";
+  private static final String nodeThresholdOption = "nodes";
+  private static final String debugOption = "debug";
+  private static final String interactiveOption = "interactive";
+
+  @SuppressWarnings("static")
+  private SnapshotComparer() {
+    options = new Options();
+    options.addOption(
+        OptionBuilder
+            .hasArg()
+            .isRequired(true)
+            .withLongOpt(leftOption)
+            .withDescription("the left snapshot file")
+            .withArgName("LEFT")
+            .withType(File.class)
+            .create("l"));
+    options.addOption(
+        OptionBuilder
+            .hasArg()
+            .isRequired(true)
+            .withLongOpt(rightOption)
+            .withDescription("the right snapshot file")
+            .withArgName("RIGHT")
+            .withType(File.class)
+            .create("r"));
+    options.addOption(
+        OptionBuilder
+            .hasArg()
+            .isRequired(true)
+            .withLongOpt(byteThresholdOption)
+            .withDescription("the node data delta size threshold, in bytes, for printing the node")
+            .withArgName("BYTETHRESHOLD")
+            .withType(File.class)
 
 Review comment:
   Are you sure?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services