hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1432319 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
Date Fri, 11 Jan 2013 22:22:18 GMT
Author: larsh
Date: Fri Jan 11 22:22:18 2013
New Revision: 1432319

URL: http://svn.apache.org/viewvc?rev=1432319&view=rev
Log:
HBASE-7540 Make znode dump to print a dump of replication znodes (Himanshu)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java?rev=1432319&r1=1432318&r2=1432319&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java Fri Jan
11 22:22:18 2013
@@ -1467,6 +1467,11 @@ public class ZKUtil {
       for (String child : listChildrenNoWatch(zkw, zkw.rsZNode)) {
         sb.append("\n ").append(child);
       }
+      try {
+        getReplicationZnodesDump(zkw, sb);
+      } catch (KeeperException ke) {
+        LOG.warn("Couldn't get the replication znode dump." + ke.getStackTrace());
+      }
       sb.append("\nQuorum Server Statistics:");
       String[] servers = zkw.getQuorum().split(",");
       for (String server : servers) {
@@ -1493,6 +1498,25 @@ public class ZKUtil {
     return sb.toString();
   }
 
+  private static void getReplicationZnodesDump(ZooKeeperWatcher zkw, StringBuilder sb)
+      throws KeeperException {
+    String replicationZNodeName = zkw.getConfiguration().get("zookeeper.znode.replication",
+      "replication");
+    String replicationZnode = joinZNode(zkw.baseZNode, replicationZNodeName);
+    if (ZKUtil.checkExists(zkw, replicationZnode) == -1)
+      return;
+    // do a ls -r on this znode
+    List<String> stack = new LinkedList<String>();
+    stack.add(replicationZnode);
+    do {
+      String znodeToProcess = stack.remove(stack.size() - 1);
+      sb.append("\n").append(znodeToProcess).append(": ")
+          .append(Bytes.toString(ZKUtil.getData(zkw, znodeToProcess)));
+      for (String zNodeChild : ZKUtil.listChildrenNoWatch(zkw, znodeToProcess)) {
+        stack.add(ZKUtil.joinZNode(znodeToProcess, zNodeChild));
+      }
+    } while (stack.size() > 0);
+  }
   /**
    * Gets the statistics from the given server.
    *



Mime
View raw message