org.apache.hadoop.hbase.client.Admin.deleteTable()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(199)

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

Admin.deleteTable介绍

[英]Deletes a table. Synchronous operation.
[中]删除一个表。同步操作。

代码示例

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

public Object call() throws Exception {
    logger.info("Deleting HBase table " + htableName);
    if (hbaseAdmin.tableExists(TableName.valueOf(htableName))) {
      if (hbaseAdmin.isTableEnabled(TableName.valueOf(htableName))) {
        hbaseAdmin.disableTable(TableName.valueOf(htableName));
      }
      hbaseAdmin.deleteTable(TableName.valueOf(htableName));
      logger.info("Deleted HBase table " + htableName);
    } else {
      logger.info("HBase table" + htableName + " does not exist");
    }
    return null;
  }
}

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

@Test
public void testEnableReplicationWhenSlaveClusterDoesntHaveTable() throws Exception {
 admin1.disableTableReplication(tableName);
 admin2.disableTable(tableName);
 admin2.deleteTable(tableName);
 assertFalse(admin2.tableExists(tableName));
 admin1.enableTableReplication(tableName);
 assertTrue(admin2.tableExists(tableName));
}

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

private static void deleteTable(Configuration conf, String[] args) {
 TableName tableName = TableName.valueOf(args[0]);
 try (Connection connection = ConnectionFactory.createConnection(conf);
    Admin admin = connection.getAdmin()) {
  try {
   admin.disableTable(tableName);
  } catch (TableNotEnabledException e) {
   LOG.debug("Dry mode: Table: " + tableName + " already disabled, so just deleting it.");
  }
  admin.deleteTable(tableName);
 } catch (IOException e) {
  LOG.error(format("***Dry run: Failed to delete table '%s'.***%n%s", tableName,
    e.toString()));
  return;
 }
 LOG.info(format("Dry run: Deleted table '%s'.", tableName));
}

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

private void dropTable(Admin admin, TableName tn) throws  Exception {
  admin.disableTable(tn);
  admin.deleteTable(tn);
 }
}

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

private static void destroy(Admin admin, TableName tableName) throws IOException {
  try {
   admin.disableTable(tableName);
   admin.deleteTable(tableName);
  } catch (TableNotFoundException tnfe) {
   /* Ignore */
  }
 }
}

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

public static void deleteHTable(TableName tableName) 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);
    }
  } finally {
    IOUtils.closeQuietly(admin);
  }
}

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

@After
public void afterTestMethod() throws Exception {
 admin.disableTable(tableName);
 admin.deleteTable(tableName);
}

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

private static void deleteTable() {
 if (admin != null) {
  try {
   admin.disableTable(name);
   admin.deleteTable(name);
  } catch (IOException e) {
   assertNull("Exception found deleting the table", e);
  }
 }
}

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

/**
 * Drop an existing table
 * @param tableName existing table
 */
public void deleteTable(TableName tableName) throws IOException {
 try {
  getAdmin().disableTable(tableName);
 } catch (TableNotEnabledException e) {
  LOG.debug("Table: " + tableName + " already disabled, so just deleting it.");
 }
 getAdmin().deleteTable(tableName);
}

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

private void disableAndDeleteTable(TableName tableName) throws IOException {
 HTU.getAdmin().disableTable(tableName);
 HTU.getAdmin().deleteTable(tableName);
}

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

@After
public void tearDown() throws Exception {
 Admin admin = TEST_UTIL.getAdmin();
 for (String table : new String[] {TABLE1, TABLE2}) {
  TableName t = TableName.valueOf(table);
  if (admin.tableExists(t)) {
   admin.disableTable(t);
   admin.deleteTable(t);
  }
 }
 conf.set("hbase.rest.readonly", "false");
}

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

@Override
public void rollbackCreateTable(Table table) throws MetaException {
 String tableName = getHBaseTableName(table);
 boolean isPurge = !MetaStoreUtils.isExternalTable(table) || MetaStoreUtils.isExternalTablePurge(table);
 try {
  if (isPurge && getHBaseAdmin().tableExists(TableName.valueOf(tableName))) {
   // we have created an HBase table, so we delete it to roll back;
   if (getHBaseAdmin().isTableEnabled(TableName.valueOf(tableName))) {
    getHBaseAdmin().disableTable(TableName.valueOf(tableName));
   }
   getHBaseAdmin().deleteTable(TableName.valueOf(tableName));
  }
 } catch (IOException ie) {
  throw new MetaException(StringUtils.stringifyException(ie));
 }
}

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

private static void deleteTables() {
 if (admin != null) {
  for (TableName tableName: createdTables){
   try {
    if (admin.tableExists(tableName)) {
     admin.disableTable(tableName);
     admin.deleteTable(tableName);
    }
   } catch (IOException e) {
    assertNull("Exception found deleting the table", e);
   }
  }
 }
}

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

@After
public void tearDown() throws IOException {
 LOG.info("Cleaning up after test.");
 if (admin.tableExists(TABLE_NAME)) {
  if (admin.isTableEnabled(TABLE_NAME)) admin.disableTable(TABLE_NAME);
  admin.deleteTable(TABLE_NAME);
 }
 LOG.info("Restoring cluster.");
 UTIL.restoreCluster();
 LOG.info("Cluster restored.");
}

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

@Before
public void setUp() throws Exception {
 LOG.info(String.format("Initializing cluster with %d region servers.",
  REGION_SERVER_COUNT));
 UTIL.initializeCluster(REGION_SERVER_COUNT);
 LOG.info("Cluster initialized");
 admin = UTIL.getAdmin();
 if (admin.tableExists(TABLE_NAME)) {
  LOG.info(String.format("Deleting existing table %s.", TABLE_NAME));
  if (admin.isTableEnabled(TABLE_NAME)) admin.disableTable(TABLE_NAME);
  admin.deleteTable(TABLE_NAME);
  LOG.info(String.format("Existing table %s deleted.", TABLE_NAME));
 }
 LOG.info("Cluster ready");
}

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

@After
public void cleanupTestTable() throws Exception {
 UTIL.getAdmin().disableTable(primaryTable);
 UTIL.getAdmin().deleteTable(primaryTable);
 UTIL.getAdmin().disableTable(otherTable);
 UTIL.getAdmin().deleteTable(otherTable);
}

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

@After
public void tearDownAfterTest() throws IOException {
 try (Admin admin = UTIL.getAdmin()) {
  if (admin.isTableEnabled(tableName)) {
   admin.disableTable(tableName);
  }
  admin.deleteTable(tableName);
 }
}

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

@After
public void tearDown() throws IOException {
 Admin admin = UTIL.getAdmin();
 if (admin.tableExists(NAME)) {
  admin.disableTable(NAME);
  admin.deleteTable(NAME);
 }
}

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

@After
public void cleanup() throws Exception {
 // cleanup
 CheckWasRunConstraint.wasRun = false;
 util.getAdmin().disableTable(tableName);
 util.getAdmin().deleteTable(tableName);
}

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

@AfterClass
public static void tearDown() throws Exception {
 UTIL.getAdmin().disableTable(TABLE_DONOT_RETRY);
 UTIL.getAdmin().disableTable(TABLE_RETRY);
 UTIL.getAdmin().deleteTable(TABLE_DONOT_RETRY);
 UTIL.getAdmin().deleteTable(TABLE_RETRY);
 UTIL.shutdownMiniCluster();
}

相关文章

Admin类方法