public static void traverseZkTree(SolrZkClient zkClient,final String path,final VISIT_ORDER visitOrder,final ZkVisitor visitor) throws InterruptedException, KeeperException {
  if (visitOrder == VISIT_ORDER.VISIT_PRE) {
    visitor.visit(path);
  }
  List<String> children;
  try {
    children=zkClient.getChildren(path,null,true);
  }
 catch (  KeeperException.NoNodeException r) {
    return;
  }
  for (  String string : children) {
    if (path.equals("/") && string.equals("zookeeper"))     continue;
    if (path.startsWith("/zookeeper"))     continue;
    if (path.equals("/")) {
      traverseZkTree(zkClient,path + string,visitOrder,visitor);
    }
 else {
      traverseZkTree(zkClient,path + "/" + string,visitOrder,visitor);
    }
  }
  if (visitOrder == VISIT_ORDER.VISIT_POST) {
    visitor.visit(path);
  }
}

public static void traverseZkTree ( SolrZkClient zkClient , final String path , final VISIT_ORDER visitOrder , final ZkVisitor visitor ) throws InterruptedException , KeeperException { if ( visitOrder == VISIT_ORDER . VISIT_PRE ) { visitor . visit ( path ) ; } List < String > children ; try { children = zkClient . getChildren ( path , null , true ) ; } catch ( KeeperException . NoNodeException r ) { return ; } for ( String string : children ) { if ( path . equals ( "/" ) && string . equals ( "zookeeper" ) ) continue ; if ( path . startsWith ( "/zookeeper" ) ) continue ; if ( path . equals ( "/" ) ) { traverseZkTree ( zkClient , path + string , visitOrder , visitor ) ; } else { traverseZkTree ( zkClient , path + "/" + string , visitOrder , visitor ) ; } } if ( visitOrder == VISIT_ORDER . VISIT_POST ) { visitor . visit ( path ) ; } }
recursively visit a zk tree rooted at path and apply the given visitor to each path . exists as a separate method because some of the logic can get nuanced .
