public static ServerName[] readZKNodes(Configuration conf) {
    List<ServerName> hosts = new LinkedList<>();
    String quorum = conf.get(HConstants.ZOOKEEPER_QUORUM, HConstants.LOCALHOST);

    String[] values = quorum.split(",");
    for (String value : values) {
      String[] parts = value.split(":");
      String host = parts[0];
      int port = HConstants.DEFAULT_ZOOKEEPER_CLIENT_PORT;
      if (parts.length > 1) {
        port = Integer.parseInt(parts[1]);
      }
      hosts.add(ServerName.valueOf(host, port, -1));
    }
    return hosts.toArray(new ServerName[hosts.size()]);
  }
Tool for reading ZooKeeper servers from HBase XML configuration and producing a line-by-line list
for use by bash scripts.
hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKServerTool.java