hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [10/10] hbase git commit: HBASE-15662 Hook up JvmPauseMonitor to REST server
Date Thu, 21 Apr 2016 01:46:04 GMT
HBASE-15662 Hook up JvmPauseMonitor to REST server


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

Branch: refs/heads/master
Commit: a330a2b5050f0ce9e902a6e23309d003015cbcf7
Parents: 2c26fe3
Author: Andrew Purtell <apurtell@apache.org>
Authored: Mon Apr 18 14:06:17 2016 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Wed Apr 20 17:37:35 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/rest/MetricsRESTSource.java    |  3 +-
 .../hbase/rest/MetricsRESTSourceImpl.java       | 35 ++++++++++++++++++++
 .../apache/hadoop/hbase/rest/RESTServlet.java   | 10 +++++-
 3 files changed, 46 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a330a2b5/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSource.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSource.java
b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSource.java
index 4ecd73b..ceec41d 100644
--- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSource.java
+++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSource.java
@@ -19,11 +19,12 @@
 package org.apache.hadoop.hbase.rest;
 
 import org.apache.hadoop.hbase.metrics.BaseSource;
+import org.apache.hadoop.hbase.metrics.JvmPauseMonitorSource;
 
 /**
  * Interface of the Metrics Source that will export data to Hadoop's Metrics2 system.
  */
-public interface MetricsRESTSource extends BaseSource {
+public interface MetricsRESTSource extends BaseSource, JvmPauseMonitorSource {
 
   String METRICS_NAME = "REST";
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/a330a2b5/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSourceImpl.java
b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSourceImpl.java
index 71755b7..30625f8 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSourceImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/rest/MetricsRESTSourceImpl.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.rest;
 
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.metrics.BaseSourceImpl;
+import org.apache.hadoop.metrics2.MetricHistogram;
 import org.apache.hadoop.metrics2.lib.MutableFastCounter;
 
 /**
@@ -41,6 +42,12 @@ public class MetricsRESTSourceImpl extends BaseSourceImpl implements MetricsREST
   private MutableFastCounter fDel;
   private MutableFastCounter fScan;
 
+  // pause monitor metrics
+  private final MutableFastCounter infoPauseThresholdExceeded;
+  private final MutableFastCounter warnPauseThresholdExceeded;
+  private final MetricHistogram pausesWithGc;
+  private final MetricHistogram pausesWithoutGc;
+
   public MetricsRESTSourceImpl() {
     this(METRICS_NAME, METRICS_DESCRIPTION, CONTEXT, JMX_CONTEXT);
   }
@@ -50,6 +57,14 @@ public class MetricsRESTSourceImpl extends BaseSourceImpl implements MetricsREST
                                String metricsContext,
                                String metricsJmxContext) {
     super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
+
+    // pause monitor metrics
+    infoPauseThresholdExceeded = getMetricsRegistry().newCounter(INFO_THRESHOLD_COUNT_KEY,
+      INFO_THRESHOLD_COUNT_DESC, 0L);
+    warnPauseThresholdExceeded = getMetricsRegistry().newCounter(WARN_THRESHOLD_COUNT_KEY,
+      WARN_THRESHOLD_COUNT_DESC, 0L);
+    pausesWithGc = getMetricsRegistry().newTimeHistogram(PAUSE_TIME_WITH_GC_KEY);
+    pausesWithoutGc = getMetricsRegistry().newTimeHistogram(PAUSE_TIME_WITHOUT_GC_KEY);
   }
 
   @Override
@@ -112,4 +127,24 @@ public class MetricsRESTSourceImpl extends BaseSourceImpl implements
MetricsREST
   public void incrementFailedScanRequests(int inc) {
    fScan.incr(inc);
   }
+
+  @Override
+  public void incInfoThresholdExceeded(int count) {
+    infoPauseThresholdExceeded.incr(count);
+  }
+
+  @Override
+  public void incWarnThresholdExceeded(int count) {
+    warnPauseThresholdExceeded.incr(count);
+  }
+
+  @Override
+  public void updatePauseTimeWithGc(long t) {
+    pausesWithGc.add(t);
+  }
+
+  @Override
+  public void updatePauseTimeWithoutGc(long t) {
+    pausesWithoutGc.add(t);
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/a330a2b5/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java
index 1f751a6..4da5c67 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java
@@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.filter.ParseFilter;
 import org.apache.hadoop.hbase.security.UserProvider;
 import org.apache.hadoop.hbase.util.ConnectionCache;
+import org.apache.hadoop.hbase.util.JvmPauseMonitor;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.authorize.ProxyUsers;
 import org.apache.log4j.Logger;
@@ -39,9 +40,10 @@ public class RESTServlet implements Constants {
   private static final Logger LOG = Logger.getLogger(RESTServlet.class);
   private static RESTServlet INSTANCE;
   private final Configuration conf;
-  private final MetricsREST metrics = new MetricsREST();
+  private final MetricsREST metrics;
   private final ConnectionCache connectionCache;
   private final UserGroupInformation realUser;
+  private final JvmPauseMonitor pauseMonitor;
 
   static final String CLEANUP_INTERVAL = "hbase.rest.connection.cleanup-interval";
   static final String MAX_IDLETIME = "hbase.rest.connection.max-idletime";
@@ -99,6 +101,11 @@ public class RESTServlet implements Constants {
     if (supportsProxyuser()) {
       ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
     }
+
+    metrics = new MetricsREST();
+
+    pauseMonitor = new JvmPauseMonitor(conf, metrics.getSource());
+    pauseMonitor.start();
   }
 
   Admin getAdmin() throws IOException {
@@ -137,6 +144,7 @@ public class RESTServlet implements Constants {
    * Shutdown any services that need to stop
    */
   void shutdown() {
+    if (pauseMonitor != null) pauseMonitor.stop();
     if (connectionCache != null) connectionCache.shutdown();
   }
 


Mime
View raw message