尝试这三种方式
第一种:通过hdfs
查看Hbase根目录.
[hadoop@HADOOPCLUS01 bin]$ hadoop fs -ls hadoop fs -ls /hbase
Found 37 items
drwxr-xr-x - hadoop cug-admin 0 2013-03-27 09:29 /hbase/-ROOT-
drwxr-xr-x - hadoop cug-admin 0 2013-03-27 09:29 /hbase/.META.
drwxr-xr-x - hadoop cug-admin 0 2013-03-26 13:15 /hbase/.corrupt
drwxr-xr-x - hadoop cug-admin 0 2013-03-27 09:48 /hbase/.logs
drwxr-xr-x - hadoop cug-admin 0 2013-03-30 17:49 /hbase/.oldlogs
drwxr-xr-x - hadoop cug-admin 0 2013-03-30 17:49 /hbase/splitlog
drwxr-xr-x - hadoop cug-admin 0 2013-03-30 17:49 /hbase/USER_TEST_TABLE
第二种通过hbase shell
第三种通过代码:
- private HRegionLocation locateRegion(final byte [] tableName,
- final byte [] row, boolean useCache)
- throws IOException {
- .......
- //检查下都应的zkTracker是否启动
- ensureZookeeperTrackers();
- //如果是-ROOT-表,则通过zk节点/hbase/root-region-server获取-ROOT-表所在的Location
- if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
- try {
- //通过zk的getData接口拿节点数据,此处会等待节点数据就位或者超时
- ServerName servername = this.rootRegionTracker.waitRootRegionLocation(this.rpcTimeout);
- LOG.debug("Looked up root region location, connection=" + this +
- "; serverName=" + ((servername == null)? "": servername.toString()));
- if (servername == null) return null;
- //返回一个拼装的HRegionLocation,因为-ROOT-表只有一个region,而且不会split
- return new HRegionLocation(HRegionInfo.ROOT_REGIONINFO,
- servername.getHostname(), servername.getPort());
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- return null;
- }
- }
- //如果是.META.表,则请求.META.表,这里的row其实就是请求row拼装的regionName,类似test,key1,99999999999999
- //如果没命中cache,则继续请求-ROOT-表,拿到这个row对应的.META.表的region location
- else if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
- return locateRegionInMeta(HConstants.ROOT_TABLE_NAME, tableName, row,
- useCache, metaRegionLock);
- }
- //如果是用户表,则请求用户表,这里的row就是key1
- //如果没命中cache,则请求.META.表,获取该row对应的region location
- else {
- // Region not in the cache - have to go to the meta RS
- return locateRegionInMeta(HConstants.META_TABLE_NAME, tableName, row,
- useCache, userRegionLock);
- }
- }
复制代码
|