private void waitUntilTableRegionCountReached(final TableName tableName, final int numRegions) throws Exception { TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return MetaTableAccessor.getRegionCount(TEST_UTIL.getConfiguration(), tableName) == numRegions; } }); } }
/** * Waits {@code timeout} milliseconds for the HBase quota table to exist. */ public void waitForQuotaTable(Connection conn, long timeout) throws IOException { testUtil.waitFor(timeout, 1000, new Predicate<IOException>() { @Override public boolean evaluate() throws IOException { return conn.getAdmin().tableExists(QuotaUtil.QUOTA_TABLE_NAME); } }); }
private void waitForTune(final MemstoreFlusherStub memStoreFlusher, final long oldMemstoreHeapSize) throws Exception { // Allow the tuner to run once and do necessary memory up UTIL.waitFor(10000, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return oldMemstoreHeapSize != memStoreFlusher.memstoreSize; } }); }
public static void waitForRsToBeDead(final HBaseTestingUtility util, final ServerName serverName) throws Exception { util.waitFor(60000, new ExplainingPredicate<Exception>() { @Override public boolean evaluate() { return getMaster(util).getServerManager().isServerDead(serverName); } @Override public String explainFailure() { return "Server " + serverName + " is not dead"; } }); }
public static void waitForQuotaInitialize(final HBaseTestingUtility util) throws Exception { util.waitFor(60000, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { HMaster master = util.getHBaseCluster().getMaster(); if (master == null) { return false; } MasterQuotaManager quotaManager = master.getMasterQuotaManager(); return quotaManager != null && quotaManager.isQuotaInitialized(); } }); }
/** * Wait until no regions in transition. * @param timeout How long to wait. * @throws IOException */ public void waitUntilNoRegionsInTransition(final long timeout) throws IOException { waitFor(timeout, predicateNoRegionsInTransition()); }
/** * Wait until all regions in a table have been assigned * @param table Table to wait on. * @param timeoutMillis Timeout. * @throws InterruptedException * @throws IOException */ public void waitTableAvailable(byte[] table, long timeoutMillis) throws InterruptedException, IOException { waitFor(timeoutMillis, predicateTableAvailable(TableName.valueOf(table))); }
public void waitTableEnabled(TableName table, long timeoutMillis) throws IOException { waitFor(timeoutMillis, predicateTableEnabled(table)); }
public void waitTableDisabled(TableName table, long millisTimeout) throws InterruptedException, IOException { waitFor(millisTimeout, predicateTableDisabled(table)); }
private void startWaitAliveThenWaitItLives(final Thread t, final int ms) { t.start(); UTIL.waitFor(2000, t::isAlive); // Wait one second. Threads.sleep(ms); assertTrue("Assert " + t.getName() + " still waiting", t.isAlive()); }
private void assertBackoffIncrease() throws IOException, InterruptedException { ProcedureTestUtil.waitUntilProcedureWaitingTimeout(UTIL, TestTransitPeerSyncReplicationStateProcedure.class, 30000); ProcedureTestUtil.waitUntilProcedureTimeoutIncrease(UTIL, TestTransitPeerSyncReplicationStateProcedure.class, 2); synchronized (TestTransitPeerSyncReplicationStateProcedure.class) { FAIL = false; } UTIL.waitFor(30000, () -> FAIL); }
private void assertBackoffIncrease() throws IOException, InterruptedException { ProcedureTestUtil.waitUntilProcedureWaitingTimeout(UTIL, TestModifyPeerProcedure.class, 30000); ProcedureTestUtil.waitUntilProcedureTimeoutIncrease(UTIL, TestModifyPeerProcedure.class, 2); synchronized (TestModifyPeerProcedureRetryBackoff.class) { FAIL = false; } UTIL.waitFor(30000, () -> FAIL); }
private void waitForCounter(final Expr e, final long oldval, long newval, long timems) throws Exception { TEST_UTIL.waitFor(timems, 10, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return (e.eval() != oldval); } }); assertEquals(newval, e.eval()); }
@Test public void testCreateAndDrop() throws Exception { TEST_UTIL.createTable(tableName, Bytes.toBytes("cf")); // wait for created table to be assigned TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return getTableRegionMap().get(tableName) != null; } }); TEST_UTIL.deleteTable(tableName); }
public static void waitUntilProcedureWaitingTimeout(HBaseTestingUtility util, Class<? extends Procedure<?>> clazz, long timeout) throws IOException { JsonParser parser = new JsonParser(); util.waitFor(timeout, () -> getProcedure(util, clazz, parser) .filter(o -> ProcedureState.WAITING_TIMEOUT.name().equals(o.get("state").getAsString())) .isPresent()); }
protected final void waitUntilDeleted(HBaseTestingUtility util, Path remoteWAL) throws Exception { MasterFileSystem mfs = util.getMiniHBaseCluster().getMaster().getMasterFileSystem(); util.waitFor(30000, new ExplainingPredicate<Exception>() { @Override public boolean evaluate() throws Exception { return !mfs.getWALFileSystem().exists(remoteWAL); } @Override public String explainFailure() throws Exception { return remoteWAL + " has not been deleted yet"; } }); } }
public static void waitForTableToBeOnline(final HBaseTestingUtility util, final TableName tableName) throws IOException, InterruptedException { HRegionServer rs = util.getRSForFirstRegionInTable(tableName); List<HRegion> onlineRegions = rs.getRegions(tableName); for (HRegion region : onlineRegions) { region.waitForFlushesAndCompactions(); } // Wait up to 60 seconds for a table to be available. util.waitFor(60000, util.predicateTableAvailable(tableName)); }
private void waitUntilHasLastPushedSequenceId(RegionInfo region) throws Exception { ReplicationQueueStorage queueStorage = UTIL.getMiniHBaseCluster().getMaster().getReplicationPeerManager().getQueueStorage(); UTIL.waitFor(30000, new ExplainingPredicate<Exception>() { @Override public boolean evaluate() throws Exception { return queueStorage.getLastSequenceId(region.getEncodedName(), PEER_ID) > 0; } @Override public String explainFailure() throws Exception { return "Still no last pushed sequence id for " + region; } }); }
@AfterClass public static void tearDown() throws Exception { // Wait the SCP of abort rs to finish UTIL.waitFor(30000, () -> UTIL.getMiniHBaseCluster().getMaster().getProcedures().stream() .filter(p -> p instanceof ServerCrashProcedure && p.isFinished()).count() > 0); UTIL.getAdmin().disableTable(TABLE_NAME); UTIL.getAdmin().deleteTable(TABLE_NAME); UTIL.shutdownMiniCluster(); }
protected static void waitUntilAllReplicasHaveRow(byte[] row) throws IOException { // this is the fastest way to let all replicas have the row TEST_UTIL.getAdmin().disableTable(TABLE_NAME); TEST_UTIL.getAdmin().enableTable(TABLE_NAME); TEST_UTIL.waitFor(30000, () -> allReplicasHaveRow(row)); }