【发布时间】:2014-12-23 14:52:50
【问题描述】:
我正在尝试使用 HBase API 为“表”获取“区域名称”。
设置如下:
Hbase 伪分布式安装(0.98.7 版本)。
Hadoop 2.5.1 安装。
Hbase 包含非常少的用于测试目的的表。可用区域的相关信息显示在 Web UI 的下方。
“test_table”表对应的“区域名称”已被特意高亮显示。
现在,我一直在尝试使用以下代码从基于 java 的 hbase API 获取这些区域信息。
void scanTable(String tabName){
org.apache.hadoop.conf.Configuration config = HBaseConfiguration.create();
try{
HTable table = new HTable(config, tabName);
org.apache.hadoop.hbase.TableName tn = table.getName();
HRegionInfo hr = new HRegionInfo(tn);
System.out.println(hr.getRegionNameAsString());
table.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
每当我传递一个表名,比如“test_table”,每次运行时返回的 regionName 都会不同。
运行 1:
test_table,,1419247657866.77b98d085239ed8668596ea659a7ad7d.
运行 2:
test_table,,1419247839479.d3097b0f4b407ca827e9fa3773b4d7c7.
运行 3:
test_table,,1419247859921.e1e39678fa724d7168cd4100289c4234.
我假设我使用了错误的方法来生成“region_name”或者我的方法是错误的。 请帮我获取给定表名的区域信息。
【问题讨论】: