Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5D44E10A37 for ; Fri, 27 Sep 2013 00:04:25 +0000 (UTC) Received: (qmail 69811 invoked by uid 500); 27 Sep 2013 00:04:25 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 69776 invoked by uid 500); 27 Sep 2013 00:04:25 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 69769 invoked by uid 99); 27 Sep 2013 00:04:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Sep 2013 00:04:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Sep 2013 00:04:23 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DB86923888E4; Fri, 27 Sep 2013 00:04:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Fri, 27 Sep 2013 00:04:03 -0000 To: commits@hbase.apache.org From: jdcryans@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130927000403.DB86923888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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;