本文整理匯總了Java中org.apache.hadoop.hbase.client.HBaseAdmin.listTables方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseAdmin.listTables方法的具體用法?Java HBaseAdmin.listTables怎麽用?Java HBaseAdmin.listTables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HBaseAdmin
的用法示例。
在下文中一共展示了HBaseAdmin.listTables方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
HBaseAdmin admin = testutil.getHBaseAdmin();
if (!admin.tableExists(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(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME)) {
admin.enableTable(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME);
}
HTableDescriptor[] tables = admin.listTables();
for (HTableDescriptor t : tables) {
LOG.info(t.getNameAsString());
}
}
示例2: getTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Gets a handle of a specific table.
* @param tableName of the table to be accessed.
* @return HTable of the table found.
*/
@Override
public HTable getTable(String tableName) {
logger.debug("NATIVE Begin of getTable for " + tableName);
HTable table = tableNameHandleMap.get(tableName);
if (table != null) {
logger.debug("NATIVE Found a cached handle for table " + tableName);
return table;
}
try {
logger.debug("NATIVE Looking for a handle of table: " + tableName);
HBaseAdmin admin = new HBaseAdmin(this.getHbcfg());
HTableDescriptor[] resources = admin.listTables(tableName);
Preconditions.checkElementIndex(0, resources.length, "no table " + tableName + " found");
admin.close();
table = new HTable(this.getHbcfg(), tableName);
} catch (IOException e) {
logger.error("NATIVE Error while trying to obtain table: " + tableName);
logger.error(e.getMessage());
};
tableNameHandleMap.put(tableName, table);
logger.debug("NATIVE Cached a handle of table: " + tableName);
return table;
}
示例3: parseTables
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
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());
}
}
}
示例4: truncateAllTables
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Truncates all tables
* @throws Exception
*/
public void truncateAllTables() throws Exception {
HBaseAdmin admin = htu.getHBaseAdmin();
for(HTableDescriptor table:admin.listTables()) {
htu.truncateTable(table.getName());
}
}
示例5: setUp
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
HBaseAdmin admin = testutil.getHBaseAdmin();
if (!admin.tableExists(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);
desc.addCoprocessor("org.apache.hadoop.hbase.coprocessor.AggregateImplementation");
admin.createTable(desc);
}
if (admin.isTableDisabled(TEST_TABLE)) {
admin.enableTable(TEST_TABLE);
}
HTableDescriptor[] tables = admin.listTables();
for (HTableDescriptor t : tables) {
LOG.info(t.getNameAsString());
}
}
示例6: deleteAllTables
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Delete all tables
* @throws Exception
*/
public void deleteAllTables() throws Exception {
HBaseAdmin admin = htu.getHBaseAdmin();
for(HTableDescriptor table:admin.listTables()) {
admin.disableTable(table.getName());
admin.deleteTable(table.getName());
}
}
示例7: validateTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
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.");
}
}
示例8: listTables
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
// 50 times: 2995 mills.
public void listTables() throws Exception {
int count = 50;
//
long beg = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
HBaseAdmin admin = createHBaseAdmin(createConfiguration());
System.out.println(admin);
//
HTableDescriptor[] htds = admin.listTables();
for (HTableDescriptor htd : htds) {
StringBuilder buffer = new StringBuilder();
buffer.append("[");
buffer.append(htd.getNameAsString());
buffer.append("] ");
HColumnDescriptor[] hcds = htd.getColumnFamilies();
for (int j = 0; j < hcds.length; j++) {
buffer.append(hcds[j].getNameAsString());
if (j < hcds.length - 1) {
buffer.append(", ");
}
}
//
System.out.println(buffer);
}
admin.close();
}
long end = System.currentTimeMillis();
System.out.println(count + " times: " + (end - beg) + " mills. ");
}
示例9: listTables
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
// 50 times: 3376 mills.
public void listTables() throws Exception {
int count = 50;
//
long beg = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
HConnection hconnection = hzDataSource.getHConnection();
HBaseAdmin admin = new HBaseAdmin(hconnection);
System.out.println(admin);
//
HTableDescriptor[] htds = admin.listTables();
for (HTableDescriptor htd : htds) {
StringBuilder buffer = new StringBuilder();
buffer.append("[");
buffer.append(htd.getNameAsString());
buffer.append("] ");
HColumnDescriptor[] hcds = htd.getColumnFamilies();
for (int j = 0; j < hcds.length; j++) {
buffer.append(hcds[j].getNameAsString());
if (j < hcds.length - 1) {
buffer.append(", ");
}
}
//
System.out.println(buffer);
}
admin.close();
}
long end = System.currentTimeMillis();
System.out.println(count + " times: " + (end - beg) + " mills. ");
}