You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/07/04 15:17:27 UTC

[GitHub] [hbase] wchevreuil commented on a change in pull request #345: HBASE-22638 : Zookeeper Utility enhancements

wchevreuil commented on a change in pull request #345: HBASE-22638 : Zookeeper Utility enhancements
URL: https://github.com/apache/hbase/pull/345#discussion_r300441002
 
 

 ##########
 File path: hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
 ##########
 @@ -1859,31 +1873,33 @@ private static void getReplicationZnodesDump(ZKWatcher zkw, StringBuilder sb)
     // do a ls -r on this znode
     sb.append("\n").append(replicationZnode).append(": ");
     List<String> children = ZKUtil.listChildrenNoWatch(zkw, replicationZnode);
-    Collections.sort(children);
-    for (String child : children) {
-      String znode = ZNodePaths.joinZNode(replicationZnode, child);
-      if (znode.equals(zkw.getZNodePaths().peersZNode)) {
-        appendPeersZnodes(zkw, znode, sb);
-      } else if (znode.equals(zkw.getZNodePaths().queuesZNode)) {
-        appendRSZnodes(zkw, znode, sb);
-      } else if (znode.equals(zkw.getZNodePaths().hfileRefsZNode)) {
-        appendHFileRefsZnodes(zkw, znode, sb);
+    if (children != null) {
+      Collections.sort(children);
+      for (String child : children) {
+        String zNode = ZNodePaths.joinZNode(replicationZnode, child);
+        if (zNode.equals(zkw.getZNodePaths().peersZNode)) {
+          appendPeersZnodes(zkw, zNode, sb);
+        } else if (zNode.equals(zkw.getZNodePaths().queuesZNode)) {
+          appendRSZnodes(zkw, zNode, sb);
+        } else if (zNode.equals(zkw.getZNodePaths().hfileRefsZNode)) {
+          appendHFileRefsZnodes(zkw, zNode, sb);
+        }
       }
     }
   }
 
   private static void appendHFileRefsZnodes(ZKWatcher zkw, String hfileRefsZnode,
                                             StringBuilder sb) throws KeeperException {
     sb.append("\n").append(hfileRefsZnode).append(": ");
-    for (String peerIdZnode : ZKUtil.listChildrenNoWatch(zkw, hfileRefsZnode)) {
-      String znodeToProcess = ZNodePaths.joinZNode(hfileRefsZnode, peerIdZnode);
-      sb.append("\n").append(znodeToProcess).append(": ");
-      List<String> peerHFileRefsZnodes = ZKUtil.listChildrenNoWatch(zkw, znodeToProcess);
-      int size = peerHFileRefsZnodes.size();
-      for (int i = 0; i < size; i++) {
-        sb.append(peerHFileRefsZnodes.get(i));
-        if (i != size - 1) {
-          sb.append(", ");
+    final List<String> hFileRefChildrenNoWatchList =
+            ZKUtil.listChildrenNoWatch(zkw, hfileRefsZnode);
+    if (hFileRefChildrenNoWatchList != null) {
+      for (String peerIdZNode : hFileRefChildrenNoWatchList) {
 
 Review comment:
   lgtm. While @maoling comments makes sense in general, here the given if structure only accounts for 3 levels (2 nested inside), so I guess it's fine to leave it as it is, for consistence with the remaining of the class, as pointed out by @HorizonNet .

----------------------------------------------------------------
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