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;
}
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;
}
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);
}
}
Aggregations