HBASE-15662 Hook up JvmPauseMonitor to REST server

This commit is contained in:
Andrew Purtell 2016-04-18 14:06:17 -07:00
parent 780cff5886
commit db83e631ad
3 changed files with 46 additions and 2 deletions

View File

@ -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";

View File

@ -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);
}
}

View File

@ -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();
}