当前位置: 首页>>代码示例>>Java>>正文


Java HBaseAdmin.listTables方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:22,代码来源:TestHBaseTimestampStorage.java

示例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;
   }
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:29,代码来源:HBaseUtils.java

示例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());
        }
    }
}
 
开发者ID:kakao,项目名称:hbase-tools,代码行数:18,代码来源:SnapshotArgs.java

示例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());
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:11,代码来源:HBaseClusterSingleton.java

示例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());
    }
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:28,代码来源:TestHBaseCommitTable.java

示例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());
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:12,代码来源:HBaseClusterSingleton.java

示例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.");
    }
}
 
开发者ID:kakao,项目名称:hbase-tools,代码行数:31,代码来源:Util.java

示例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. ");
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:32,代码来源:HBaseAdminTest.java

示例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. ");
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:33,代码来源:HzDataSourceImplTest.java


注:本文中的org.apache.hadoop.hbase.client.HBaseAdmin.listTables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。