hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From achou...@apache.org
Subject hbase git commit: HBASE-18374 RegionServer Metrics improvements
Date Mon, 31 Jul 2017 07:15:36 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2 8fc010636 -> 08b5a4b2c


HBASE-18374 RegionServer Metrics improvements


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

Branch: refs/heads/branch-2
Commit: 08b5a4b2c68823d2a555d4b92f65cb58666e0bd9
Parents: 8fc0106
Author: Abhishek Singh Chouhan <achouhan@apache.org>
Authored: Fri Jul 28 19:01:42 2017 +0530
Committer: Abhishek Singh Chouhan <achouhan@apache.org>
Committed: Mon Jul 31 12:44:27 2017 +0530

----------------------------------------------------------------------
 .../regionserver/MetricsRegionServerSource.java | 38 +++++++++++++++++---
 .../MetricsRegionServerSourceImpl.java          | 33 +++++++++++++++--
 .../regionserver/MetricsRegionSourceImpl.java   |  2 +-
 .../hbase/regionserver/MetricsRegionServer.java | 20 +++++++++--
 .../hbase/regionserver/RSRpcServices.java       | 35 +++++++++++++++---
 .../regionserver/TestMetricsRegionServer.java   | 23 ++++++++----
 .../regionserver/TestRegionServerMetrics.java   |  2 +-
 .../regionserver/TestRemoveRegionMetrics.java   |  4 +--
 8 files changed, 133 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/08b5a4b2/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java
b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java
index 0e7dd8d..df522d3 100644
--- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java
+++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java
@@ -54,6 +54,12 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
   void updatePut(long t);
 
   /**
+   * Update the PutBatch time histogram if a batch contains a Put op
+   * @param t
+   */
+  void updatePutBatch(long t);
+
+  /**
    * Update the Delete time histogram
    *
    * @param t time it took
@@ -61,6 +67,24 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
   void updateDelete(long t);
 
   /**
+   * Update the Delete time histogram if a batch contains a delete op
+   * @param t time it took
+   */
+  void updateDeleteBatch(long t);
+
+  /**
+   * Update checkAndDelete histogram
+   * @param t time it took
+   */
+  void updateCheckAndDelete(long t);
+
+  /**
+   * Update checkAndPut histogram
+   * @param t time it took
+   */
+  void updateCheckAndPut(long t);
+
+  /**
    * Update the Get time histogram .
    *
    * @param t time it took
@@ -334,25 +358,29 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
   String UPDATES_BLOCKED_DESC =
       "Number of MS updates have been blocked so that the memstore can be flushed.";
   String DELETE_KEY = "delete";
+  String CHECK_AND_DELETE_KEY = "checkAndDelete";
+  String CHECK_AND_PUT_KEY = "checkAndPut";
+  String DELETE_BATCH_KEY = "deleteBatch";
   String GET_SIZE_KEY = "getSize";
   String GET_KEY = "get";
   String INCREMENT_KEY = "increment";
-  String MUTATE_KEY = "mutate";
+  String PUT_KEY = "put";
+  String PUT_BATCH_KEY = "putBatch";
   String APPEND_KEY = "append";
   String REPLAY_KEY = "replay";
   String SCAN_KEY = "scan";
   String SCAN_SIZE_KEY = "scanSize";
   String SCAN_TIME_KEY = "scanTime";
 
-  String SLOW_MUTATE_KEY = "slowPutCount";
+  String SLOW_PUT_KEY = "slowPutCount";
   String SLOW_GET_KEY = "slowGetCount";
   String SLOW_DELETE_KEY = "slowDeleteCount";
   String SLOW_INCREMENT_KEY = "slowIncrementCount";
   String SLOW_APPEND_KEY = "slowAppendCount";
-  String SLOW_MUTATE_DESC =
-      "The number of Multis that took over 1000ms to complete";
+  String SLOW_PUT_DESC =
+      "The number of batches containing puts that took over 1000ms to complete";
   String SLOW_DELETE_DESC =
-      "The number of Deletes that took over 1000ms to complete";
+      "The number of batches containing delete(s) that took over 1000ms to complete";
   String SLOW_GET_DESC = "The number of Gets that took over 1000ms to complete";
   String SLOW_INCREMENT_DESC =
       "The number of Increments that took over 1000ms to complete";

http://git-wip-us.apache.org/repos/asf/hbase/blob/08b5a4b2/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
index 67764f8..94b21bc 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
@@ -37,7 +37,11 @@ public class MetricsRegionServerSourceImpl
 
   final MetricsRegionServerWrapper rsWrap;
   private final MetricHistogram putHisto;
+  private final MetricHistogram putBatchHisto;
   private final MetricHistogram deleteHisto;
+  private final MetricHistogram deleteBatchHisto;
+  private final MetricHistogram checkAndDeleteHisto;
+  private final MetricHistogram checkAndPutHisto;
   private final MetricHistogram getHisto;
   private final MetricHistogram incrementHisto;
   private final MetricHistogram appendHisto;
@@ -97,12 +101,17 @@ public class MetricsRegionServerSourceImpl
     super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
     this.rsWrap = rsWrap;
 
-    putHisto = getMetricsRegistry().newTimeHistogram(MUTATE_KEY);
-    slowPut = getMetricsRegistry().newCounter(SLOW_MUTATE_KEY, SLOW_MUTATE_DESC, 0L);
+    putHisto = getMetricsRegistry().newTimeHistogram(PUT_KEY);
+    putBatchHisto = getMetricsRegistry().newTimeHistogram(PUT_BATCH_KEY);
+    slowPut = getMetricsRegistry().newCounter(SLOW_PUT_KEY, SLOW_PUT_DESC, 0L);
 
     deleteHisto = getMetricsRegistry().newTimeHistogram(DELETE_KEY);
     slowDelete = getMetricsRegistry().newCounter(SLOW_DELETE_KEY, SLOW_DELETE_DESC, 0L);
 
+    deleteBatchHisto = getMetricsRegistry().newTimeHistogram(DELETE_BATCH_KEY);
+    checkAndDeleteHisto = getMetricsRegistry().newTimeHistogram(CHECK_AND_DELETE_KEY);
+    checkAndPutHisto = getMetricsRegistry().newTimeHistogram(CHECK_AND_PUT_KEY);
+
     getHisto = getMetricsRegistry().newTimeHistogram(GET_KEY);
     slowGet = getMetricsRegistry().newCounter(SLOW_GET_KEY, SLOW_GET_DESC, 0L);
 
@@ -537,4 +546,24 @@ public class MetricsRegionServerSourceImpl
   public void updatePauseTimeWithoutGc(long t) {
     pausesWithoutGc.add(t);
   }
+
+  @Override
+  public void updateDeleteBatch(long t) {
+    deleteBatchHisto.add(t);
+  }
+
+  @Override
+  public void updateCheckAndDelete(long t) {
+    checkAndDeleteHisto.add(t);
+  }
+
+  @Override
+  public void updateCheckAndPut(long t) {
+    checkAndPutHisto.add(t);
+  }
+
+  @Override
+  public void updatePutBatch(long t) {
+    putBatchHisto.add(t);
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/08b5a4b2/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
index 0570a34..b843b03 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
@@ -83,7 +83,7 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
 
     String suffix = "Count";
 
-    regionPutKey = regionNamePrefix + MetricsRegionServerSource.MUTATE_KEY + suffix;
+    regionPutKey = regionNamePrefix + MetricsRegionServerSource.PUT_KEY + suffix;
     regionPut = registry.getCounter(regionPutKey, 0L);
 
     regionDeleteKey = regionNamePrefix + MetricsRegionServerSource.DELETE_KEY + suffix;

http://git-wip-us.apache.org/repos/asf/hbase/blob/08b5a4b2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
index b230fa8..f42721b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
@@ -71,18 +71,34 @@ public class MetricsRegionServer {
     return regionServerWrapper;
   }
 
-  public void updatePut(long t) {
+  public void updatePutBatch(long t) {
     if (t > 1000) {
       serverSource.incrSlowPut();
     }
+    serverSource.updatePutBatch(t);
+  }
+
+  public void updatePut(long t) {
     serverSource.updatePut(t);
   }
 
   public void updateDelete(long t) {
+    serverSource.updateDelete(t);
+  }
+
+  public void updateDeleteBatch(long t) {
     if (t > 1000) {
       serverSource.incrSlowDelete();
     }
-    serverSource.updateDelete(t);
+    serverSource.updateDeleteBatch(t);
+  }
+
+  public void updateCheckAndDelete(long t) {
+    serverSource.updateCheckAndDelete(t);
+  }
+
+  public void updateCheckAndPut(long t) {
+    serverSource.updateCheckAndPut(t);
   }
 
   public void updateGet(long t) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/08b5a4b2/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 0067d15..bc196a6 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
@@ -1029,10 +1029,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
     if (regionServer.metricsRegionServer != null) {
       long after = EnvironmentEdgeManager.currentTime();
       if (batchContainsPuts) {
-        regionServer.metricsRegionServer.updatePut(after - before);
+        regionServer.metricsRegionServer.updatePutBatch(after - before);
       }
       if (batchContainsDelete) {
-        regionServer.metricsRegionServer.updateDelete(after - before);
+        regionServer.metricsRegionServer.updateDeleteBatch(after - before);
       }
     }
   }
@@ -1104,10 +1104,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
       if (regionServer.metricsRegionServer != null) {
         long after = EnvironmentEdgeManager.currentTime();
           if (batchContainsPuts) {
-          regionServer.metricsRegionServer.updatePut(after - before);
+          regionServer.metricsRegionServer.updatePutBatch(after - before);
         }
         if (batchContainsDelete) {
-          regionServer.metricsRegionServer.updateDelete(after - before);
+          regionServer.metricsRegionServer.updateDeleteBatch(after - before);
         }
       }
     }
@@ -2681,6 +2681,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
     OperationQuota quota = null;
     RpcCallContext context = RpcServer.getCurrentCall();
     ActivePolicyEnforcement spaceQuotaEnforcement = null;
+    MutationType type = null;
+    long before = EnvironmentEdgeManager.currentTime();
     // Clear scanner so we are not holding on to reference across call.
     if (controller != null) {
       controller.setCellScanner(null);
@@ -2698,7 +2700,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
       long nonceGroup = request.hasNonceGroup() ? request.getNonceGroup() : HConstants.NO_NONCE;
       Result r = null;
       Boolean processed = null;
-      MutationType type = mutation.getMutateType();
+      type = mutation.getMutateType();
 
       quota = getRpcQuotaManager().checkQuota(region, OperationQuota.OperationType.MUTATE);
       spaceQuotaEnforcement = getSpaceQuotaManager().getActiveEnforcements();
@@ -2795,6 +2797,29 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
       if (quota != null) {
         quota.close();
       }
+      // Update metrics
+      if (regionServer.metricsRegionServer != null && type != null) {
+        long after = EnvironmentEdgeManager.currentTime();
+        switch (type) {
+        case DELETE:
+          if (request.hasCondition()) {
+            regionServer.metricsRegionServer.updateCheckAndDelete(after - before);
+          } else {
+            regionServer.metricsRegionServer.updateDelete(after - before);
+          }
+          break;
+        case PUT:
+          if (request.hasCondition()) {
+            regionServer.metricsRegionServer.updateCheckAndPut(after - before);
+          } else {
+            regionServer.metricsRegionServer.updatePut(after - before);
+          }
+          break;
+        default:
+          break;
+
+        }
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/08b5a4b2/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java
index 3a9d2ee..8ed9f08 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java
@@ -111,8 +111,8 @@ public class TestMetricsRegionServer {
       rsm.updateAppend(1002);
     }
     for (int i=0; i < 13; i ++) {
-      rsm.updateDelete(13);
-      rsm.updateDelete(1003);
+      rsm.updateDeleteBatch(13);
+      rsm.updateDeleteBatch(1003);
     }
     for (int i=0; i < 14; i ++) {
       rsm.updateGet(14);
@@ -123,15 +123,26 @@ public class TestMetricsRegionServer {
       rsm.updateIncrement(1005);
     }
     for (int i=0; i < 16; i ++) {
-      rsm.updatePut(16);
-      rsm.updatePut(1006);
+      rsm.updatePutBatch(16);
+      rsm.updatePutBatch(1006);
+    }
+
+    for (int i=0; i < 17; i ++) {
+      rsm.updatePut(17);
+      rsm.updateDelete(17);
+      rsm.updateCheckAndDelete(17);
+      rsm.updateCheckAndPut(17);
     }
 
     HELPER.assertCounter("appendNumOps", 24, serverSource);
-    HELPER.assertCounter("deleteNumOps", 26, serverSource);
+    HELPER.assertCounter("deleteBatchNumOps", 26, serverSource);
     HELPER.assertCounter("getNumOps", 28, serverSource);
     HELPER.assertCounter("incrementNumOps", 30, serverSource);
-    HELPER.assertCounter("mutateNumOps", 32, serverSource);
+    HELPER.assertCounter("putBatchNumOps", 32, serverSource);
+    HELPER.assertCounter("putNumOps", 17, serverSource);
+    HELPER.assertCounter("deleteNumOps", 17, serverSource);
+    HELPER.assertCounter("checkAndDeleteNumOps", 17, serverSource);
+    HELPER.assertCounter("checkAndPutNumOps", 17, serverSource);
 
 
     HELPER.assertCounter("slowAppendCount", 12, serverSource);

http://git-wip-us.apache.org/repos/asf/hbase/blob/08b5a4b2/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 128b010..4be76e6 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
@@ -260,7 +260,7 @@ public class TestRegionServerMetrics {
     assertCounter("writeRequestCount", writeRequests + 30);
 
     assertRegionMetrics("getCount", 10);
-    assertRegionMetrics("mutateCount", 31);
+    assertRegionMetrics("putCount", 31);
 
     doNGets(10, true);  // true = batch
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/08b5a4b2/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
index 85699ef..b007161 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
@@ -114,7 +114,7 @@ public class TestRemoveRegionMetrics {
           "_region_" + regionInfo.getEncodedName()+
           "_metric";
 
-      metricsHelper.assertCounter(prefix + "_mutateCount", 1, currentAgg);
+      metricsHelper.assertCounter(prefix + "_putCount", 1, currentAgg);
 
 
       try {
@@ -129,7 +129,7 @@ public class TestRemoveRegionMetrics {
             .getMetrics()
             .getSource()
             .getAggregateSource();
-        metricsHelper.assertCounter(prefix + "_mutateCount", 0, destAgg);
+        metricsHelper.assertCounter(prefix + "_putCount", 0, destAgg);
       }
     }
 


Mime
View raw message