HBASE-4304 requestsPerSecond counter stuck at 0
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1190167 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0e83d7445d
commit
91090148f7
|
@ -415,6 +415,7 @@ Release 0.92.0 - Unreleased
|
||||||
HBASE-4300 Start of new-version master fails if old master's znode is
|
HBASE-4300 Start of new-version master fails if old master's znode is
|
||||||
hanging around
|
hanging around
|
||||||
HBASE-4679 Thrift null mutation error
|
HBASE-4679 Thrift null mutation error
|
||||||
|
HBASE-4304 requestsPerSecond counter stuck at 0 (Li Pi)
|
||||||
|
|
||||||
TESTS
|
TESTS
|
||||||
HBASE-4450 test for number of blocks read: to serve as baseline for expected
|
HBASE-4450 test for number of blocks read: to serve as baseline for expected
|
||||||
|
|
|
@ -56,10 +56,14 @@ public class MetricsRate extends MetricsBase {
|
||||||
value++;
|
value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void intervalHeartBeat() {
|
public synchronized void intervalHeartBeat() {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long diff = (now-ts)/1000;
|
long diff = (now-ts) / 1000;
|
||||||
if (diff == 0) diff = 1; // sigh this is crap.
|
if (diff < 1){
|
||||||
|
// To make sure our averages aren't skewed by fast repeated calls,
|
||||||
|
// we simply ignore fast repeated calls.
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.prevRate = (float)value / diff;
|
this.prevRate = (float)value / diff;
|
||||||
this.value = 0;
|
this.value = 0;
|
||||||
this.ts = now;
|
this.ts = now;
|
||||||
|
|
|
@ -1018,7 +1018,6 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
||||||
/**
|
/**
|
||||||
* @param encodedRegionName
|
* @param encodedRegionName
|
||||||
* @return An instance of RegionLoad.
|
* @return An instance of RegionLoad.
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public HServerLoad.RegionLoad createRegionLoad(final String encodedRegionName) {
|
public HServerLoad.RegionLoad createRegionLoad(final String encodedRegionName) {
|
||||||
HRegion r = null;
|
HRegion r = null;
|
||||||
|
@ -1275,6 +1274,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
||||||
protected void metrics() {
|
protected void metrics() {
|
||||||
this.metrics.regions.set(this.onlineRegions.size());
|
this.metrics.regions.set(this.onlineRegions.size());
|
||||||
this.metrics.incrementRequests(this.requestCount.get());
|
this.metrics.incrementRequests(this.requestCount.get());
|
||||||
|
this.metrics.requests.intervalHeartBeat();
|
||||||
// Is this too expensive every three seconds getting a lock on onlineRegions
|
// Is this too expensive every three seconds getting a lock on onlineRegions
|
||||||
// and then per store carried? Can I make metrics be sloppier and avoid
|
// and then per store carried? Can I make metrics be sloppier and avoid
|
||||||
// the synchronizations?
|
// the synchronizations?
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class RegionServerMetrics implements Updater {
|
||||||
/*
|
/*
|
||||||
* Count of requests to the regionservers since last call to metrics update
|
* Count of requests to the regionservers since last call to metrics update
|
||||||
*/
|
*/
|
||||||
private final MetricsRate requests = new MetricsRate("requests", registry);
|
public final MetricsRate requests = new MetricsRate("requests", registry);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count of stores open on the regionserver.
|
* Count of stores open on the regionserver.
|
||||||
|
|
|
@ -70,6 +70,7 @@ public class TestMetricsMBeanBase extends TestCase {
|
||||||
|
|
||||||
public void testGetAttribute() throws Exception {
|
public void testGetAttribute() throws Exception {
|
||||||
this.metricsRate.inc(2);
|
this.metricsRate.inc(2);
|
||||||
|
Thread.sleep(1000);
|
||||||
this.metricsRate.pushMetric(this.metricsRecord);
|
this.metricsRate.pushMetric(this.metricsRecord);
|
||||||
this.intValue.set(5);
|
this.intValue.set(5);
|
||||||
this.intValue.pushMetric(this.metricsRecord);
|
this.intValue.pushMetric(this.metricsRecord);
|
||||||
|
@ -78,7 +79,7 @@ public class TestMetricsMBeanBase extends TestCase {
|
||||||
this.varyRate.pushMetric(this.metricsRecord);
|
this.varyRate.pushMetric(this.metricsRecord);
|
||||||
|
|
||||||
|
|
||||||
assertEquals( 2.0, (Float)this.stats.getAttribute("metricsRate"), 0.001 );
|
assertEquals( 2.0, (Float)this.stats.getAttribute("metricsRate"), 0.005 );
|
||||||
assertEquals( 5, this.stats.getAttribute("intValue") );
|
assertEquals( 5, this.stats.getAttribute("intValue") );
|
||||||
assertEquals( 10L, this.stats.getAttribute("varyRateMinTime") );
|
assertEquals( 10L, this.stats.getAttribute("varyRateMinTime") );
|
||||||
assertEquals( 50L, this.stats.getAttribute("varyRateMaxTime") );
|
assertEquals( 50L, this.stats.getAttribute("varyRateMaxTime") );
|
||||||
|
|
Loading…
Reference in New Issue