Search in sources :

Example 1 with NotAllMetaRegionsOnlineException

use of org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException in project hbase by apache.

the class MetaTableLocator method waitMetaRegionLocation.

/**
 * 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
 */
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;
}
Also used : NotAllMetaRegionsOnlineException(org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException) ServerName(org.apache.hadoop.hbase.ServerName) KeeperException(org.apache.zookeeper.KeeperException)

Example 2 with NotAllMetaRegionsOnlineException

use of org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException in project hbase by apache.

the class MetaTableLocator method waitMetaRegionLocation.

/**
   * 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
   * @param replicaId
   * @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
   * @throws NotAllMetaRegionsOnlineException
   */
public ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, int replicaId, long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException {
    try {
        if (ZKUtil.checkExists(zkw, zkw.znodePaths.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;
}
Also used : NotAllMetaRegionsOnlineException(org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException) ServerName(org.apache.hadoop.hbase.ServerName) KeeperException(org.apache.zookeeper.KeeperException)

Example 3 with NotAllMetaRegionsOnlineException

use of org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException in project hbase by apache.

the class ProcedureSyncWait method waitMetaRegions.

protected static void waitMetaRegions(final MasterProcedureEnv env) throws IOException {
    int timeout = env.getMasterConfiguration().getInt("hbase.client.catalog.timeout", 10000);
    try {
        long start = EnvironmentEdgeManager.currentTime();
        for (; ; ) {
            RegionStateNode rsn = env.getAssignmentManager().getRegionStates().getRegionStateNode(RegionInfoBuilder.FIRST_META_REGIONINFO);
            if (rsn != null && rsn.isInState(RegionState.State.OPEN)) {
                return;
            }
            if (EnvironmentEdgeManager.currentTime() - start >= timeout) {
                throw new NotAllMetaRegionsOnlineException();
            }
            Thread.sleep(HConstants.SOCKET_RETRY_WAIT_MS);
        }
    } catch (InterruptedException e) {
        throw (InterruptedIOException) new InterruptedIOException().initCause(e);
    }
}
Also used : NotAllMetaRegionsOnlineException(org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException) InterruptedIOException(java.io.InterruptedIOException) RegionStateNode(org.apache.hadoop.hbase.master.assignment.RegionStateNode)

Aggregations

NotAllMetaRegionsOnlineException (org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException)3 ServerName (org.apache.hadoop.hbase.ServerName)2 KeeperException (org.apache.zookeeper.KeeperException)2 InterruptedIOException (java.io.InterruptedIOException)1 RegionStateNode (org.apache.hadoop.hbase.master.assignment.RegionStateNode)1