org.apache.hadoop.hbase.HBaseTestingUtility.waitFor()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.hadoop.hbase.HBaseTestingUtility.waitFor()方法的一些代码示例,展示了HBaseTestingUtility.waitFor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HBaseTestingUtility.waitFor()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.HBaseTestingUtility
类名称:HBaseTestingUtility
方法名:waitFor

HBaseTestingUtility.waitFor介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

/**
 * 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);
  }
 });
}

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

/**
 * 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());
}

代码示例来源:origin: apache/hbase

/**
 * 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)));
}

代码示例来源:origin: apache/hbase

public void waitTableEnabled(TableName table, long timeoutMillis)
throws IOException {
 waitFor(timeoutMillis, predicateTableEnabled(table));
}

代码示例来源:origin: apache/hbase

public void waitTableDisabled(TableName table, long millisTimeout)
    throws InterruptedException, IOException {
 waitFor(millisTimeout, predicateTableDisabled(table));
}

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

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

代码示例来源:origin: apache/hbase

@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();
}

代码示例来源:origin: apache/hbase

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

相关文章

HBaseTestingUtility类方法