本文整理了Java中org.apache.hadoop.hbase.client.Admin.isTableEnabled()
方法的一些代码示例,展示了Admin.isTableEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Admin.isTableEnabled()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Admin
类名称:Admin
方法名:isTableEnabled
暂无
代码示例来源:origin: apache/hbase
/**
* Canary entry point for specified table.
* @throws Exception
*/
private static List<Future<Void>> sniff(final Admin admin, final Sink sink, String tableName,
ExecutorService executor, TaskType taskType, boolean rawScanEnabled, LongAdder readLatency)
throws Exception {
LOG.debug("Checking table is enabled and getting table descriptor for table {}", tableName);
if (admin.isTableEnabled(TableName.valueOf(tableName))) {
return Canary.sniff(admin, sink, admin.getDescriptor(TableName.valueOf(tableName)),
executor, taskType, rawScanEnabled, readLatency);
} else {
LOG.warn("Table {} is not enabled", tableName);
}
return new LinkedList<>();
}
代码示例来源: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
@Override
public boolean isTableEnabled(ByteBuffer tableName) throws IOError {
try {
return this.connectionCache.getAdmin().isTableEnabled(getTableName(tableName));
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw getIOError(e);
}
}
代码示例来源:origin: apache/kylin
public static void deleteTable(Connection conn, String tableName) throws IOException {
Admin hbase = conn.getAdmin();
try {
if (!tableExists(conn, tableName)) {
logger.debug("HTable '" + tableName + "' does not exists");
return;
}
logger.debug("delete HTable '" + tableName + "'");
if (hbase.isTableEnabled(TableName.valueOf(tableName))) {
hbase.disableTable(TableName.valueOf(tableName));
}
hbase.deleteTable(TableName.valueOf(tableName));
logger.debug("HTable '" + tableName + "' deleted");
} finally {
hbase.close();
}
}
代码示例来源:origin: apache/hbase
@Override
public boolean isTableEnabled(TTableName tableName) throws TIOError, TException {
try {
TableName table = tableNameFromThrift(tableName);
return connectionCache.getAdmin().isTableEnabled(table);
} catch (IOException e) {
throw getTIOError(e);
}
}
代码示例来源:origin: apache/hbase
private List<Future<Void>> sniff(TaskType taskType, RegionStdOutSink regionSink)
throws Exception {
LOG.debug("Reading list of tables");
List<Future<Void>> taskFutures = new LinkedList<>();
for (TableDescriptor td: admin.listTableDescriptors()) {
if (admin.isTableEnabled(td.getTableName()) &&
(!td.getTableName().equals(writeTableName))) {
LongAdder readLatency =
regionSink.initializeAndGetReadLatencyForTable(td.getTableName().getNameAsString());
taskFutures.addAll(Canary.sniff(admin, sink, td, executor, taskType, this.rawScanEnabled,
readLatency));
}
}
return taskFutures;
}
代码示例来源:origin: apache/hive
@Override
public void commitDropTable(Table tbl, boolean deleteData) throws MetaException {
try {
String tableName = getHBaseTableName(tbl);
boolean isPurge = !MetaStoreUtils.isExternalTable(tbl) || MetaStoreUtils.isExternalTablePurge(tbl);
if (deleteData && isPurge) {
LOG.info("Dropping with purge all the data for data source {}", tableName);
if (getHBaseAdmin().tableExists(TableName.valueOf(tableName))) {
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
@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/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
@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
@Override
public boolean evaluate() throws IOException {
return getAdmin().tableExists(tableName) && getAdmin().isTableEnabled(tableName);
}
};
代码示例来源:origin: apache/hbase
/**
* Get servername that is up in hbase:meta hosting the given region. this is hostname + port +
* startcode comma-delimited. Can return null
* @return regionServer hosting the given region
*/
private ServerName getServerNameForRegion(RegionInfo region) throws IOException {
if (!admin.isTableEnabled(region.getTable())) {
return null;
}
HRegionLocation loc =
conn.getRegionLocator(region.getTable()).getRegionLocation(region.getStartKey(), true);
if (loc != null) {
return loc.getServerName();
} else {
return null;
}
}
代码示例来源:origin: apache/hbase
@Before
public void setUp() throws Exception {
Admin admin = util.getAdmin();
if (admin.tableExists(tableName)) {
if (admin.isTableEnabled(tableName)) {
admin.disableTable(tableName);
}
admin.deleteTable(tableName);
}
util.createTable(tableName, new byte[][] {dummy, test});
TestCoprocessor.PREPUT_BYPASSES.set(0);
TestCoprocessor.PREPUT_INVOCATIONS.set(0);
}
代码示例来源:origin: apache/hbase
@Test
public void testIsEnabledOrDisabledOnUnknownTable() throws Exception {
try {
admin.isTableEnabled(TableName.valueOf(name.getMethodName()));
fail("Test should fail if isTableEnabled called on unknown table.");
} catch (IOException e) {
}
try {
admin.isTableDisabled(TableName.valueOf(name.getMethodName()));
fail("Test should fail if isTableDisabled called on unknown table.");
} catch (IOException e) {
}
}
代码示例来源: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 tearDownAfterTest() throws IOException {
Admin admin = TEST_UTIL.getAdmin();
if (admin.isTableEnabled(TABLE_NAME)) {
admin.disableTable(TABLE_NAME);
}
admin.deleteTable(TABLE_NAME);
}
代码示例来源:origin: apache/hbase
protected void verifyTables() throws IOException{
Connection connection = getConnection();
Admin admin = connection.getAdmin();
// iterating concurrent map
for (TableName tableName : enabledTables.keySet()){
Assert.assertTrue("Table: " + tableName + " in enabledTables is not enabled",
admin.isTableEnabled(tableName));
}
for (TableName tableName : disabledTables.keySet()){
Assert.assertTrue("Table: " + tableName + " in disabledTables is not disabled",
admin.isTableDisabled(tableName));
}
for (TableName tableName : deletedTables.keySet()){
Assert.assertFalse("Table: " + tableName + " in deletedTables is not deleted",
admin.tableExists(tableName));
}
admin.close();
}
代码示例来源:origin: apache/hbase
@BeforeClass
public static void setUpBeforeClass() throws Exception {
conf = HBaseConfiguration.create();
conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
TestCoprocessor.class.getName());
util = new HBaseTestingUtility(conf);
util.startMiniCluster();
Admin admin = util.getAdmin();
if (admin.tableExists(tableName)) {
if (admin.isTableEnabled(tableName)) {
admin.disableTable(tableName);
}
admin.deleteTable(tableName);
}
Table ht = util.createTable(tableName, new byte[][]{dummy, test});
Put p = new Put(row1);
p.addColumn(dummy, dummy, dummy);
ht.put(p);
}
代码示例来源:origin: apache/hbase
@Test
public void testEnableDisableAddColumnDeleteColumn() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
while (!this.admin.isTableEnabled(TableName.valueOf(name.getMethodName()))) {
Thread.sleep(10);
}
this.admin.disableTable(tableName);
try {
TEST_UTIL.getConnection().getTable(tableName);
} catch (org.apache.hadoop.hbase.DoNotRetryIOException e) {
//expected
}
this.admin.addColumnFamily(tableName, new HColumnDescriptor("col2"));
this.admin.enableTable(tableName);
try {
this.admin.deleteColumnFamily(tableName, Bytes.toBytes("col2"));
} catch (TableNotDisabledException e) {
LOG.info(e.toString(), e);
}
this.admin.disableTable(tableName);
this.admin.deleteTable(tableName);
}
代码示例来源:origin: apache/hbase
@After
public void tearDownAfterTest() throws IOException {
Admin admin = TEST_UTIL.getAdmin();
if (admin.tableExists(TABLE_NAME)) {
if (admin.isTableEnabled(TABLE_NAME)) {
TEST_UTIL.getAdmin().disableTable(TABLE_NAME);
}
TEST_UTIL.getAdmin().deleteTable(TABLE_NAME);
}
LOCATOR.clearCache(TABLE_NAME);
}
内容来源于网络,如有侵权,请联系作者删除!