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

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

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

HBaseTestingUtility.waitUntilNoRegionsInTransition介绍

[英]Wait until no regions in transition. (time limit 15min)
[中]等待,直到没有区域处于过渡状态。(时限15分钟)

代码示例

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

/**
 * Wait until no regions in transition. (time limit 15min)
 * @throws IOException
 */
public void waitUntilNoRegionsInTransition() throws IOException {
 waitUntilNoRegionsInTransition(15 * 60000);
}

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

private void blockUntilNoRIT(ZKWatcher zkw, HMaster master) throws Exception {
 TEST_UTIL.waitUntilNoRegionsInTransition(60000);
}

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

private List<HRegionInfo> assertRegionCount(final TableName tableName, final int nregions)
   throws Exception {
  UTIL.waitUntilNoRegionsInTransition();
  List<HRegionInfo> tableRegions = admin.getTableRegions(tableName);
  assertEquals(nregions, tableRegions.size());
  return tableRegions;
 }
}

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

public List<RegionInfo> assertRegionCount(final TableName tableName, final int nregions)
  throws Exception {
 UTIL.waitUntilNoRegionsInTransition();
 List<RegionInfo> tableRegions = admin.getRegions(tableName);
 assertEquals(nregions, tableRegions.size());
 return tableRegions;
}

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

/**
 * Wait until all the regions are assigned.
 */
private void waitForAllRegionsAssigned() throws IOException {
 int totalRegions = HBaseTestingUtility.KEYS.length;
 try {
   Thread.sleep(200);
 } catch (InterruptedException e) {
  throw new InterruptedIOException();
 }
 while (UTIL.getMiniHBaseCluster().countServedRegions() < totalRegions) {
 // while (!cluster.getMaster().allRegionsAssigned()) {
  LOG.debug("Waiting for there to be "+ totalRegions +" regions, but there are "
   + UTIL.getMiniHBaseCluster().countServedRegions() + " right now.");
  try {
   Thread.sleep(200);
  } catch (InterruptedException e) {
   throw new InterruptedIOException();
  }
 }
 UTIL.waitUntilNoRegionsInTransition();
}

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

@BeforeClass
public static void setupCluster() throws Exception {
 Configuration conf = UTIL.getConfiguration();
 setupConf(UTIL.getConfiguration());
 UTIL.startMiniDFSCluster(3);
 CommonFSUtils.setWALRootDir(conf, new Path(conf.get("fs.defaultFS"), "/tmp/wal"));
 UTIL.startMiniCluster(2);
 UTIL.waitUntilNoRegionsInTransition();
}

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

@Test
public void test2FavoredNodesDead() throws Exception {
 TableName tableName = TableName.valueOf("testAllFavoredNodesDead");
 HTableDescriptor desc = new HTableDescriptor(tableName);
 desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
 admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM);
 TEST_UTIL.waitTableAvailable(tableName);
 final RegionInfo region = admin.getTableRegions(tableName).get(0);
 LOG.info("Region that's supposed to be in transition: " + region);
 FavoredNodesManager fnm = master.getFavoredNodesManager();
 List<ServerName> currentFN = fnm.getFavoredNodes(region);
 assertNotNull(currentFN);
 List<ServerName> serversToStop = Lists.newArrayList(currentFN);
 serversToStop.remove(currentFN.get(0));
 // Lets kill 2 FN for the region. All regions should still be assigned
 stopServersAndWaitUntilProcessed(serversToStop);
 TEST_UTIL.waitUntilNoRegionsInTransition();
 final RegionStates regionStates = master.getAssignmentManager().getRegionStates();
 TEST_UTIL.waitFor(10000, new Waiter.Predicate<Exception>() {
  @Override
  public boolean evaluate() throws Exception {
   return regionStates.getRegionState(region).isOpened();
  }
 });
 assertEquals("Not all regions are online", REGION_NUM, admin.getTableRegions(tableName).size());
 admin.setBalancerRunning(true, true);
 assertTrue("Balancer did not run", admin.balancer());
 TEST_UTIL.waitUntilNoRegionsInTransition(60000);
 checkFavoredNodeAssignments(tableName, fnm, regionStates);
}

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

htd.addFamily(new HColumnDescriptor(FAMILYNAME));
admin.createTable(htd);
HTU.waitUntilNoRegionsInTransition(60000);

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

@Test
public void testBalancerWithoutFavoredNodes() throws Exception {
 TableName tableName = TableName.valueOf("testBalancerWithoutFavoredNodes");
 HTableDescriptor desc = new HTableDescriptor(tableName);
 desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
 admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM);
 TEST_UTIL.waitTableAvailable(tableName);
 final RegionInfo region = admin.getTableRegions(tableName).get(0);
 LOG.info("Region thats supposed to be in transition: " + region);
 FavoredNodesManager fnm = master.getFavoredNodesManager();
 List<ServerName> currentFN = fnm.getFavoredNodes(region);
 assertNotNull(currentFN);
 fnm.deleteFavoredNodesForRegions(Lists.newArrayList(region));
 RegionStates regionStates = master.getAssignmentManager().getRegionStates();
 admin.setBalancerRunning(true, true);
 // Balancer should unassign the region
 assertTrue("Balancer did not run", admin.balancer());
 TEST_UTIL.waitUntilNoRegionsInTransition();
 admin.assign(region.getEncodedNameAsBytes());
 TEST_UTIL.waitUntilNoRegionsInTransition(60000);
 currentFN = fnm.getFavoredNodes(region);
 assertNotNull(currentFN);
 assertEquals("Expected number of FN not present",
  FavoredNodeAssignmentHelper.FAVORED_NODES_NUM, currentFN.size());
 assertTrue("Balancer did not run", admin.balancer());
 TEST_UTIL.waitUntilNoRegionsInTransition(60000);
 checkFavoredNodeAssignments(tableName, fnm, regionStates);
}

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

@BeforeClass
public static void setUp() throws Exception {
 UTIL.getConfiguration().setLong(ProcedureExecutor.WORKER_KEEP_ALIVE_TIME_CONF_KEY, 5000);
 UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 4);
 UTIL.getConfiguration().set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, MyCP.class.getName());
 UTIL.startMiniCluster(3);
 CORE_POOL_SIZE =
  UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getCorePoolSize();
 TABLE_COUNT = 50 * CORE_POOL_SIZE;
 List<Future<?>> futures = new ArrayList<>();
 for (int i = 0; i < TABLE_COUNT; i++) {
  futures.add(UTIL.getAdmin().createTableAsync(
   TableDescriptorBuilder.newBuilder(TableName.valueOf(TABLE_NAME_PREFIX + i))
    .setColumnFamily(ColumnFamilyDescriptorBuilder.of(CF)).build(),
   null));
 }
 for (Future<?> future : futures) {
  future.get(1, TimeUnit.MINUTES);
 }
 UTIL.getAdmin().balance(true);
 UTIL.waitUntilNoRegionsInTransition();
}

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

private void setEncodingConf(DataBlockEncoding encoding,
  boolean onlineChange) throws Exception {
 LOG.debug("Setting CF encoding to " + encoding + " (ordinal="
  + encoding.ordinal() + "), onlineChange=" + onlineChange);
 hcd.setDataBlockEncoding(encoding);
 try (Admin admin = TEST_UTIL.getConnection().getAdmin()) {
  if (!onlineChange) {
   admin.disableTable(tableName);
  }
  admin.modifyColumnFamily(tableName, hcd);
  if (!onlineChange) {
   admin.enableTable(tableName);
  }
 }
 // This is a unit test, not integration test. So let's
 // wait for regions out of transition. Otherwise, for online
 // encoding change, verification phase may be flaky because
 // regions could be still in transition.
 TEST_UTIL.waitUntilNoRegionsInTransition(TIMEOUT_MS);
}

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

@Test
public void testFlushedSequenceIdPersistLoad() throws Exception {
 Configuration conf = TEST_UTIL.getConfiguration();
 int msgInterval = conf.getInt("hbase.regionserver.msginterval", 100);
 // insert some data into META
 TableName tableName = TableName.valueOf("testFlushSeqId");
 HTableDescriptor desc = new HTableDescriptor(tableName);
 desc.addFamily(new HColumnDescriptor(Bytes.toBytes("cf")));
 Table table = TEST_UTIL.createTable(desc, null);
 // flush META region
 TEST_UTIL.flush(TableName.META_TABLE_NAME);
 // wait for regionserver report
 Threads.sleep(msgInterval * 2);
 // record flush seqid before cluster shutdown
 Map<byte[], Long> regionMapBefore =
   TEST_UTIL.getHBaseCluster().getMaster().getServerManager()
     .getFlushedSequenceIdByRegion();
 // restart hbase cluster which will cause flushed sequence id persist and reload
 TEST_UTIL.getMiniHBaseCluster().shutdown();
 TEST_UTIL.restartHBaseCluster(2);
 TEST_UTIL.waitUntilNoRegionsInTransition();
 // check equality after reloading flushed sequence id map
 Map<byte[], Long> regionMapAfter =
   TEST_UTIL.getHBaseCluster().getMaster().getServerManager()
     .getFlushedSequenceIdByRegion();
 assertTrue(regionMapBefore.equals(regionMapAfter));
}

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

admin.createTable(htd, SPLIT_KEYS);
TEST_UTIL.waitUntilNoRegionsInTransition(60000);
HMaster m = cluster.getMaster();
try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {

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

@Before
public void setup() throws IOException, InterruptedException {
 // Create a table of three families. This will assign a region.
 TEST_UTIL.createTable(TABLENAME, FAMILIES);
 Table t = TEST_UTIL.getConnection().getTable(TABLENAME);
 TEST_UTIL.waitUntilNoRegionsInTransition();
 // Load the table with data for all families
 TEST_UTIL.loadTable(t, FAMILIES);
 TEST_UTIL.flush();
 t.close();
 TEST_UTIL.ensureSomeRegionServersAvailable(2);
}

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

private void testCrashRsWithMetaRegion(final boolean kill) throws Exception {
 int nkilled = 0;
 for (RegionInfo hri: AssignmentTestingUtil.getMetaRegions(UTIL)) {
  ServerName serverName = AssignmentTestingUtil.crashRsWithRegion(UTIL, hri, kill);
  // wait for region to enter in transition and then to get out of transition
  AssignmentTestingUtil.waitForRegionToBeInTransition(UTIL, hri);
  UTIL.waitUntilNoRegionsInTransition();
  testGet(hri, 10);
  // region should be moved to another RS
  assertNotEquals(serverName, AssignmentTestingUtil.getServerHoldingRegion(UTIL, hri));
  if (++nkilled == (NUM_RS - 1)) {
   break;
  }
 }
 assertTrue("expected RSs to be killed", nkilled > 0);
}

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

UTIL.getMiniHBaseCluster().getRegionServer(0).getServerName());
UTIL.getMiniHBaseCluster().startRegionServer();
UTIL.waitUntilNoRegionsInTransition();
Scan scan = new Scan();
ResultScanner results = TABLE.getScanner(scan);

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

UTIL.getMiniHBaseCluster().getRegionServer(0).getServerName());
UTIL.getMiniHBaseCluster().startRegionServer();
UTIL.waitUntilNoRegionsInTransition();
Scan scan = new Scan();
ResultScanner results = TABLE.getScanner(scan);

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

@Test
public void testBasicBalance() throws Exception {
 TableName tableName = TableName.valueOf("testBasicBalance");
 HTableDescriptor desc = new HTableDescriptor(tableName);
 desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
 admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM);
 TEST_UTIL.waitTableAvailable(tableName);
 TEST_UTIL.loadTable(admin.getConnection().getTable(tableName), HConstants.CATALOG_FAMILY);
 admin.flush(tableName);
 compactTable(tableName);
 JVMClusterUtil.RegionServerThread rs1 = cluster.startRegionServerAndWait(10000);
 JVMClusterUtil.RegionServerThread rs2 = cluster.startRegionServerAndWait(10000);
 // Now try to run balance, and verify no regions are moved to the 2 region servers recently
 // started.
 admin.setBalancerRunning(true, true);
 assertTrue("Balancer did not run", admin.balancer());
 TEST_UTIL.waitUntilNoRegionsInTransition(120000);
 List<RegionInfo> hris = admin.getRegions(rs1.getRegionServer().getServerName());
 for (RegionInfo hri : hris) {
  assertFalse("New RS contains regions belonging to table: " + tableName,
   hri.getTable().equals(tableName));
 }
 hris = admin.getRegions(rs2.getRegionServer().getServerName());
 for (RegionInfo hri : hris) {
  assertFalse("New RS contains regions belonging to table: " + tableName,
   hri.getTable().equals(tableName));
 }
}

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

regionB.getEncodedNameAsBytes(), false).get(60, TimeUnit.SECONDS);
TEST_UTIL.waitUntilNoRegionsInTransition(WAIT_TIMEOUT);
waitUntilTableRegionCountReached(tableName, countOfRegions - 1);

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

private void testCrashRsWithUserRegion(final boolean kill, final boolean withData)
  throws Exception {
 final int NROWS = 100;
 int nkilled = 0;
 for (RegionInfo hri: UTIL.getHBaseAdmin().getTableRegions(TEST_TABLE)) {
  ServerName serverName = AssignmentTestingUtil.getServerHoldingRegion(UTIL, hri);
  if (AssignmentTestingUtil.isServerHoldingMeta(UTIL, serverName)) continue;
  if (withData) {
   testInsert(hri, NROWS);
  }
  // wait for regions to enter in transition and then to get out of transition
  AssignmentTestingUtil.crashRs(UTIL, serverName, kill);
  AssignmentTestingUtil.waitForRegionToBeInTransition(UTIL, hri);
  UTIL.waitUntilNoRegionsInTransition();
  if (withData) {
   assertEquals(NROWS, testGet(hri, NROWS));
  }
  // region should be moved to another RS
  assertNotEquals(serverName, AssignmentTestingUtil.getServerHoldingRegion(UTIL, hri));
  if (++nkilled == (NUM_RS - 1)) {
   break;
  }
 }
 assertTrue("expected RSs to be killed", nkilled > 0);
}

相关文章

HBaseTestingUtility类方法