private static void waitUntilZnodeAvailable(int replicaId) throws Exception {
    String znode = util.getZooKeeperWatcher().getZNodePaths().getZNodeForReplica(replicaId);
    int i = 0;
    while (i < 1000) {
      if (ZKUtil.checkExists(util.getZooKeeperWatcher(), znode) == -1) {
        Thread.sleep(100);
        i++;
      } else break;
    }
    if (i == 1000) throw new IOException("znode for meta replica " + replicaId + " not available");
  }
Util to get at the cluster.
hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestMetaReplicas.java