protected static void waitMetaRegions(final MasterProcedureEnv env) throws IOException { int timeout = env.getMasterConfiguration().getInt("hbase.client.catalog.timeout", 10000); try { if (MetaTableLocator.waitMetaRegionLocation(env.getMasterServices().getZooKeeper(), timeout) == null) { throw new NotAllMetaRegionsOnlineException(); } } catch (InterruptedException e) { throw (InterruptedIOException) new InterruptedIOException().initCause(e); } }
/** * Waits indefinitely for availability of <code>.META.</code>. Used during * cluster startup. Does not verify meta, just that something has been * set up in zk. * @see #waitForMeta(long) * @throws InterruptedException if interrupted while waiting */ public void waitForMeta() throws InterruptedException { while (!this.stopped) { try { if (waitForMeta(100) != null) break; } catch (NotAllMetaRegionsOnlineException e) { if (LOG.isTraceEnabled()) { LOG.info(".META. still not available, sleeping and retrying." + " Reason: " + e.getMessage()); } } catch (IOException e) { LOG.info("Retrying", e); } } }
/** * Waits indefinitely for availability of <code>hbase:meta</code>. Used during * cluster startup. Does not verify meta, just that something has been * set up in zk. * @see #waitMetaRegionLocation(ZKWatcher, long) * @throws InterruptedException if interrupted while waiting */ public void waitMetaRegionLocation(ZKWatcher zkw) throws InterruptedException { long startTime = System.currentTimeMillis(); while (!stopped) { try { if (waitMetaRegionLocation(zkw, 100) != null) { break; } long sleepTime = System.currentTimeMillis() - startTime; // +1 in case sleepTime=0 if ((sleepTime + 1) % 10000 == 0) { LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms"); } } catch (NotAllMetaRegionsOnlineException e) { if (LOG.isTraceEnabled()) { LOG.trace("hbase:meta still not available, sleeping and retrying." + " Reason: " + e.getMessage()); } } } }
/** * 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 */ public 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; }
/** * Waits indefinitely for availability of <code>hbase:meta</code>. Used during * cluster startup. Does not verify meta, just that something has been * set up in zk. * @see #waitMetaRegionLocation(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher, long) * @throws InterruptedException if interrupted while waiting */ public void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws InterruptedException { Stopwatch stopwatch = new Stopwatch().start(); while (!stopped) { try { if (waitMetaRegionLocation(zkw, 100) != null) break; long sleepTime = stopwatch.elapsedMillis(); // +1 in case sleepTime=0 if ((sleepTime + 1) % 10000 == 0) { LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms"); } } catch (NotAllMetaRegionsOnlineException e) { if (LOG.isTraceEnabled()) { LOG.trace("hbase:meta still not available, sleeping and retrying." + " Reason: " + e.getMessage()); } } } }
/** * Gets the current location for <code>-ROOT-</code> if available and waits * for up to the specified timeout if not immediately available. Returns null * if the timeout elapses before root is available. * @param timeout maximum time to wait for root availability, in milliseconds * @return {@link ServerName} for server hosting <code>-ROOT-</code> or null * if none available * @throws InterruptedException if interrupted while waiting * @throws NotAllMetaRegionsOnlineException if root not available before * timeout */ ServerName waitForRoot(final long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException { ServerName sn = rootRegionTracker.waitRootRegionLocation(timeout); if (sn == null) { throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms"); } return sn; }
throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
protected static void waitMetaRegions(final MasterProcedureEnv env) throws IOException { int timeout = env.getMasterConfiguration().getInt("hbase.client.catalog.timeout", 10000); try { if (env.getMasterServices().getMetaTableLocator().waitMetaRegionLocation( env.getMasterServices().getZooKeeper(), timeout) == null) { throw new NotAllMetaRegionsOnlineException(); } } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException().initCause(e); } }
throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
if (server.getMetaTableLocator().waitMetaRegionLocation( server.getZooKeeper(), timeout) == null) { throw new NotAllMetaRegionsOnlineException();