hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-21185 - WALPrettyPrinter: Additional useful info to be printed by wal printer tool, for debugability purposes
Date Thu, 04 Oct 2018 10:31:22 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2 8a5537b5f -> 9e3f3fdc1


HBASE-21185 - WALPrettyPrinter: Additional useful info to be printed by wal printer tool,
for debugability purposes

Signed-off-by: Allan Yang <allan163@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9e3f3fdc
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9e3f3fdc
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9e3f3fdc

Branch: refs/heads/branch-2
Commit: 9e3f3fdc1f2c95957a735cf5a83ab06ea76f80b8
Parents: 8a5537b
Author: Wellington Chevreuil <wellingtonchevreuil@ChevreuilWellington-MBP15.local>
Authored: Tue Oct 2 15:55:52 2018 +0100
Committer: Michael Stack <stack@apache.org>
Committed: Thu Oct 4 03:31:15 2018 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/wal/WALPrettyPrinter.java      | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/9e3f3fdc/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALPrettyPrinter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALPrettyPrinter.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALPrettyPrinter.java
index 85877fe..45934d4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALPrettyPrinter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALPrettyPrinter.java
@@ -80,6 +80,8 @@ public class WALPrettyPrinter {
   private PrintStream out;
   // for JSON encoding
   private static final ObjectMapper MAPPER = new ObjectMapper();
+  //allows for jumping straight to a given portion of the file
+  private long position;
 
   /**
    * Basic constructor that simply initializes values to reasonable defaults.
@@ -198,6 +200,15 @@ public class WALPrettyPrinter {
   }
 
   /**
+   * sets the position to start seeking the WAL file
+   * @param position
+   *          initial position to start seeking the given WAL file
+   */
+  public void setPosition(long position) {
+    this.position = position;
+  }
+
+  /**
    * enables output as a single, persistent list. at present, only relevant in
    * the case of JSON output.
    */
@@ -270,6 +281,10 @@ public class WALPrettyPrinter {
       firstTxn = true;
     }
 
+    if (position > 0) {
+      log.seek(position);
+    }
+
     try {
       WAL.Entry entry;
       while ((entry = log.next()) != null) {
@@ -293,6 +308,7 @@ public class WALPrettyPrinter {
           if (row == null || ((String) op.get("row")).equals(row)) {
             actions.add(op);
           }
+          op.put("total_size_sum", PrivateCellUtil.estimatedSizeOfCell(cell));
         }
         if (actions.isEmpty())
           continue;
@@ -317,8 +333,11 @@ public class WALPrettyPrinter {
               out.println("    tag: " + op.get("tag"));
             }
             if (outputValues) out.println("    value: " + op.get("value"));
+            out.println("cell total size sum: " + op.get("total_size_sum"));
           }
         }
+        out.println("edit heap size: " + entry.getEdit().heapSize());
+        out.println("position: " + log.getPosition());
       }
     } finally {
       log.close();
@@ -376,6 +395,7 @@ public class WALPrettyPrinter {
     options.addOption("s", "sequence", true,
         "Sequence to filter by. Pass sequence number.");
     options.addOption("w", "row", true, "Row to filter by. Pass row name.");
+    options.addOption("g", "goto", true, "Position to seek to in the file");
 
     WALPrettyPrinter printer = new WALPrettyPrinter();
     CommandLineParser parser = new PosixParser();
@@ -399,6 +419,9 @@ public class WALPrettyPrinter {
         printer.setSequenceFilter(Long.parseLong(cmd.getOptionValue("s")));
       if (cmd.hasOption("w"))
         printer.setRowFilter(cmd.getOptionValue("w"));
+      if (cmd.hasOption("g")) {
+        printer.setPosition(Long.parseLong(cmd.getOptionValue("g")));
+      }
     } catch (ParseException e) {
       e.printStackTrace();
       HelpFormatter formatter = new HelpFormatter();


Mime
View raw message