hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nkey...@apache.org
Subject git commit: HBASE-11387 metrics: wrong totalRequestCount
Date Tue, 24 Jun 2014 09:21:15 GMT
Repository: hbase
Updated Branches:
  refs/heads/master af9e519e0 -> b2914be9d


HBASE-11387 metrics: wrong totalRequestCount


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b2914be9
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b2914be9
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b2914be9

Branch: refs/heads/master
Commit: b2914be9d32876a5a3337bcfed7dc68c5b7e7a98
Parents: af9e519
Author: Nicolas Liochon <nkeywal@gmail.com>
Authored: Tue Jun 24 11:21:12 2014 +0200
Committer: Nicolas Liochon <nkeywal@gmail.com>
Committed: Tue Jun 24 11:21:12 2014 +0200

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/HRegion.java      |  2 +-
 .../hbase/regionserver/RSRpcServices.java       |  1 -
 .../regionserver/TestRegionServerMetrics.java   | 50 +++++++++++++++-----
 3 files changed, 38 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/b2914be9/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 5b7d41d..309d0c0 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/b2914be9/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index 4d133c3..e94c506 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -580,7 +580,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
         mArray[i++] = mutation;
       }
 
-      requestCount.add(mutations.size());
       if (!region.getRegionInfo().isMetaTable()) {
         regionServer.cacheFlusher.reclaimMemStoreMemory();
       }

http://git-wip-us.apache.org/repos/asf/hbase/blob/b2914be9/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
index eacdecb..99ea553 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
@@ -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.
-    metricsRegionServer.getRegionServerWrapper().forceRecompute();
-    long requests = metricsHelper.getCounter("totalRequestCount", serverSource);
-    long readRequests = metricsHelper.getCounter("readRequestCount", serverSource);
-    long writeRequests = metricsHelper.getCounter("writeRequestCount", serverSource);
 
+    // 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);
 
     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.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.assertCounterGt("totalRequestCount", requests + 39, serverSource);
-    metricsHelper.assertCounterGt("readRequestCount", readRequests + 9, serverSource);
-    metricsHelper.assertCounterGt("writeRequestCount", writeRequests + 29, serverSource);
+    metricsHelper.assertCounter("totalRequestCount", requests + 80, serverSource);
+    metricsHelper.assertCounter("readRequestCount", readRequests + 20, serverSource);
+    metricsHelper.assertCounter("writeRequestCount", writeRequests + 60, serverSource);
 
     table.close();
   }


Mime
View raw message