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 4ecd73bbbb8..ceec41d9496 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"; 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 71755b742d1..30625f8ca7e 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); + } } 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 1f751a68959..4da5c67b443 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(); }