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

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

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

Admin.listTableNamesByNamespace介绍

[英]Get list of table names by namespace
[中]按命名空间获取表名列表

代码示例

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

@Override
 public Void call() throws Exception {
  admin.listTableNamesByNamespace("non_existing_namespace");
  return null;
 }
}, NamespaceNotFoundException.class);

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

@Override
public List<TTableName> getTableNamesByNamespace(String name) throws TIOError, TException {
 try {
  TableName[] tableNames = connectionCache.getAdmin().listTableNamesByNamespace(name);
  return tableNamesFromHBase(tableNames);
 } catch (IOException e) {
  throw getTIOError(e);
 }
}

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

tablesToFetchSnapshotsFrom.addAll(Arrays.asList(admin.listTableNamesByNamespace(ns)));
} else {
 tablesToFetchSnapshotsFrom.add(tn);

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

assert tableName == null;
TableName[] tablesInNS = conn.getAdmin().listTableNamesByNamespace(namespace);
for (TableName tableUnderNs : tablesInNS) {
 if (LOG.isTraceEnabled()) {

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

@Test
public void testSystemTables() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys);
 TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
 // All regions should have favored nodes
 checkIfFavoredNodeInformationIsCorrect(tableName);
 for (TableName sysTable :
   admin.listTableNamesByNamespace(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR)) {
  List<HRegionInfo> regions = admin.getTableRegions(sysTable);
  for (HRegionInfo region : regions) {
   assertNull("FN should be null for sys region", fnm.getFavoredNodes(region));
  }
 }
 TEST_UTIL.deleteTable(tableName);
}

代码示例来源:origin: larsgeorge/hbase-book

public void dropNamespace(String namespace, boolean force) {
 try {
  if (force) {
   TableName[] tableNames = admin.listTableNamesByNamespace(namespace);
   for (TableName name : tableNames) {
    admin.disableTable(name);
    admin.deleteTable(name);
   }
  }
 } catch (Exception e) {
  // ignore
 }
 try {
  admin.deleteNamespace(namespace);
 } catch (IOException e) {
  System.err.println("Error: " + e.getMessage());
 }
}

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

TableName[] tableNames = admin.listTableNamesByNamespace(prefix + "ns1");
assertNotNull("Should have not returned null", tableNames);
assertEquals("Should have returned non-empty array", 1, tableNames.length);

代码示例来源:origin: larsgeorge/hbase-book

names = admin.listTableNamesByNamespace("testspace1");

代码示例来源:origin: larsgeorge/hbase-book

TableName[] tbls = admin.listTableNamesByNamespace("testspace");
for (TableName tbl : tbls) {
 admin.disableTable(tbl);

代码示例来源:origin: hortonworks/streamline

/**
 * @param namespace Namespace for which to get table names
 * @return All tables for the namespace given as parameter
 */
public Tables getHBaseTables(final String namespace) throws IOException, PrivilegedActionException, InterruptedException {
  final TableName[] tableNames = executeSecure(() -> hBaseAdmin.listTableNamesByNamespace(namespace));
  LOG.debug("HBase namespace [{}] has tables {}", namespace, Arrays.toString(tableNames));
  return Tables.newInstance(tableNames, securityContext, true, getPrincipals(), getKeytabs());
}

代码示例来源:origin: opencb/opencga

public static void printTables(Configuration conf) throws IOException {
  System.out.println("Print tables!");
  System.out.println("conf.get(HConstants.ZOOKEEPER_QUORUM) = " + conf.get(HConstants.ZOOKEEPER_QUORUM));
  try (Connection con = ConnectionFactory.createConnection(conf)) {
    HBaseManager.act(con, "all", (table, admin) -> {
      for (NamespaceDescriptor ns : admin.listNamespaceDescriptors()) {
        System.out.println(ns.getName());
        for (TableName tableName : admin.listTableNamesByNamespace(ns.getName())) {
          System.out.println("      " + tableName);
        }
        System.out.println("---");
      }
      return null;
    });
  }
}

代码示例来源:origin: waterguo/antsdb

TableName[] tables = admin.listTableNamesByNamespace(this.sysns);
for (TableName i:tables) {
  String name = i.getQualifierAsString();

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testSystemTables() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys);
 TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
 // All regions should have favored nodes
 checkIfFavoredNodeInformationIsCorrect(tableName);
 for (TableName sysTable :
   admin.listTableNamesByNamespace(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR)) {
  List<HRegionInfo> regions = admin.getTableRegions(sysTable);
  for (HRegionInfo region : regions) {
   assertNull("FN should be null for sys region", fnm.getFavoredNodes(region));
  }
 }
 TEST_UTIL.deleteTable(tableName);
}

代码示例来源:origin: opencb/opencga

@Test
public void testNamespace() throws Exception {
  HadoopVariantStorageEngine variantStorageManager = getVariantStorageEngine();
  variantStorageManager.getOptions().put(HadoopVariantStorageEngine.HBASE_NAMESPACE, "opencga");
  VariantHadoopDBAdaptor dbAdaptor = variantStorageManager.getDBAdaptor();
  Admin admin = dbAdaptor.getConnection().getAdmin();
  admin.createNamespace(NamespaceDescriptor.create("opencga").build());
  runDefaultETL(getResourceUri("s1.genome.vcf"), variantStorageManager, newStudyConfiguration(),
      new ObjectMap()
          .append(HadoopVariantStorageEngine.HBASE_NAMESPACE, "opencga")
          .append(VariantStorageEngine.Options.ANNOTATE.key(), true)
          .append(VariantStorageEngine.Options.CALCULATE_STATS.key(), true));
  NamespaceDescriptor[] namespaceDescriptors = admin.listNamespaceDescriptors();
  for (NamespaceDescriptor namespaceDescriptor : namespaceDescriptors) {
    System.out.println("namespaceDescriptor = " + namespaceDescriptor);
    for (TableName tableName : admin.listTableNamesByNamespace(namespaceDescriptor.getName())) {
      System.out.println("\ttableName = " + tableName);
    }
    if (namespaceDescriptor.getName().equals("opencga")) {
      Assert.assertEquals(4, admin.listTableNamesByNamespace(namespaceDescriptor.getName()).length);
    }
  }
  assertTrue(variantStorageManager.getDBAdaptor().count(null).first() > 0);
}

代码示例来源:origin: opencb/opencga

@Test
public void testNoNamespace() throws Exception {
  runDefaultETL(smallInputUri, getVariantStorageEngine(), newStudyConfiguration(),
      new ObjectMap()
          .append(HadoopVariantStorageEngine.HBASE_NAMESPACE, "")
          .append(VariantStorageEngine.Options.ANNOTATE.key(), true)
          .append(VariantStorageEngine.Options.CALCULATE_STATS.key(), true));
  HadoopVariantStorageEngine variantStorageManager = getVariantStorageEngine();
  Admin admin = variantStorageManager.getDBAdaptor().getConnection().getAdmin();
  for (NamespaceDescriptor namespaceDescriptor : admin.listNamespaceDescriptors()) {
    System.out.println("namespaceDescriptor = " + namespaceDescriptor);
    for (TableName tableName : admin.listTableNamesByNamespace(namespaceDescriptor.getName())) {
      System.out.println("\ttableName = " + tableName);
    }
  }
  assertTrue(variantStorageManager.getDBAdaptor().count(null).first() > 0);
}

代码示例来源:origin: org.apache.hbase/hbase-server

TableName[] tableNames = admin.listTableNamesByNamespace(prefix + "ns1");
assertNotNull("Should have not returned null", tableNames);
assertEquals("Should have returned non-empty array", 1, tableNames.length);

相关文章

Admin类方法