protected void waitForEnabled(String tableName) throws Exception { for (int i = 0; i < MAX_WAIT_ITERATION; i++) { if (admin.isTableEnabled(tableName)) { return; } Thread.sleep(WAIT_INTERVAL); } Assert.fail(getMethodName() + " failed"); }
protected static void validateTable(HBaseAdmin admin, String tableName) throws IOException, InterruptedException { if (tableName.equals(Args.ALL_TABLES)) return; boolean tableExists = admin.tableExists(tableName); if (tableExists) { if (!admin.isTableEnabled(tableName)) { throw new InvalidTableException("Table is not enabled."); } } else { throw new InvalidTableException("Table does not exist."); } }
public static void main(String args[]) throws MasterNotRunningException, IOException { // Instantiating configuration class Configuration conf = HBaseConfiguration.create(); // Instantiating HBaseAdmin class HBaseAdmin admin = new HBaseAdmin(conf); // Verifying weather the table is disabled Boolean bool = admin.isTableEnabled("emp"); System.out.println(bool); // Disabling the table using HBaseAdmin object if (!bool) { admin.enableTable("emp"); System.out.println("Table Enabled"); } }
private boolean check() throws DataExchangeException, IOException { if (!admin.isMasterRunning()) { throw new IllegalStateException("HBase master is not running!"); } if (!admin.tableExists(htable.getTableName())) { throw new IllegalStateException( "HBase table " + Bytes.toString(htable.getTableName()) + " is not existed!"); } if (!admin.isTableAvailable(htable.getTableName())) { throw new IllegalStateException( "HBase table " + Bytes.toString(htable.getTableName()) + " is not available!"); } if (!admin.isTableEnabled(htable.getTableName())) { throw new IllegalStateException( "HBase table " + Bytes.toString(htable.getTableName()) + " is disable!"); } return true; }