From ad853582b47ad26ad4b31a01a6c6af31e6c2d8a3 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Fri, 11 Jan 2013 19:10:33 +0000 Subject: [PATCH] HBASE-7540 Make znode dump to print a dump of replciation znodes git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1432235 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/hadoop/hbase/zookeeper/ZKUtil.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java index e475dfaeae7..058751b5f34 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java @@ -26,6 +26,7 @@ import java.net.InetSocketAddress; import java.net.InetAddress; import java.net.Socket; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Properties; import java.util.HashMap; @@ -1253,6 +1254,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) { @@ -1279,6 +1285,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 stack = new LinkedList(); + 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. *