You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jd...@apache.org on 2013/09/27 02:04:03 UTC
svn commit: r1526754 - in /hbase/trunk:
hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java
Author: jdcryans
Date: Fri Sep 27 00:04:03 2013
New Revision: 1526754
URL: http://svn.apache.org/r1526754
Log:
HBASE-8711 Requests count is completely off (James Kinley via JD)
Modified:
hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java
Modified: hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1526754&r1=1526753&r2=1526754&view=diff
==============================================================================
--- hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java Fri Sep 27 00:04:03 2013
@@ -848,7 +848,11 @@ public final class HConstants {
/** Temporary directory used for table creation and deletion */
public static final String HBASE_TEMP_DIRECTORY = ".tmp";
-
+ /**
+ * The period (in milliseconds) between computing region server point in time metrics
+ */
+ public static final String REGIONSERVER_METRICS_PERIOD = "hbase.regionserver.metrics.period";
+ public static final long DEFAULT_REGIONSERVER_METRICS_PERIOD = 5000;
/** Directories that are not HBase table directories */
public static final List<String> HBASE_NON_TABLE_DIRS =
Collections.unmodifiableList(Arrays.asList(new String[] { HREGION_LOGDIR_NAME,
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java?rev=1526754&r1=1526753&r2=1526754&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java Fri Sep 27 00:04:03 2013
@@ -17,11 +17,16 @@
*/
package org.apache.hadoop.hbase.regionserver;
+import java.util.Collection;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.io.hfile.BlockCache;
@@ -31,10 +36,6 @@ import org.apache.hadoop.hbase.util.Envi
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.metrics2.MetricsExecutor;
-import java.util.Collection;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
/**
* Impl for exposing HRegionServer Information through Hadoop's metrics 2 system.
*/
@@ -44,8 +45,6 @@ class MetricsRegionServerWrapperImpl
public static final Log LOG = LogFactory.getLog(MetricsRegionServerWrapperImpl.class);
- public static final int PERIOD = 15;
-
private final HRegionServer regionServer;
private BlockCache blockCache;
@@ -69,14 +68,24 @@ class MetricsRegionServerWrapperImpl
private CacheStats cacheStats;
private ScheduledExecutorService executor;
private Runnable runnable;
+ private long period;
public MetricsRegionServerWrapperImpl(final HRegionServer regionServer) {
this.regionServer = regionServer;
initBlockCache();
+ this.period =
+ regionServer.conf.getLong(HConstants.REGIONSERVER_METRICS_PERIOD,
+ HConstants.DEFAULT_REGIONSERVER_METRICS_PERIOD);
+
this.executor = CompatibilitySingletonFactory.getInstance(MetricsExecutor.class).getExecutor();
this.runnable = new RegionServerMetricsWrapperRunnable();
- this.executor.scheduleWithFixedDelay(this.runnable, PERIOD, PERIOD, TimeUnit.SECONDS);
+ this.executor.scheduleWithFixedDelay(this.runnable, this.period, this.period,
+ TimeUnit.MILLISECONDS);
+
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Computing regionserver metrics every " + this.period + " milliseconds");
+ }
}
/**
@@ -398,12 +407,12 @@ class MetricsRegionServerWrapperImpl
// assume that it took PERIOD seconds to start the executor.
// this is a guess but it's a pretty good one.
if (lastRan == 0) {
- lastRan = currentTime - (PERIOD*1000);
+ lastRan = currentTime - (period * 1000);
}
//If we've time traveled keep the last requests per second.
- if ((currentTime - lastRan) > 10) {
+ if ((currentTime - lastRan) > 0) {
long currentRequestCount = getTotalRequestCount();
requestsPerSecond = (currentRequestCount - lastRequestCount) / ((currentTime - lastRan) / 1000.0);
lastRequestCount = currentRequestCount;