public static String dump(final ZKWatcher zkWatcher) {
    final int zkDumpConnectionTimeOut =
      zkWatcher.getConfiguration().getInt("zookeeper.dump.connection.timeout", 1000);
    StringBuilder sb = new StringBuilder();
    try {
      sb.append("HBase is rooted at ").append(zkWatcher.getZNodePaths().baseZNode);
      sb.append("\nActive master address: ");
      try {
        sb.append("\n ").append(MasterAddressTracker.getMasterAddress(zkWatcher));
      } catch (IOException e) {
        sb.append("<<FAILED LOOKUP: ").append(e.getMessage()).append(">>");
      }
      sb.append("\nBackup master addresses:");
      final List<String> backupMasterChildrenNoWatchList =
        ZKUtil.listChildrenNoWatch(zkWatcher, zkWatcher.getZNodePaths().backupMasterAddressesZNode);
      if (backupMasterChildrenNoWatchList != null) {
        for (String child : backupMasterChildrenNoWatchList) {
          sb.append("\n ").append(child);
        }
      }
      sb.append("\nRegion server holding hbase:meta:");
      sb.append("\n ").append(MetaTableLocator.getMetaRegionLocation(zkWatcher));
      int numMetaReplicas = zkWatcher.getMetaReplicaNodes().size();
      for (int i = 1; i < numMetaReplicas; i++) {
        sb.append("\n").append(" replica").append(i).append(": ")
          .append(MetaTableLocator.getMetaRegionLocation(zkWatcher, i));
      }
      sb.append("\nRegion servers:");
      final List<String> rsChildrenNoWatchList =
        ZKUtil.listChildrenNoWatch(zkWatcher, zkWatcher.getZNodePaths().rsZNode);
      if (rsChildrenNoWatchList != null) {
        for (String child : rsChildrenNoWatchList) {
          sb.append("\n ").append(child);
        }
      }
      try {
        getReplicationZnodesDump(zkWatcher, sb);
      } catch (KeeperException ke) {
        LOG.warn("Couldn't get the replication znode dump", ke);
      }
      sb.append("\nQuorum Server Statistics:");
      String[] servers = zkWatcher.getQuorum().split(",");
      for (String server : servers) {
        sb.append("\n ").append(server);
        try {
          String[] stat = getServerStats(server, zkDumpConnectionTimeOut);

          if (stat == null) {
            sb.append("[Error] invalid quorum server: ").append(server);
            break;
          }

          for (String s : stat) {
            sb.append("\n  ").append(s);
          }
        } catch (Exception e) {
          sb.append("\n  ERROR: ").append(e.getMessage());
        }
      }
    } catch (KeeperException ke) {
      sb.append("\nFATAL ZooKeeper Exception!\n");
      sb.append("\n").append(ke.getMessage());
    }
    return sb.toString();
  }
Builds a string containing everything in ZooKeeper. This is inherently invasive into the
structures of other components' logical responsibilities.
hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKDump.java