用于获取HBase区域指标的API

时间:2013-07-01 23:16:31

标签: hbase

我想获取特定区域服务器上所有区域的区域指标。特别是,我在readRequestsCount和writeRequestsCount之后。我在区域服务器Web界面中看到了这些值,但我无法找到对这些值的API访问。

2 个答案:

答案 0 :(得分:2)

看看RegionServerMetrics课程。它提供了readRequestsCountwriteRequestsCount方法。

答案 1 :(得分:2)

我在Scala中的解决方案的关键:

val config = new Configuration()
config.set("hbase.zookeeper.quorum", /* put your own entry here */)

val admin = new HBaseAdmin(config)
val master = admin.getMaster
val servers = master.getClusterStatus.getServers

for(server <- servers){
  val load = master.getClusterStatus.getLoad(server)
  val rloads = load.getRegionsLoad
  for ((k,rload) <- rloads){

    // Do whatever you please with these values
    var region = Bytes.toString(k)
    val host = server.getHostname
    val reads = rload.getReadRequestsCount
    val writes = rload.getWriteRequestsCount
  }
}