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

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

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

HBaseTestingUtility.waitUntilAllRegionsAssigned介绍

[英]Wait until all regions for a table in hbase:meta have a non-empty info:server, up to a configuable timeout value (default is 60 seconds) This means all regions have been deployed, master has been informed and updated hbase:meta with the regions deployed server.
[中]等待hbase:meta中的表的所有区域都有一个非空的info:server,最多可配置超时值(默认值为60秒)。这意味着所有区域都已部署,主机都已通知,并且已使用已部署的区域服务器更新hbase:meta。

代码示例

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

/**
 * Waith until all system table's regions get assigned
 * @throws IOException
 */
public void waitUntilAllSystemRegionsAssigned() throws IOException {
 waitUntilAllRegionsAssigned(TableName.META_TABLE_NAME);
}

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

/**
 * Wait until all regions for a table in hbase:meta have a non-empty
 * info:server, up to a configuable timeout value (default is 60 seconds)
 * This means all regions have been deployed,
 * master has been informed and updated hbase:meta with the regions deployed
 * server.
 * @param tableName the table name
 * @throws IOException
 */
public void waitUntilAllRegionsAssigned(final TableName tableName) throws IOException {
 waitUntilAllRegionsAssigned(tableName,
  this.conf.getLong("hbase.client.sync.wait.timeout.msec", 60000));
}

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

protected Table createTable(final TableName table, byte[] family) throws Exception {
 Table t = UTIL.createTable(table, family);
 // Wait for everything to be ready with the table
 UTIL.waitUntilAllRegionsAssigned(table);
 // At this point the table should be good to go.
 return t;
}

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

protected void createPreSplitLoadTestTable(HTableDescriptor htd, HColumnDescriptor hcd)
  throws IOException {
 HBaseTestingUtility.createPreSplitLoadTestTable(conf, htd, hcd);
 TEST_UTIL.waitUntilAllRegionsAssigned(htd.getTableName());
}

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

@BeforeClass
public static void setUpBeforeClass() throws Exception {
 try {
  createWithFavoredNode = DistributedFileSystem.class.getDeclaredMethod("create", Path.class,
   FsPermission.class, boolean.class, int.class, short.class, long.class,
   Progressable.class, InetSocketAddress[].class);
 } catch (NoSuchMethodException nm) {
  return;
 }
 TEST_UTIL.startMiniCluster(REGION_SERVERS);
 table = TEST_UTIL.createMultiRegionTable(TABLE_NAME, COLUMN_FAMILY);
 TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);
}

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

@BeforeClass
public static void setUpBeforeClass() throws Exception {
 TEST_UTIL.startMiniCluster(SLAVES);
 TEST_UTIL.createTable(TABLE_NAME, new byte[][] { FAMILY });
 TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);
}

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

@BeforeClass
public static void beforeClass() throws Exception {
 // Up the handlers; this test needs more than usual.
 UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
 UTIL.startMiniCluster();
 Table table =
   UTIL.createMultiRegionTable(MULTI_REGION_TABLE_NAME, new byte[][] { INPUT_FAMILY,
     OUTPUT_FAMILY });
 UTIL.loadTable(table, INPUT_FAMILY, false);
 UTIL.waitUntilAllRegionsAssigned(MULTI_REGION_TABLE_NAME);
}

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

@Before
public void setUp() throws Exception {
 Admin admin = TEST_UTIL.getAdmin();
 HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
 htd.setOwner(USER_OWNER);
 HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY1);
 hcd.setMaxVersions(10);
 htd.addFamily(hcd);
 hcd = new HColumnDescriptor(TEST_FAMILY2);
 hcd.setMaxVersions(10);
 htd.addFamily(hcd);
 // Enable backwards compatible early termination behavior in the HTD. We
 // want to confirm that the per-table configuration is properly picked up.
 htd.setConfiguration(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, "true");
 admin.createTable(htd);
 TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE.getTableName());
}

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

@Test
public void testCreateTable() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys);
 TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
 // All regions should have favored nodes
 checkIfFavoredNodeInformationIsCorrect(tableName);
 List<HRegionInfo> regions = admin.getTableRegions(tableName);
 TEST_UTIL.deleteTable(tableName);
 checkNoFNForDeletedTable(regions);
}

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

@BeforeClass
public static void setupBeforeClass() throws Exception {
 TEST_UTIL = new HBaseTestingUtility();
 conf = TEST_UTIL.getConfiguration();
 // Try to frequently clean up compacted files
 conf.setInt("hbase.hfile.compaction.discharger.interval", 1000);
 conf.setInt("hbase.master.hfilecleaner.ttl", 1000);
 TEST_UTIL.startMiniCluster(1);
 TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster();
 TEST_UTIL.waitUntilAllRegionsAssigned(TableName.META_TABLE_NAME);
 rootDir = FSUtils.getRootDir(conf);
 fs = TEST_UTIL.getTestFileSystem();
}

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

public static void createTable(HBaseTestingUtility testUtil, HTableDescriptor htd,
 byte [][] splitKeys) throws Exception {
 // NOTE: We need a latch because admin is not sync,
 // so the postOp coprocessor method may be called after the admin operation returned.
 MasterSyncCoprocessor coproc = testUtil.getHBaseCluster().getMaster()
   .getMasterCoprocessorHost().findCoprocessor(MasterSyncCoprocessor.class);
 coproc.tableCreationLatch = new CountDownLatch(1);
 if (splitKeys != null) {
  admin.createTable(htd, splitKeys);
 } else {
  admin.createTable(htd);
 }
 coproc.tableCreationLatch.await();
 coproc.tableCreationLatch = null;
 testUtil.waitUntilAllRegionsAssigned(htd.getTableName());
}

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

/**
 * Takes the snapshot of originalTable and clones the snapshot to another tables.
 * If {@code online} is false, the original table is disabled during taking snapshot, so also
 * enables it again.
 * @param online - Whether the table is online or not during the snapshot
 */
private void createAndCloneSnapshot(boolean online) throws Exception {
 SnapshotTestingUtils.createSnapshotAndValidate(admin, originalTableName, TEST_FAM_STR,
  snapshotNameAsString, rootDir, fs, online);
 // If offline, enable the table disabled by snapshot testing util.
 if (!online) {
  admin.enableTable(originalTableName);
  UTIL.waitTableAvailable(originalTableName);
 }
 admin.cloneSnapshot(snapshotName, cloneTableName);
 UTIL.waitUntilAllRegionsAssigned(cloneTableName);
}

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

@BeforeClass
public static void setUpBeforeClass() throws Exception {
 TEST_UTIL.startMiniCluster(1);
 TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster();
 TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME.META_TABLE_NAME);
 TEST_UTIL.createTable(TABLE_NAME, FAMILY);
}

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

public Table createTable(TableName tableName, byte[][] families,
  int numVersions, byte[] startKey, byte[] endKey, int numRegions)
throws IOException{
 HTableDescriptor desc = createTableDescriptor(tableName, families, numVersions);
 getAdmin().createTable(desc, startKey, endKey, numRegions);
 // HBaseAdmin only waits for regions to appear in hbase:meta we
 // should wait until they are assigned
 waitUntilAllRegionsAssigned(tableName);
 return getConnection().getTable(tableName);
}

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

public static void createTable(HBaseTestingUtility testUtil, Admin admin, TableDescriptor htd,
  byte[][] splitKeys) throws Exception {
 // NOTE: We need a latch because admin is not sync,
 // so the postOp coprocessor method may be called after the admin operation returned.
 MasterSyncObserver observer = testUtil.getHBaseCluster().getMaster()
  .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class);
 observer.tableCreationLatch = new CountDownLatch(1);
 if (splitKeys != null) {
  admin.createTable(htd, splitKeys);
 } else {
  admin.createTable(htd);
 }
 observer.tableCreationLatch.await();
 observer.tableCreationLatch = null;
 testUtil.waitUntilAllRegionsAssigned(htd.getTableName());
}

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

private static final void createTable(HTableDescriptor desc) throws Exception {
 Admin admin = TEST_UTIL.getAdmin();
 admin.createTable(desc, new byte[][]{ROWS[rowSeperator1], ROWS[rowSeperator2]});
 TEST_UTIL.waitUntilAllRegionsAssigned(desc.getTableName());
 Table table = TEST_UTIL.getConnection().getTable(desc.getTableName());
 try {
  for (int i = 0; i < ROWSIZE; i++) {
   Put put = new Put(ROWS[i]);
   put.addColumn(TEST_FAMILY, TEST_QUALIFIER, Bytes.toBytes(i));
   table.put(put);
  }
 } finally {
  table.close();
 }
}

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

@Test
public void testSystemTables() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys);
 TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
 // All regions should have favored nodes
 checkIfFavoredNodeInformationIsCorrect(tableName);
 for (TableName sysTable :
   admin.listTableNamesByNamespace(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR)) {
  List<HRegionInfo> regions = admin.getTableRegions(sysTable);
  for (HRegionInfo region : regions) {
   assertNull("FN should be null for sys region", fnm.getFavoredNodes(region));
  }
 }
 TEST_UTIL.deleteTable(tableName);
}

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

private void bulkLoadHFile(TableName tableName) throws Exception {
 try (Connection conn = ConnectionFactory.createConnection(conf);
   Admin admin = conn.getAdmin();
   RegionLocator locator = conn.getRegionLocator(tableName);
   Table table = conn.getTable(tableName)) {
  TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
  LoadIncrementalHFiles loader = new LoadIncrementalHFiles(conf);
  loader.doBulkLoad(loadPath, admin, table, locator);
 }
}

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

@Test
public void testTruncateTable() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys);
 TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
 // All regions should have favored nodes
 checkIfFavoredNodeInformationIsCorrect(tableName);
 List<HRegionInfo> regions = admin.getTableRegions(tableName);
 TEST_UTIL.truncateTable(tableName, true);
 checkNoFNForDeletedTable(regions);
 checkIfFavoredNodeInformationIsCorrect(tableName);
 regions = admin.getTableRegions(tableName);
 TEST_UTIL.truncateTable(tableName, false);
 checkNoFNForDeletedTable(regions);
 TEST_UTIL.deleteTable(tableName);
}

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

/**
 * Start up a mini cluster and put a small table of many empty regions into it.
 * @throws Exception
 */
@BeforeClass public static void beforeAllTests() throws Exception {
 TEST_UTIL.startMiniCluster(2);
 // Create a table of three families.  This will assign a region.
 TEST_UTIL.createMultiRegionTable(TABLENAME, FAMILIES);
 Table t = TEST_UTIL.getConnection().getTable(TABLENAME);
 int countOfRegions = -1;
 try (RegionLocator r = TEST_UTIL.getConnection().getRegionLocator(TABLENAME)) {
  countOfRegions = r.getStartKeys().length;
 }
 TEST_UTIL.waitUntilAllRegionsAssigned(TABLENAME);
 addToEachStartKey(countOfRegions);
 t.close();
}

相关文章

HBaseTestingUtility类方法