hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject [15/50] [abbrv] hbase git commit: HBASE-15663 Hook up JvmPauseMonitor to ThriftServer
Date Mon, 25 Apr 2016 21:12:59 GMT
HBASE-15663 Hook up JvmPauseMonitor to ThriftServer


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

Branch: refs/heads/HBASE-14850
Commit: b6617b4eb90047d51fb287643c971278ba6b9213
Parents: a330a2b
Author: Andrew Purtell <apurtell@apache.org>
Authored: Mon Apr 18 14:37:56 2016 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Wed Apr 20 17:37:35 2016 -0700

----------------------------------------------------------------------
 .../hbase/thrift/MetricsThriftServerSource.java |  3 +-
 .../thrift/MetricsThriftServerSourceImpl.java   | 34 ++++++++++++++++++++
 .../hadoop/hbase/thrift/ThriftServerRunner.java |  8 +++++
 .../hadoop/hbase/thrift2/ThriftServer.java      | 11 +++++--
 4 files changed, 53 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/b6617b4e/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSource.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSource.java
b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSource.java
index a25df56..558a863 100644
--- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSource.java
+++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSource.java
@@ -19,11 +19,12 @@
 package org.apache.hadoop.hbase.thrift;
 
 import org.apache.hadoop.hbase.metrics.BaseSource;
+import org.apache.hadoop.hbase.metrics.JvmPauseMonitorSource;
 
 /**
  * Interface of a class that will export metrics about Thrift to hadoop's metrics2.
  */
-public interface MetricsThriftServerSource extends BaseSource {
+public interface MetricsThriftServerSource extends BaseSource, JvmPauseMonitorSource {
 
   String BATCH_GET_KEY = "batchGet";
   String BATCH_MUTATE_KEY = "batchMutate";

http://git-wip-us.apache.org/repos/asf/hbase/blob/b6617b4e/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceImpl.java
b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceImpl.java
index f5d83b1..71f67eb 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceImpl.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.thrift;
 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;
 import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
 import org.apache.hadoop.metrics2.lib.MutableHistogram;
 
@@ -42,11 +43,25 @@ public class MetricsThriftServerSourceImpl extends BaseSourceImpl implements
 
   private MutableGaugeLong callQueueLenGauge;
 
+  // pause monitor metrics
+  private final MutableFastCounter infoPauseThresholdExceeded;
+  private final MutableFastCounter warnPauseThresholdExceeded;
+  private final MetricHistogram pausesWithGc;
+  private final MetricHistogram pausesWithoutGc;
+
   public MetricsThriftServerSourceImpl(String metricsName,
                                        String metricsDescription,
                                        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
@@ -97,4 +112,23 @@ public class MetricsThriftServerSourceImpl extends BaseSourceImpl implements
     thriftSlowCallStat.add(time);
   }
 
+  @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/b6617b4e/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
----------------------------------------------------------------------
diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
index 21e382b..7d228dc 100644
--- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
+++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
@@ -99,6 +99,7 @@ import org.apache.hadoop.hbase.thrift.generated.TScan;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.ConnectionCache;
 import org.apache.hadoop.hbase.util.DNS;
+import org.apache.hadoop.hbase.util.JvmPauseMonitor;
 import org.apache.hadoop.hbase.util.Strings;
 import org.apache.hadoop.security.SaslRpcServer.SaslGssCallbackHandler;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -202,6 +203,8 @@ public class ThriftServerRunner implements Runnable {
   private final boolean securityEnabled;
   private final boolean doAsEnabled;
 
+  private final JvmPauseMonitor pauseMonitor;
+
   /** An enum of server implementation selections */
   enum ImplType {
     HS_HA("hsha", true, THsHaServer.class, true),
@@ -315,6 +318,7 @@ public class ThriftServerRunner implements Runnable {
     this.conf = HBaseConfiguration.create(conf);
     this.listenPort = conf.getInt(PORT_CONF_KEY, DEFAULT_LISTEN_PORT);
     this.metrics = new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.ONE);
+    this.pauseMonitor = new JvmPauseMonitor(conf, this.metrics.getSource());
     this.hbaseHandler = new HBaseHandler(conf, userProvider);
     this.hbaseHandler.initMetrics(metrics);
     this.handler = HbaseHandlerMetricsProxy.newInstance(
@@ -344,6 +348,7 @@ public class ThriftServerRunner implements Runnable {
       @Override
       public Object run() {
         try {
+          pauseMonitor.start();
           if (conf.getBoolean(USE_HTTP_CONF_KEY, false)) {
             setupHTTPServer();
             httpServer.start();
@@ -364,6 +369,9 @@ public class ThriftServerRunner implements Runnable {
   }
 
   public void shutdown() {
+    if (pauseMonitor != null) {
+      pauseMonitor.stop();
+    }
     if (tserver != null) {
       tserver.stop();
       tserver = null;

http://git-wip-us.apache.org/repos/asf/hbase/blob/b6617b4e/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java
----------------------------------------------------------------------
diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java
b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java
index b606500..7d94d0e 100644
--- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java
+++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java
@@ -62,6 +62,7 @@ import org.apache.hadoop.hbase.thrift.CallQueue.Call;
 import org.apache.hadoop.hbase.thrift.ThriftMetrics;
 import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
 import org.apache.hadoop.hbase.util.DNS;
+import org.apache.hadoop.hbase.util.JvmPauseMonitor;
 import org.apache.hadoop.hbase.util.Strings;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.SaslRpcServer.SaslGssCallbackHandler;
@@ -433,6 +434,7 @@ public class ThriftServer extends Configured implements Tool {
     boolean hsha = cmd.hasOption("hsha");
 
     ThriftMetrics metrics = new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.TWO);
+    final JvmPauseMonitor pauseMonitor = new JvmPauseMonitor(conf, metrics.getSource());
 
     String implType = "threadpool";
     if (nonblocking) {
@@ -538,8 +540,13 @@ public class ThriftServer extends Configured implements Tool {
       new PrivilegedAction<Object>() {
         @Override
         public Object run() {
-          tserver.serve();
-          return null;
+          pauseMonitor.start();
+          try {
+            tserver.serve();
+            return null;
+          } finally {
+            pauseMonitor.stop();
+          }
         }
       });
     // when tserver.stop eventually happens we'll get here.


Mime
View raw message