Java Code Examples for org.apache.hadoop.hbase.client.HBaseAdmin#listTables()
The following examples show how to use
org.apache.hadoop.hbase.client.HBaseAdmin#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: TestHBaseTimestampStorage.java From phoenix-omid with Apache License 2.0 | 6 votes |
@BeforeMethod public void setUp() throws Exception { HBaseAdmin admin = testutil.getHBaseAdmin(); if (!admin.tableExists(TableName.valueOf(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME))) { HTableDescriptor desc = new HTableDescriptor(TABLE_NAME); HColumnDescriptor datafam = new HColumnDescriptor(DEFAULT_TIMESTAMP_STORAGE_CF_NAME); datafam.setMaxVersions(Integer.MAX_VALUE); desc.addFamily(datafam); admin.createTable(desc); } if (admin.isTableDisabled(TableName.valueOf(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME))) { admin.enableTable(TableName.valueOf(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME)); } HTableDescriptor[] tables = admin.listTables(); for (HTableDescriptor t : tables) { LOG.info(t.getNameAsString()); } }
Example 2
Source File: SnapshotArgs.java From hbase-tools with Apache License 2.0 | 6 votes |
private void parseTables(HBaseAdmin admin, String[] tables, Set<String> tableSet) throws IOException { for (String table : tables) { final String tableName; if (table.contains(ENTRY_DELIMITER)) { String[] parts = table.split(ENTRY_DELIMITER); tableName = parts[0]; tableKeepMap.put(tableName, Integer.valueOf(parts[1])); tableFlushMap.put(tableName, Boolean.valueOf(parts[2])); } else { tableName = table; } for (HTableDescriptor hTableDescriptor : admin.listTables(tableName)) { tableSet.add(hTableDescriptor.getNameAsString()); } } }
Example 3
Source File: SnapshotArgs.java From hbase-tools with Apache License 2.0 | 6 votes |
private void parseTables(HBaseAdmin admin, String[] tables, Set<String> tableSet) throws IOException { for (String table : tables) { final String tableName; if (table.contains(ENTRY_DELIMITER)) { String[] parts = table.split(ENTRY_DELIMITER); tableName = parts[0]; tableKeepMap.put(tableName, Integer.valueOf(parts[1])); tableFlushMap.put(tableName, Boolean.valueOf(parts[2])); } else { tableName = table; } for (HTableDescriptor hTableDescriptor : admin.listTables(tableName)) { tableSet.add(hTableDescriptor.getNameAsString()); } } }
Example 4
Source File: SnapshotArgs.java From hbase-tools with Apache License 2.0 | 6 votes |
private void parseTables(HBaseAdmin admin, String[] tables, Set<String> tableSet) throws IOException { for (String table : tables) { final String tableName; if (table.contains(ENTRY_DELIMITER)) { String[] parts = table.split(ENTRY_DELIMITER); tableName = parts[0]; tableKeepMap.put(tableName, Integer.valueOf(parts[1])); tableFlushMap.put(tableName, Boolean.valueOf(parts[2])); } else { tableName = table; } for (HTableDescriptor hTableDescriptor : admin.listTables(tableName)) { tableSet.add(hTableDescriptor.getNameAsString()); } } }
Example 5
Source File: SnapshotArgs.java From hbase-tools with Apache License 2.0 | 6 votes |
private void parseTables(HBaseAdmin admin, String[] tables, Set<String> tableSet) throws IOException { for (String table : tables) { final String tableName; if (table.contains(ENTRY_DELIMITER)) { String[] parts = table.split(ENTRY_DELIMITER); tableName = parts[0]; tableKeepMap.put(tableName, Integer.valueOf(parts[1])); tableFlushMap.put(tableName, Boolean.valueOf(parts[2])); } else { tableName = table; } for (HTableDescriptor hTableDescriptor : admin.listTables(tableName)) { tableSet.add(hTableDescriptor.getNameAsString()); } } }
Example 6
Source File: SnapshotArgs.java From hbase-tools with Apache License 2.0 | 6 votes |
private void parseTables(HBaseAdmin admin, String[] tables, Set<String> tableSet) throws IOException { for (String table : tables) { final String tableName; if (table.contains(ENTRY_DELIMITER)) { String[] parts = table.split(ENTRY_DELIMITER); tableName = parts[0]; tableKeepMap.put(tableName, Integer.valueOf(parts[1])); tableFlushMap.put(tableName, Boolean.valueOf(parts[2])); } else { tableName = table; } for (HTableDescriptor hTableDescriptor : admin.listTables(tableName)) { tableSet.add(hTableDescriptor.getNameAsString()); } } }
Example 7
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 { HBaseAdmin admin = driver.getConnectionQueryServices(null, null).getAdmin(); try { HTableDescriptor[] tables = admin.listTables(); for (HTableDescriptor table : tables) { String schemaName = SchemaUtil.getSchemaNameFromFullName(table.getName()); if (!QueryConstants.SYSTEM_SCHEMA_NAME.equals(schemaName)) { admin.disableTable(table.getName()); admin.deleteTable(table.getName()); } } } finally { admin.close(); } }
Example 8
Source File: TestCreateTable.java From learning-hadoop with Apache License 2.0 | 6 votes |
public static boolean existsFamilyName(HBaseAdmin hba, String tableName, String columnName) { HTableDescriptor[] list; try { list = hba.listTables(); for (int i = 0; i < list.length; i++) { if (list[i].getNameAsString().equals(tableName)) for (HColumnDescriptor hc : list[i].getColumnFamilies()) { if (hc.getNameAsString().equals(columnName)) return true; } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
Example 9
Source File: BasicHadoopTest.java From Kylin with Apache License 2.0 | 6 votes |
@Test public void testRetriveHtableHost() throws IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(); for (HTableDescriptor table : tableDescriptors) { String value = table.getValue("KYLIN_HOST"); if (value != null) { System.out.println(table.getTableName()); System.out.println("host is " + value); hbaseAdmin.disableTable(table.getTableName()); table.setValue("KYLIN_HOST_ANOTHER", "dev02"); hbaseAdmin.modifyTable(table.getTableName(), table); hbaseAdmin.enableTable(table.getTableName()); } } hbaseAdmin.close(); }
Example 10
Source File: Util.java From hbase-tools with Apache License 2.0 | 5 votes |
public static void validateTable(HBaseAdmin admin, String tableName) throws IOException, InterruptedException { if (tableName.equals(Args.ALL_TABLES)) return; boolean tableExists = false; try { if (tableName.contains(Constant.TABLE_DELIMITER)) { String[] tables = tableName.split(Constant.TABLE_DELIMITER); for (String table : tables) { tableExists = admin.tableExists(table); } } else { tableExists = admin.listTables(tableName).length > 0; } } catch (Exception e) { Thread.sleep(1000); System.out.println(); System.out.println(admin.getConfiguration().get("hbase.zookeeper.quorum") + " is invalid zookeeper quorum"); System.exit(1); } if (tableExists) { try { if (!admin.isTableEnabled(tableName)) { throw new InvalidTableException("Table is not enabled."); } } catch (Exception ignore) { } } else { throw new InvalidTableException("Table does not exist."); } }
Example 11
Source File: Util.java From hbase-tools with Apache License 2.0 | 5 votes |
public static void validateTable(HBaseAdmin admin, String tableName) throws IOException, InterruptedException { if (tableName.equals(Args.ALL_TABLES)) return; boolean tableExists = false; try { if (tableName.contains(Constant.TABLE_DELIMITER)) { String[] tables = tableName.split(Constant.TABLE_DELIMITER); for (String table : tables) { tableExists = admin.tableExists(table); } } else { tableExists = admin.listTables(tableName).length > 0; } } catch (Exception e) { Thread.sleep(1000); System.out.println(); System.out.println(admin.getConfiguration().get("hbase.zookeeper.quorum") + " is invalid zookeeper quorum"); System.exit(1); } if (tableExists) { try { if (!admin.isTableEnabled(tableName)) { throw new InvalidTableException("Table is not enabled."); } } catch (Exception ignore) { } } else { throw new InvalidTableException("Table does not exist."); } }
Example 12
Source File: Util.java From hbase-tools with Apache License 2.0 | 5 votes |
public static void validateTable(HBaseAdmin admin, String tableName) throws IOException, InterruptedException { if (tableName.equals(Args.ALL_TABLES)) return; boolean tableExists = false; try { if (tableName.contains(Constant.TABLE_DELIMITER)) { String[] tables = tableName.split(Constant.TABLE_DELIMITER); for (String table : tables) { tableExists = admin.tableExists(table); } } else { tableExists = admin.listTables(tableName).length > 0; } } catch (Exception e) { Thread.sleep(1000); System.out.println(); System.out.println(admin.getConfiguration().get("hbase.zookeeper.quorum") + " is invalid zookeeper quorum"); System.exit(1); } if (tableExists) { try { if (!admin.isTableEnabled(tableName)) { throw new InvalidTableException("Table is not enabled."); } } catch (Exception ignore) { } } else { throw new InvalidTableException("Table does not exist."); } }
Example 13
Source File: Util.java From hbase-tools with Apache License 2.0 | 5 votes |
public static void validateTable(HBaseAdmin admin, String tableName) throws IOException, InterruptedException { if (tableName.equals(Args.ALL_TABLES)) return; boolean tableExists = false; try { if (tableName.contains(Constant.TABLE_DELIMITER)) { String[] tables = tableName.split(Constant.TABLE_DELIMITER); for (String table : tables) { tableExists = admin.tableExists(table); } } else { tableExists = admin.listTables(tableName).length > 0; } } catch (Exception e) { Thread.sleep(1000); System.out.println(); System.out.println(admin.getConfiguration().get("hbase.zookeeper.quorum") + " is invalid zookeeper quorum"); System.exit(1); } if (tableExists) { try { if (!admin.isTableEnabled(tableName)) { throw new InvalidTableException("Table is not enabled."); } } catch (Exception ignore) { } } else { throw new InvalidTableException("Table does not exist."); } }
Example 14
Source File: Util.java From hbase-tools with Apache License 2.0 | 5 votes |
public static void validateTable(HBaseAdmin admin, String tableName) throws IOException, InterruptedException { if (tableName.equals(Args.ALL_TABLES)) return; boolean tableExists = false; try { if (tableName.contains(Constant.TABLE_DELIMITER)) { String[] tables = tableName.split(Constant.TABLE_DELIMITER); for (String table : tables) { tableExists = admin.tableExists(table); } } else { tableExists = admin.listTables(tableName).length > 0; } } catch (Exception e) { Thread.sleep(1000); System.out.println(); System.out.println(admin.getConfiguration().get("hbase.zookeeper.quorum") + " is invalid zookeeper quorum"); System.exit(1); } if (tableExists) { try { if (!admin.isTableEnabled(tableName)) { throw new InvalidTableException("Table is not enabled."); } } catch (Exception ignore) { } } else { throw new InvalidTableException("Table does not exist."); } }
Example 15
Source File: CleanHtableCLI.java From Kylin with Apache License 2.0 | 5 votes |
private void clean() throws IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); for (HTableDescriptor descriptor : hbaseAdmin.listTables()) { String name = descriptor.getNameAsString().toLowerCase(); if (name.startsWith("kylin") || name.startsWith("_kylin")) { String x = descriptor.getValue("KYLIN_HOST"); System.out.println("table name " + descriptor.getNameAsString() + " host: " + x); System.out.println(descriptor); System.out.println(); } } hbaseAdmin.close(); }
Example 16
Source File: ExportHBaseData.java From Kylin with Apache License 2.0 | 5 votes |
private void setup() throws IOException { long currentTIME = System.currentTimeMillis(); exportFolder = "/tmp/hbase-export/" + currentTIME + "/"; backupArchive = "/tmp/kylin_" + currentTIME + ".tar.gz"; KylinConfig.destoryInstance(); System.setProperty(KylinConfig.KYLIN_CONF, AbstractKylinTestCase.SANDBOX_TEST_DATA); kylinConfig = KylinConfig.getInstanceFromEnv(); cli = kylinConfig.getCliCommandExecutor(); String metadataUrl = kylinConfig.getMetadataUrl(); // split TABLE@HBASE_URL int cut = metadataUrl.indexOf('@'); tableNameBase = metadataUrl.substring(0, cut); String hbaseUrl = cut < 0 ? metadataUrl : metadataUrl.substring(cut + 1); HConnection conn = HBaseConnection.get(hbaseUrl); try { hbase = new HBaseAdmin(conn); config = hbase.getConfiguration(); allTables = hbase.listTables(); } catch (IOException e) { e.printStackTrace(); throw e; } }