通过API获取Hbase区域大小 [英] Get Hbase region size via API

查看:915
本文介绍了通过API获取Hbase区域大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Hbase编写一个平衡器工具,它可以按区域计数和/或区域大小(storeFile大小的总和)来平衡整个regionServers中的区域。我找不到任何返回区域大小或相关信息的Hbase API类。我已经检查了可用于获取其他表/区域信息的一些类。 org.apache.hadoop.hbase.client.HTable和HBaseAdmin。



我在想,另一种可以实现的方法是使用其中一个Hadoop类,它返回文件系统中目录的大小,例如org.apache.hadoop.fs.FileSystem列出特定HDFS路径下的文件。



有何建议?

解决方案

我使用它来完成区域的托管拆分,但是,您可以利用它来自行进行负载平衡。我还负载平衡自己,以便将各个区域(给定的表格)均匀地分布在节点上,以便MR作业均匀分布。 可能下面的代码片段是有用吗?

 最终HBaseAdmin admin = new HBaseAdmin(conf); 
final ClusterStatus clusterStatus = admin.getClusterStatus(); (ServerName serverName:clusterStatus.getServers()){
final HServerLoad serverLoad = clusterStatus.getLoad(serverName);

(Map.Entry< byte [],HServerLoad.RegionLoad>条目:serverLoad.getRegionsLoad()。entrySet()){
final String region = Bytes.toString(entry.getKey)为

。 ());
final HServerLoad.RegionLoad regionLoad = entry.getValue();
long storeFileSize = regionLoad.getStorefileSizeMB();
// region中的其他有用物品如果您喜欢
}
}


I am trying to write a balancer tool for Hbase which could balance regions across regionServers for a table by region count and/or region size (sum of storeFile sizes). I could not find any Hbase API class which returns the regions size or related info. I have already checked a few of the classes which could be used to get other table/region info, e.g. org.apache.hadoop.hbase.client.HTable and HBaseAdmin.

I am thinking, another way this could be implemented is by using one of the Hadoop classes which returns the size of the directories in the fileSystem, for e.g. org.apache.hadoop.fs.FileSystem lists the files under a particular HDFS path.

Any suggestions ?

解决方案

I use this to do managed splits of regions, but, you could leverage it to load-balance on your own. I also load-balance myself to spread the regions ( of a given table ) evenly across our nodes so that MR jobs are evenly distributed.

Perhaps the code-snippet below is useful?

final HBaseAdmin admin = new HBaseAdmin(conf);
final ClusterStatus clusterStatus = admin.getClusterStatus();

for (ServerName serverName : clusterStatus.getServers()) {
  final HServerLoad serverLoad = clusterStatus.getLoad(serverName);

  for (Map.Entry<byte[], HServerLoad.RegionLoad> entry : serverLoad.getRegionsLoad().entrySet()) {
    final String region = Bytes.toString(entry.getKey());
    final HServerLoad.RegionLoad regionLoad = entry.getValue();
    long storeFileSize = regionLoad.getStorefileSizeMB();
    // other useful thing in regionLoad if you like
  }
}

这篇关于通过API获取Hbase区域大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆