public static boolean isAccessControllerRunning(Connection connection) throws MasterNotRunningException, ZooKeeperConnectionException, IOException { try (Admin admin = connection.getAdmin()) { return admin.isTableAvailable(ACL_TABLE_NAME); } }
void modifyTableSync(Connection conn, TableDescriptor desc) throws IOException { try (Admin admin = conn.getAdmin()) { admin.modifyTable(desc); int attempt = 0; int maxAttempts = 600; while (!admin.isTableAvailable(desc.getTableName())) { Thread.sleep(100); attempt++; if (attempt++ > maxAttempts) { throw new IOException("Timeout expired " + (maxAttempts * 100) + "ms"); } } } catch (Exception e) { throw new IOException(e); } }
private void waitForSystemTable(Admin admin, TableName tableName) throws IOException { // Return fast if the table is available and avoid a log message if (admin.tableExists(tableName) && admin.isTableAvailable(tableName)) { return; } long TIMEOUT = 60000; long startTime = EnvironmentEdgeManager.currentTime(); LOG.debug("Backup table {} is not present and available, waiting for it to become so", tableName); while (!admin.tableExists(tableName) || !admin.isTableAvailable(tableName)) { try { Thread.sleep(100); } catch (InterruptedException e) { } if (EnvironmentEdgeManager.currentTime() - startTime > TIMEOUT) { throw new IOException( "Failed to create backup system table " + tableName + " after " + TIMEOUT + "ms"); } } LOG.debug("Backup table {} exists and available", tableName); }
@Override public boolean evaluate() throws IOException { return admin.isTableAvailable(getTablename()); } });
@Override public boolean isTableAvailable(TTableName tableName) throws TIOError, TException { try { TableName table = tableNameFromThrift(tableName); return connectionCache.getAdmin().isTableAvailable(table); } catch (IOException e) { throw getTIOError(e); } }
@Override public boolean isTableAvailableWithSplit(TTableName tableName, List<ByteBuffer> splitKeys) throws TIOError, TException { try { TableName table = tableNameFromThrift(tableName); byte[][] split = splitKeyFromThrift(splitKeys); return connectionCache.getAdmin().isTableAvailable(table, split); } catch (IOException e) { throw getTIOError(e); } }
/** create a HTable that has the same performance settings as normal cube table, for benchmark purpose */ public static void createBenchmarkHTable(TableName tableName, String cfName) throws IOException { Admin admin = HBaseConnection.get(KylinConfig.getInstanceFromEnv().getStorageUrl()).getAdmin(); try { if (admin.tableExists(tableName)) { logger.info("disabling hbase table " + tableName); admin.disableTable(tableName); logger.info("deleting hbase table " + tableName); admin.deleteTable(tableName); } HTableDescriptor tableDesc = new HTableDescriptor(tableName); tableDesc.setValue(HTableDescriptor.SPLIT_POLICY, DisabledRegionSplitPolicy.class.getName()); KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv(); tableDesc.addFamily(createColumnFamily(kylinConfig, cfName, false)); logger.info("creating hbase table " + tableName); admin.createTable(tableDesc, null); Preconditions.checkArgument(admin.isTableAvailable(tableName), "table " + tableName + " created, but is not available due to some reasons"); logger.info("create hbase table " + tableName + " done."); } finally { IOUtils.closeQuietly(admin); } }
while (!admin.isTableAvailable(targetTableName)) { try { Thread.sleep(100);
RegionLocator regionLocator, boolean silence, boolean copyFile) throws TableNotFoundException, IOException { if (!admin.isTableAvailable(regionLocator.getName())) { throw new TableNotFoundException("Table " + table.getName() + " is not currently available.");
@Test public void testTableAvailableWithRandomSplitKeys() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor("col")); byte[][] splitKeys = new byte[1][]; splitKeys = new byte [][] { new byte [] { 1, 1, 1 }, new byte [] { 2, 2, 2 } }; admin.createTable(desc); boolean tableAvailable = admin.isTableAvailable(tableName, splitKeys); assertFalse("Table should be created with 1 row in META", tableAvailable); }
Table table, RegionLocator regionLocator, boolean silence, boolean copyFile) throws TableNotFoundException, IOException { if (!admin.isTableAvailable(regionLocator.getName())) { throw new TableNotFoundException("Table " + table.getName() + " is not currently available.");
Preconditions.checkArgument(admin.isTableAvailable(TableName.valueOf(tableName)), "table " + tableName + " created, but is not available due to some reasons"); logger.info("create hbase table " + tableName + " done."); } finally {
assertTrue(admin.isTableAvailable(TABLENAME));
final TableName tableName = TableName.valueOf(name.getMethodName()); String peerId = "2"; if (admin2.isTableAvailable(TestReplicationBase.tableName)) { admin2.disableTable(TestReplicationBase.tableName); admin2.deleteTable(TestReplicationBase.tableName); admin2.isTableAvailable(TestReplicationBase.tableName)); assertFalse("Table should not be created if user has set table cfs explicitly for the " + "peer and this is not part of that collection", admin2.isTableAvailable(TestReplicationBase.tableName)); assertTrue( "Table should be created if user has explicitly added table into table cfs collection", admin2.isTableAvailable(TestReplicationBase.tableName)); } finally { adminExt.removePeerTableCFs(peerId, adminExt.getPeerTableCFs(peerId));
assertTrue(admin.isTableAvailable(TABLENAME));
hbaseAdmin.createTable(desc); assertTrue(hbaseAdmin.isTableAvailable(tableName));
!admin.isTableAvailable(table.getName())) { Thread.sleep(200); LOG.info("Waiting for new region assignment to happen");
admin.isTableAvailable(tableName, splitKeys)); assertEquals(NUM_REGIONS, TEST_UTIL.getHBaseCluster().getRegions(newTableName).size()); assertTrue("New table should be created with splitKyes + 1 rows in META", admin.isTableAvailable(newTableName, splitKeys)); } else { assertEquals(1, TEST_UTIL.getHBaseCluster().getRegions(newTableName).size());
@Override public boolean evaluate() throws IOException { boolean tableAvailable = getAdmin().isTableAvailable(tableName); if (tableAvailable) { try (Table table = getConnection().getTable(tableName)) { TableDescriptor htd = table.getDescriptor(); for (HRegionLocation loc : getConnection().getRegionLocator(tableName) .getAllRegionLocations()) { Scan scan = new Scan().withStartRow(loc.getRegionInfo().getStartKey()) .withStopRow(loc.getRegionInfo().getEndKey()).setOneRowLimit() .setMaxResultsPerColumnFamily(1).setCacheBlocks(false); for (byte[] family : htd.getColumnFamilyNames()) { scan.addFamily(family); } try (ResultScanner scanner = table.getScanner(scan)) { scanner.next(); } } } } return tableAvailable; } };
assertTrue(admin.isTableAvailable(tableDescriptor.getTableName())); assertTrue(admin.isTableAvailable(tableDescriptor.getTableName()));