Example #1
0
 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");
 }
Example #2
0
  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.");
    }
  }
Example #3
0
  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");
    }
  }
Example #4
0
  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;
  }