private static ServerName waitMetaRegionLocation(ZKWatcher zkw, int replicaId, long timeout)
    throws InterruptedException, NotAllMetaRegionsOnlineException {
    try {
      if (ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode) == -1) {
        String errorMsg = "Check the value configured in 'zookeeper.znode.parent'. "
          + "There could be a mismatch with the one configured in the master.";
        LOG.error(errorMsg);
        throw new IllegalArgumentException(errorMsg);
      }
    } catch (KeeperException e) {
      throw new IllegalStateException("KeeperException while trying to check baseZNode:", e);
    }
    ServerName sn = blockUntilAvailable(zkw, replicaId, timeout);

    if (sn == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
    }

    return sn;
  }
Gets the meta region location, if available, and waits for up to the specified timeout if not
immediately available. Given the zookeeper notification could be delayed, we will try to get
the latest data.
@param zkw       reference to the {@link ZKWatcher} which also contains configuration and
                 operation
@param replicaId the ID of the replica
@param timeout   maximum time to wait, in millis
@return server name for server hosting meta region formatted as per {@link ServerName}, or null
        if none available
@throws InterruptedException             if waiting for the socket operation fails
@throws NotAllMetaRegionsOnlineException if a meta or root region is not online
hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java