Java Code Examples for org.apache.hadoop.hbase.client.Admin#listTables()
The following examples show how to use
org.apache.hadoop.hbase.client.Admin#listTables() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBaseUsage.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private static void show() throws IOException { Map<String, List<String>> envs = Maps.newHashMap(); // get all kylin hbase tables KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv(); Connection conn = HBaseConnection.get(kylinConfig.getStorageUrl()); Admin hbaseAdmin = conn.getAdmin(); String tableNamePrefix = kylinConfig.getHBaseTableNamePrefix(); HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(tableNamePrefix + ".*"); for (HTableDescriptor desc : tableDescriptors) { String host = desc.getValue(IRealizationConstants.HTableTag); if (StringUtils.isEmpty(host)) { add("unknown", desc.getNameAsString(), envs); } else { add(host, desc.getNameAsString(), envs); } } for (Map.Entry<String, List<String>> entry : envs.entrySet()) { System.out.println(entry.getKey() + " has htable count: " + entry.getValue().size()); } hbaseAdmin.close(); }
Example 2
Source File: CleanHtableCLI.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
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, "[email protected]"); hbaseAdmin.modifyTable(TableName.valueOf(descriptor.getNameAsString()), descriptor); } } hbaseAdmin.close(); }
Example 3
Source File: HBaseUsage.java From kylin with Apache License 2.0 | 6 votes |
private static void show() throws IOException { Map<String, List<String>> envs = Maps.newHashMap(); // get all kylin hbase tables KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv(); Connection conn = HBaseConnection.get(kylinConfig.getStorageUrl()); Admin hbaseAdmin = conn.getAdmin(); String tableNamePrefix = kylinConfig.getHBaseTableNamePrefix(); HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(tableNamePrefix + ".*"); for (HTableDescriptor desc : tableDescriptors) { String host = desc.getValue(IRealizationConstants.HTableTag); if (StringUtils.isEmpty(host)) { add("unknown", desc.getNameAsString(), envs); } else { add(host, desc.getNameAsString(), envs); } } for (Map.Entry<String, List<String>> entry : envs.entrySet()) { System.out.println(entry.getKey() + " has htable count: " + entry.getValue().size()); } hbaseAdmin.close(); }
Example 4
Source File: CleanHtableCLI.java From kylin with Apache License 2.0 | 6 votes |
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, "[email protected]"); hbaseAdmin.modifyTable(TableName.valueOf(descriptor.getNameAsString()), descriptor); } } hbaseAdmin.close(); }
Example 5
Source File: HBaseRangerAuthorizationTest.java From ranger with Apache License 2.0 | 6 votes |
@Test public void testReadTablesAsProcessOwner() throws Exception { final Configuration conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper.quorum", "localhost"); conf.set("hbase.zookeeper.property.clientPort", "" + port); conf.set("zookeeper.znode.parent", "/hbase-unsecure"); Connection conn = ConnectionFactory.createConnection(conf); Admin admin = conn.getAdmin(); HTableDescriptor[] tableDescriptors = admin.listTables(); for (HTableDescriptor desc : tableDescriptors) { LOG.info("Found table:[" + desc.getTableName().getNameAsString() + "]"); } Assert.assertEquals(3, tableDescriptors.length); conn.close(); }
Example 6
Source File: BaseTest.java From phoenix with Apache License 2.0 | 6 votes |
/** * Disable and drop all the tables except SYSTEM.CATALOG and SYSTEM.SEQUENCE */ private static void disableAndDropNonSystemTables() throws Exception { if (driver == null) return; Admin admin = driver.getConnectionQueryServices(null, null).getAdmin(); try { TableDescriptor[] tables = admin.listTables(); for (TableDescriptor table : tables) { String schemaName = SchemaUtil.getSchemaNameFromFullName(table.getTableName().getName()); if (!QueryConstants.SYSTEM_SCHEMA_NAME.equals(schemaName)) { disableAndDropTable(admin, table.getTableName()); } } } finally { admin.close(); } }
Example 7
Source File: TestHBaseCommitTable.java From phoenix-omid with Apache License 2.0 | 5 votes |
@BeforeMethod public void setUp() throws Exception { Admin admin = testutil.getHBaseAdmin(); if (!admin.tableExists(TableName.valueOf(TEST_TABLE))) { HTableDescriptor desc = new HTableDescriptor(TABLE_NAME); HColumnDescriptor datafam = new HColumnDescriptor(commitTableFamily); datafam.setMaxVersions(Integer.MAX_VALUE); desc.addFamily(datafam); HColumnDescriptor lowWatermarkFam = new HColumnDescriptor(lowWatermarkFamily); lowWatermarkFam.setMaxVersions(Integer.MAX_VALUE); desc.addFamily(lowWatermarkFam); // Move to HBaseSims for 2.0 support // For 2.0, use TableDescriptorBuilder to build TableDescriptor admin.createTable(desc); } if (admin.isTableDisabled(TableName.valueOf(TEST_TABLE))) { admin.enableTable(TableName.valueOf(TEST_TABLE)); } HTableDescriptor[] tables = admin.listTables(); for (HTableDescriptor t : tables) { LOG.info(t.getNameAsString()); } }
Example 8
Source File: HBaseCLI.java From cloud-bigtable-examples with Apache License 2.0 | 5 votes |
public void run(Connection connection, List<String> args) throws InvalidArgsException, IOException { String pattern = null; if (args.size() == 1) { pattern = args.get(0); } else if (args.size() != 0) { throw new InvalidArgsException(args); } Admin admin = connection.getAdmin(); HTableDescriptor[] tables; // We use the listTables() method on the Admin instance // to get a list of HTableDescriptor objects. if (pattern != null) { tables = admin.listTables(pattern); } else { tables = admin.listTables(); } // For each of the tables we get the table name and column families // registered with the table, and print them out. for (HTableDescriptor table : tables) { HColumnDescriptor[] columnFamilies = table.getColumnFamilies(); String columnFamilyNames = ""; for (HColumnDescriptor columnFamily : columnFamilies) { columnFamilyNames += columnFamily.getNameAsString() + ","; } if (columnFamilyNames.length() > 0) { columnFamilyNames = " <" + columnFamilyNames.substring(0, columnFamilyNames.length()) + ">"; } System.out.println(table.getTableName() + columnFamilyNames); } }
Example 9
Source File: IndexerIT.java From hbase-indexer with Apache License 2.0 | 5 votes |
@Before public void setUpBeforeTest() throws Exception { if (!firstTest) { // Delete /ngdata from zookeeper System.out.println(">>> Deleting /ngdata node from ZooKeeper"); cleanZooKeeper("localhost:" + hbaseTestUtil.getZkCluster().getClientPort(), "/ngdata"); // Delete all hbase tables System.out.println(">>> Deleting all HBase tables"); Admin admin = connection.getAdmin(); for (HTableDescriptor table : admin.listTables()) { admin.disableTable(table.getTableName()); admin.deleteTable(table.getTableName()); } admin.close(); // Delete all replication peers System.out.println(">>> Deleting all replication peers from HBase"); ReplicationAdmin replAdmin = new ReplicationAdmin(conf); for (String peerId : replAdmin.listPeerConfigs().keySet()) { replAdmin.removePeer(peerId); } replAdmin.close(); SepTestUtil.waitOnAllReplicationPeersStopped(); // Clear Solr indexes System.out.println(">>> Clearing Solr indexes"); collection1.deleteByQuery("*:*"); collection1.commit(); collection2.deleteByQuery("*:*"); collection2.commit(); } else { firstTest = false; } main = new Main(); main.startServices(conf); }