Java Code Examples for org.apache.hadoop.hbase.client.Admin#isTableDisabled()

The following examples show how to use org.apache.hadoop.hbase.client.Admin#isTableDisabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OmidTestBase.java    From phoenix-omid with Apache License 2.0 5 votes vote down vote up
void deleteTable(Admin admin, TableName tableName) throws IOException {
    if (admin.tableExists(tableName)) {
        if (admin.isTableDisabled(tableName)) {
            admin.deleteTable(tableName);
        } else {
            admin.disableTable(tableName);
            admin.deleteTable(tableName);
        }
    }
}
 
Example 2
Source File: TestHBaseCommitTable.java    From phoenix-omid with Apache License 2.0 5 votes vote down vote up
@BeforeMethod
public void setUp() throws Exception {
    Admin admin = testutil.getHBaseAdmin();

    if (!admin.tableExists(TableName.valueOf(TEST_TABLE))) {
        HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);

        HColumnDescriptor datafam = new HColumnDescriptor(commitTableFamily);
        datafam.setMaxVersions(Integer.MAX_VALUE);
        desc.addFamily(datafam);

        HColumnDescriptor lowWatermarkFam = new HColumnDescriptor(lowWatermarkFamily);
        lowWatermarkFam.setMaxVersions(Integer.MAX_VALUE);
        desc.addFamily(lowWatermarkFam);

        // Move to HBaseSims for 2.0 support
        // For 2.0, use TableDescriptorBuilder to build TableDescriptor
        admin.createTable(desc);
    }

    if (admin.isTableDisabled(TableName.valueOf(TEST_TABLE))) {
        admin.enableTable(TableName.valueOf(TEST_TABLE));
    }
    HTableDescriptor[] tables = admin.listTables();
    for (HTableDescriptor t : tables) {
        LOG.info(t.getNameAsString());
    }
}
 
Example 3
Source File: TestBackupSystemTable.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void cleanBackupTable() throws IOException {
  Admin admin = UTIL.getAdmin();
  admin.disableTable(BackupSystemTable.getTableName(conf));
  admin.truncateTable(BackupSystemTable.getTableName(conf), true);
  if (admin.isTableDisabled(BackupSystemTable.getTableName(conf))) {
    admin.enableTable(BackupSystemTable.getTableName(conf));
  }
}
 
Example 4
Source File: HBaseTestingUtility.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Truncate a table using the admin command.
 * Effectively disables, deletes, and recreates the table.
 * @param tableName table which must exist.
 * @param preserveRegions keep the existing split points
 * @return HTable for the new table
 */
public Table truncateTable(final TableName tableName, final boolean preserveRegions) throws
    IOException {
  Admin admin = getAdmin();
  if (!admin.isTableDisabled(tableName)) {
    admin.disableTable(tableName);
  }
  admin.truncateTable(tableName, preserveRegions);
  return getConnection().getTable(tableName);
}
 
Example 5
Source File: HBaseOperations.java    From geowave with Apache License 2.0 5 votes vote down vote up
private void disableTable(final Admin admin, final TableName tableName) throws IOException {
  admin.disableTableAsync(tableName);
  while (!admin.isTableDisabled(tableName)) {
    try {
      Thread.sleep(10);
    } catch (final InterruptedException e) {
      // Do nothing
    }
  }
}