HBASE-11387 metrics: wrong totalRequestCount

This commit is contained in:
Nicolas Liochon 2014-06-24 11:21:12 +02:00
parent af9e519e00
commit b2914be9d3
3 changed files with 38 additions and 15 deletions

View File

@ -2269,8 +2269,8 @@ public class HRegion implements HeapSize { // , Writable{
try {
if (!initialized) {
this.writeRequestsCount.add(batchOp.operations.length);
if (!batchOp.isInReplay()) {
this.writeRequestsCount.increment();
doPreMutationHook(batchOp);
}
initialized = true;

View File

@ -580,7 +580,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
mArray[i++] = mutation;
}
requestCount.add(mutations.size());
if (!region.getRegionInfo().isMetaTable()) {
regionServer.cacheFlusher.reclaimMemStoreMemory();
}

View File

@ -32,6 +32,8 @@ import org.junit.experimental.categories.Category;
import static org.junit.Assert.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Category(MediumTests.class)
@ -106,30 +108,36 @@ public class TestRegionServerMetrics {
TEST_UTIL.createTable(tName, cfName);
new HTable(conf, tName).close(); //wait for the table to come up.
// Do a first put to be sure that the connection is established, meta is there and so on.
HTable table = new HTable(conf, tName);
Put p = new Put(row);
p.add(cfName, qualifier, initValue);
table.put(p);
metricsRegionServer.getRegionServerWrapper().forceRecompute();
long requests = metricsHelper.getCounter("totalRequestCount", serverSource);
long readRequests = metricsHelper.getCounter("readRequestCount", serverSource);
long writeRequests = metricsHelper.getCounter("writeRequestCount", serverSource);
HTable table = new HTable(conf, tName);
Put p = new Put(row);
p.add(cfName, qualifier, initValue);
for (int i=0; i< 30; i++) {
table.put(p);
}
table.flushCommits();
metricsRegionServer.getRegionServerWrapper().forceRecompute();
metricsHelper.assertCounter("totalRequestCount", requests + 30, serverSource);
metricsHelper.assertCounter("readRequestCount", readRequests, serverSource);
metricsHelper.assertCounter("writeRequestCount", writeRequests + 30, serverSource);
Get g = new Get(row);
for (int i=0; i< 10; i++) {
table.get(g);
}
metricsRegionServer.getRegionServerWrapper().forceRecompute();
metricsHelper.assertCounter("totalRequestCount", requests + 40, serverSource);
metricsHelper.assertCounter("readRequestCount", readRequests + 10, serverSource);
metricsHelper.assertCounter("writeRequestCount", writeRequests + 30, serverSource);
for ( HRegionInfo i:table.getRegionLocations().keySet()) {
MetricsRegionAggregateSource agg = rs.getRegion(i.getRegionName())
@ -141,14 +149,30 @@ public class TestRegionServerMetrics {
"_region_" + i.getEncodedName()+
"_metric";
metricsHelper.assertCounter(prefix + "_getNumOps", 10, agg);
metricsHelper.assertCounter(prefix + "_mutateCount", 30, agg);
metricsHelper.assertCounter(prefix + "_mutateCount", 31, agg);
}
List<Get> gets = new ArrayList<Get>();
for (int i=0; i< 10; i++) {
gets.add(new Get(row));
}
table.get(gets);
metricsRegionServer.getRegionServerWrapper().forceRecompute();
metricsHelper.assertCounterGt("totalRequestCount", requests + 39, serverSource);
metricsHelper.assertCounterGt("readRequestCount", readRequests + 9, serverSource);
metricsHelper.assertCounterGt("writeRequestCount", writeRequests + 29, serverSource);
metricsHelper.assertCounter("totalRequestCount", requests + 50, serverSource);
metricsHelper.assertCounter("readRequestCount", readRequests + 20, serverSource);
metricsHelper.assertCounter("writeRequestCount", writeRequests + 30, serverSource);
table.setAutoFlushTo(false);
for (int i=0; i< 30; i++) {
table.put(p);
}
table.flushCommits();
metricsRegionServer.getRegionServerWrapper().forceRecompute();
metricsHelper.assertCounter("totalRequestCount", requests + 80, serverSource);
metricsHelper.assertCounter("readRequestCount", readRequests + 20, serverSource);
metricsHelper.assertCounter("writeRequestCount", writeRequests + 60, serverSource);
table.close();
}