You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by vj...@apache.org on 2020/07/14 18:52:33 UTC
[hbase] branch branch-2.2 updated: Revert "HBASE-24615
MutableRangeHistogram#updateSnapshotRangeMetrics doesn't calculate the
distribution for last bucket"
This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.2 by this push:
new 9d9607f Revert "HBASE-24615 MutableRangeHistogram#updateSnapshotRangeMetrics doesn't calculate the distribution for last bucket"
9d9607f is described below
commit 9d9607f8bd2db4b2e5d95a66eed10cea77f3d9ba
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Wed Jul 15 00:22:01 2020 +0530
Revert "HBASE-24615 MutableRangeHistogram#updateSnapshotRangeMetrics doesn't calculate the distribution for last bucket"
This reverts commit d32f154d10423c9959dc862c00f23deaa5f85c79.
---
.../metrics2/lib/TestMutableRangeHistogram.java | 90 ----------------------
.../hadoop/metrics2/lib/MutableRangeHistogram.java | 4 +-
2 files changed, 2 insertions(+), 92 deletions(-)
diff --git a/hbase-hadoop-compat/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableRangeHistogram.java b/hbase-hadoop-compat/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableRangeHistogram.java
deleted file mode 100644
index 1cf8702..0000000
--- a/hbase-hadoop-compat/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableRangeHistogram.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.metrics2.lib;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.testclassification.MetricsTests;
-import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.apache.hadoop.metrics2.AbstractMetric;
-import org.apache.hadoop.metrics2.MetricsRecord;
-import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Category({ MetricsTests.class, SmallTests.class })
-public class TestMutableRangeHistogram {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMutableRangeHistogram.class);
-
- private static final String RECORD_NAME = "test";
- private static final String SIZE_HISTOGRAM_NAME = "TestSize";
-
- /**
- * calculate the distribution for last bucket, see HBASE-24615 for detail.
- */
- @Test
- public void testLastBucketWithSizeHistogram() {
- // create and init histogram minValue and maxValue
- MetricsCollectorImpl collector = new MetricsCollectorImpl();
- MutableSizeHistogram histogram = new MutableSizeHistogram(SIZE_HISTOGRAM_NAME, "");
- long[] ranges = histogram.getRanges();
- int len = ranges.length;
- histogram.add(0L);
- histogram.add(ranges[len - 1]);
- histogram.snapshot(collector.addRecord(RECORD_NAME), true);
- collector.clear();
-
- // fill up values and snapshot
- histogram.add(ranges[len - 2] * 2);
- histogram.add(ranges[len - 1] * 2);
- histogram.snapshot(collector.addRecord(RECORD_NAME), true);
- List<? extends MetricsRecord> records = collector.getRecords();
- assertEquals(1, records.size());
- MetricsRecord record = records.iterator().next();
- assertEquals(RECORD_NAME, record.name());
-
- // get size range metrics
- String histogramMetricPrefix = SIZE_HISTOGRAM_NAME + "_" + histogram.getRangeType();
- List<AbstractMetric> metrics = new ArrayList<>();
- for (AbstractMetric metric : record.metrics()) {
- if (metric.name().startsWith(histogramMetricPrefix)) {
- metrics.add(metric);
- }
- }
- assertEquals(2, metrics.size());
-
- // check range [10000000,100000000]
- String metricName = histogramMetricPrefix + "_" + ranges[len - 2] + "-" + ranges[len - 1];
- assertEquals(metricName, metrics.get(0).name());
- assertEquals(1, metrics.get(0).value().longValue());
-
- // check range [100000000, inf]
- metricName = histogramMetricPrefix + "_" + ranges[len - 1] + "-inf";
- assertEquals(metricName, metrics.get(1).name(), metricName);
- assertEquals(1, metrics.get(1).value().longValue());
- }
-}
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java
index 3dc6652..273154f 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java
@@ -67,7 +67,7 @@ public abstract class MutableRangeHistogram extends MutableHistogram implements
final long[] ranges = getRanges();
final String rangeType = getRangeType();
- for (int i = 0; i < ranges.length; i++) {
+ for (int i = 0; i < ranges.length - 1; i++) {
long val = snapshot.getCountAtOrBelow(ranges[i]);
if (val - cumNum > 0) {
metricsRecordBuilder.addCounter(
@@ -80,7 +80,7 @@ public abstract class MutableRangeHistogram extends MutableHistogram implements
long val = snapshot.getCount();
if (val - cumNum > 0) {
metricsRecordBuilder.addCounter(
- Interns.info(name + "_" + rangeType + "_" + priorRange + "-inf", desc),
+ Interns.info(name + "_" + rangeType + "_" + ranges[ranges.length - 1] + "-inf", desc),
val - cumNum);
}
}