标签:
让运维加监控,被问到Requests Per Second(见下图)的具体含义是什么?我一时竟回答不上来,虽然大概知道它是指每秒Region Server的请求数,但是具体是怎么算的呢,不清楚。于是决定通过研究源码深入了解下。下面便记录了这个过程。
1 <%java> 2 int totalRegions = 0; 3 int totalRequests = 0; 4 for (ServerName serverName: serverNames) { 5 6 ServerLoad sl = master.getServerManager().getLoad(serverName); 7 double requestsPerSecond = 0.0; 8 int numRegionsOnline = 0; 9 10 if (sl != null) { 11 requestsPerSecond = sl.getRequestsPerSecond(); 12 numRegionsOnline = sl.getNumberOfRegions(); 13 totalRegions += sl.getNumberOfRegions(); 14 // Is this correct? Adding a rate to a measure. 15 totalRequests += sl.getNumberOfRequests(); 16 } 17 long startcode = serverName.getStartcode(); 18 </%java>
其中requestsPerSecond变量的值就是我们要找的。可以看出来是来自ServerLoad中的getRequestsPerSecond函数。
1 serverLoad.setNumberOfRequests((int) regionServerWrapper.getRequestsPerSecond());
if (lastRan == 0) { lastRan = currentTime - period; } //If we‘ve time traveled keep the last requests per second. if ((currentTime - lastRan) > 0) { long currentRequestCount = getTotalRequestCount(); requestsPerSecond = (currentRequestCount - lastRequestCount) / ((currentTime - lastRan) / 1000.0); lastRequestCount = currentRequestCount; } lastRan = currentTime;
Hbase源码分析:Hbase UI中Requests Per Second的具体含义
标签:
原文地址:http://www.cnblogs.com/stevendes/p/5908295.html