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 BE6D09B53 for ; Tue, 20 Dec 2011 18:42:37 +0000 (UTC) Received: (qmail 60431 invoked by uid 500); 20 Dec 2011 18:42:37 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 60342 invoked by uid 500); 20 Dec 2011 18:42:36 -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 60335 invoked by uid 99); 20 Dec 2011 18:42:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2011 18:42:36 +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; Tue, 20 Dec 2011 18:42:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 21F412388860 for ; Tue, 20 Dec 2011 18:42:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1221419 - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java Date: Tue, 20 Dec 2011 18:42:12 -0000 To: commits@hbase.apache.org From: nspiegelberg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111220184212.21F412388860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nspiegelberg Date: Tue Dec 20 18:42:11 2011 New Revision: 1221419 URL: http://svn.apache.org/viewvc?rev=1221419&view=rev Log: [jira] [HBASE-5072] Support Max Value for Per-Store Metrics Summary: We were bit in our multi-tenant cluster because one of our Stores encountered a bug and grew its StoreFile count. We didn't notice this because the StoreFile count currently reported by the RegionServer is an average of all Stores in the region. For the per-Store metrics, we should also record the max so we can notice outliers. Test Plan: - mvn test -Dtest=TestRegionServerMetrics Reviewers: JIRA, mbautin, Kannan Reviewed By: Kannan CC: stack, nspiegelberg, mbautin, Kannan Differential Revision: 945 Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java?rev=1221419&r1=1221418&r2=1221419&view=diff ============================================================================== --- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java (original) +++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java Tue Dec 20 18:42:11 2011 @@ -245,6 +245,7 @@ public class SchemaMetrics { private final String[] bloomMetricNames = new String[2]; private final String[] storeMetricNames = new String[NUM_STORE_METRIC_TYPES]; + private final String[] storeMetricNamesMax = new String[NUM_STORE_METRIC_TYPES]; private SchemaMetrics(final String tableName, final String cfName) { String metricPrefix = SchemaMetrics.generateSchemaMetricsPrefix( @@ -290,8 +291,9 @@ public class SchemaMetrics { } for (StoreMetricType storeMetric : StoreMetricType.values()) { - storeMetricNames[storeMetric.ordinal()] = metricPrefix + - storeMetric.toString(); + String coreName = metricPrefix + storeMetric.toString(); + storeMetricNames[storeMetric.ordinal()] = coreName; + storeMetricNamesMax[storeMetric.ordinal()] = coreName + ".max"; } } @@ -390,13 +392,22 @@ public class SchemaMetrics { public void accumulateStoreMetric(final Map tmpMap, StoreMetricType storeMetricType, double val) { final String key = getStoreMetricName(storeMetricType); - if (tmpMap.get(key) != null) { - tmpMap.get(key).add(val); - } else { + if (tmpMap.get(key) == null) { tmpMap.put(key, new MutableDouble(val)); + } else { + tmpMap.get(key).add(val); } - if (this != ALL_SCHEMA_METRICS) { + if (this == ALL_SCHEMA_METRICS) { + // also compute the max value across all Stores on this server + final String maxKey = getStoreMetricNameMax(storeMetricType); + MutableDouble cur = tmpMap.get(maxKey); + if (cur == null) { + tmpMap.put(maxKey, new MutableDouble(val)); + } else if (cur.doubleValue() < val) { + cur.setValue(val); + } + } else { ALL_SCHEMA_METRICS.accumulateStoreMetric(tmpMap, storeMetricType, val); } } @@ -405,6 +416,10 @@ public class SchemaMetrics { return storeMetricNames[storeMetricType.ordinal()]; } + public String getStoreMetricNameMax(StoreMetricType storeMetricType) { + return storeMetricNamesMax[storeMetricType.ordinal()]; + } + /** * Update a metric that does not get reset on every poll. * @param storeMetricType the store metric to update Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java?rev=1221419&r1=1221418&r2=1221419&view=diff ============================================================================== --- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java (original) +++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java Tue Dec 20 18:42:11 2011 @@ -116,9 +116,15 @@ public class TestRegionServerMetrics { for (String cf : FAMILIES) { SchemaMetrics schemaMetrics = SchemaMetrics.getInstance(TABLE_NAME, cf); - assertStoreMetricEquals(NUM_FLUSHES * NUM_REGIONS, - schemaMetrics, StoreMetricType.STORE_FILE_COUNT); + assertStoreMetricEquals(NUM_FLUSHES * NUM_REGIONS, schemaMetrics, + StoreMetricType.STORE_FILE_COUNT); } + + // ensure that the max value is also maintained + final String storeMetricName = ALL_METRICS + .getStoreMetricNameMax(StoreMetricType.STORE_FILE_COUNT); + assertEquals("Invalid value for store metric " + storeMetricName, + NUM_FLUSHES, HRegion.getNumericMetric(storeMetricName)); }