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/01 02:10:16 UTC

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

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

 ##########
 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:
   - to avoid too deep nest.
   ```
   if (hFileRefChildrenNoWatchList == null) {
       return;
   }
   ```
   - Others,LGTM
   

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