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

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

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

Admin.listTables介绍

[英]List all the userspace tables.
[中]列出所有用户空间表。

代码示例

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

@Override
public void call(Admin admin) throws Exception {
 admin.listTables();
}
@Override

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

private void setupMockTables() throws IOException {
 HTableDescriptor tables[] = new HTableDescriptor[] {
   new HTableDescriptor(TableName.valueOf("foo")),
   new HTableDescriptor(TableName.valueOf("bar"))
 };
 Mockito.doReturn(tables).when(admin).listTables();
}

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

@Override
public Set<String> getTableNames() {
 try(Admin admin = plugin.getConnection().getAdmin()) {
  HTableDescriptor[] tables = admin.listTables();
  Set<String> tableNames = Sets.newHashSet();
  for (HTableDescriptor table : tables) {
   tableNames.add(new String(table.getTableName().getNameAsString()));
  }
  return tableNames;
 } catch (Exception e) {
  logger.warn("Failure while loading table names for database '{}'.", getName(), e.getCause());
  return Collections.emptySet();
 }
}

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

public void waitTableDeleted(TableName name, long timeoutInMillis) throws Exception {
 long start = System.currentTimeMillis();
 while (true) {
  HTableDescriptor[] tables = admin.listTables();
  for (HTableDescriptor htd : tables) {
   if (htd.getNameAsString() == name.getNameAsString())
    return;
  }
  if (System.currentTimeMillis() - start > timeoutInMillis)
   return;
  Thread.sleep(1000);
 }
}

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

private void clean() throws IOException {
  Connection conn = HBaseConnection.get(KylinConfig.getInstanceFromEnv().getStorageUrl());
  Admin hbaseAdmin = conn.getAdmin();
  for (HTableDescriptor descriptor : hbaseAdmin.listTables()) {
    String name = descriptor.getNameAsString().toLowerCase(Locale.ROOT);
    if (name.startsWith("kylin") || name.startsWith("_kylin")) {
      String x = descriptor.getValue(IRealizationConstants.HTableTag);
      System.out.println("table name " + descriptor.getNameAsString() + " host: " + x);
      System.out.println(descriptor);
      System.out.println();
      descriptor.setValue(IRealizationConstants.HTableOwner, "whoami@kylin.apache.org");
      hbaseAdmin.modifyTable(TableName.valueOf(descriptor.getNameAsString()), descriptor);
    }
  }
  hbaseAdmin.close();
}

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

protected HTableDescriptor[] getTables(final Configuration configuration) throws IOException {
  HTableDescriptor[] htbls = null;
  try (Connection connection = ConnectionFactory.createConnection(configuration)) {
   try (Admin admin = connection.getAdmin()) {
    htbls = admin.listTables();
   }
  }
  return htbls;
 }
}

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

@Override
 public Object run() throws Exception {
  try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
    Admin admin = conn.getAdmin()) {
   return Arrays.asList(admin.listTables());
  }
 }
};

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

@After
public void tearDown() throws Exception {
 for (HTableDescriptor htd : this.admin.listTables()) {
  TEST_UTIL.deleteTable(htd.getTableName());
 }
}

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

@After
public void tearDown() throws Exception {
 for (HTableDescriptor htd : this.admin.listTables()) {
  TEST_UTIL.deleteTable(htd.getTableName());
 }
}

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

@Test
public void createTableInDefaultNamespace() throws Exception {
 HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
 HColumnDescriptor colDesc = new HColumnDescriptor("cf1");
 desc.addFamily(colDesc);
 admin.createTable(desc);
 assertTrue(admin.listTables().length == 1);
 admin.disableTable(desc.getTableName());
 admin.deleteTable(desc.getTableName());
}

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

/**
 * @throws java.lang.Exception
 */
@After
public void tearDown() throws Exception {
 for (HTableDescriptor htd: TEST_UTIL.getAdmin().listTables()) {
  LOG.info("Tear down, remove table=" + htd.getTableName());
  TEST_UTIL.deleteTable(htd.getTableName());
}
}

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

/**
 * @throws java.lang.Exception
 */
@After
public void tearDown() throws Exception {
 for (HTableDescriptor htd : TEST_UTIL.getAdmin().listTables()) {
  LOG.info("Tear down, remove table=" + htd.getTableName());
  TEST_UTIL.deleteTable(htd.getTableName());
 }
}

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

@Test
public void createTableInSystemNamespace() throws Exception {
 final TableName tableName = TableName.valueOf("hbase:" + name.getMethodName());
 HTableDescriptor desc = new HTableDescriptor(tableName);
 HColumnDescriptor colDesc = new HColumnDescriptor("cf1");
 desc.addFamily(colDesc);
 admin.createTable(desc);
 assertEquals(0, admin.listTables().length);
 assertTrue(admin.tableExists(tableName));
 admin.disableTable(desc.getTableName());
 admin.deleteTable(desc.getTableName());
}

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

@After
public void tearDown() throws Exception {
 resetProcExecutorTestingKillFlag();
 for (HTableDescriptor htd: UTIL.getAdmin().listTables()) {
  LOG.info("Tear down, remove table=" + htd.getTableName());
  UTIL.deleteTable(htd.getTableName());
 }
}

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

@Test
public void testCreateTable() throws IOException {
 HTableDescriptor [] tables = admin.listTables();
 int numTables = tables.length;
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
 tables = this.admin.listTables();
 assertEquals(numTables + 1, tables.length);
 assertTrue("Table must be enabled.",
   TEST_UTIL.getHBaseCluster().getMaster().getTableStateManager()
     .isTableState(tableName, TableState.State.ENABLED));
 assertEquals(TableState.State.ENABLED, getStateFromMeta(tableName));
}

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

@Before
public void setup() throws IOException {
 try (Connection connection = ConnectionFactory.createConnection(UTIL.getConfiguration());
    Admin admin = connection.getAdmin()) {
  for (HTableDescriptor htd : admin.listTables()) {
   UTIL.deleteTable(htd.getTableName());
  }
 }
}

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

@Before
public void beforeMethod() throws IOException {
 for (HTableDescriptor desc : admin.listTables(prefix+".*")) {
  admin.disableTable(desc.getTableName());
  admin.deleteTable(desc.getTableName());
 }
 for (NamespaceDescriptor ns : admin.listNamespaceDescriptors()) {
  if (ns.getName().startsWith(prefix)) {
   admin.deleteNamespace(ns.getName());
  }
 }
}

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

@After
public void tearDown() throws Exception {
 assertTrue("expected executor to be running", getMasterProcedureExecutor().isRunning());
 ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false);
 for (HTableDescriptor htd: UTIL.getAdmin().listTables()) {
  LOG.info("Tear down, remove table=" + htd.getTableName());
  UTIL.deleteTable(htd.getTableName());
 }
}

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

@Before
public void setUpBefore() throws Exception {
 TEST_UTIL = new HBaseTestingUtility();
 TEST_UTIL.getConfiguration().setInt("dfs.datanode.max.xceivers", 9192);
 TEST_UTIL.startMiniCluster(3);
 conf = TEST_UTIL.getConfiguration();
 this.connection = ConnectionFactory.createConnection(conf);
 assertEquals(0, TEST_UTIL.getAdmin().listTables().length);
 // setup the table
 table = TableName.valueOf(TABLE_BASE + "-" + tableIdx);
 tableIdx++;
 htbl = setupTable(table);
 populateTable(htbl);
 assertEquals(5, scanMeta());
 LOG.info("Table " + table + " has " + tableRowCount(conf, table)
   + " entries.");
 assertEquals(16, tableRowCount(conf, table));
 TEST_UTIL.getAdmin().disableTable(table);
 assertEquals(1, TEST_UTIL.getAdmin().listTables().length);
}

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

@After
public void cleanup() throws Exception, KeeperException {
 for (HTableDescriptor table : ADMIN.listTables()) {
  ADMIN.disableTable(table.getTableName());
  deleteTable(table.getTableName());
 }
 for (NamespaceDescriptor ns : ADMIN.listNamespaceDescriptors()) {
  if (ns.getName().startsWith(prefix)) {
   ADMIN.deleteNamespace(ns.getName());
  }
 }
 assertTrue("Quota manager not initialized", UTIL.getHBaseCluster().getMaster()
   .getMasterQuotaManager().isQuotaInitialized());
}

相关文章

Admin类方法