[GitHub] [hbase] WenFeiYi commented on a change in pull request #1962: HBASE-24615 MutableRangeHistogram#updateSnapshotRangeMetrics doesn't calculate the distribution for last bucket.

2020-07-10 Thread GitBox


WenFeiYi commented on a change in pull request #1962:
URL: https://github.com/apache/hbase/pull/1962#discussion_r452654143



##
File path: 
hbase-hadoop-compat/src/test/java/org/apache/hadoop/metrics2/impl/TestMutableRangeHistogram.java
##
@@ -0,0 +1,90 @@
+/**
+ * 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.impl;

Review comment:
   I found a solution, please ignore.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [hbase] WenFeiYi commented on a change in pull request #1962: HBASE-24615 MutableRangeHistogram#updateSnapshotRangeMetrics doesn't calculate the distribution for last bucket.

2020-07-09 Thread GitBox


WenFeiYi commented on a change in pull request #1962:
URL: https://github.com/apache/hbase/pull/1962#discussion_r452583441



##
File path: 
hbase-hadoop-compat/src/test/java/org/apache/hadoop/metrics2/impl/TestMutableRangeHistogram.java
##
@@ -0,0 +1,90 @@
+/**
+ * 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.impl;

Review comment:
   I did that at first, but 
org.apache.hadoop.metrics2.impl.MetricsRecordImpl is a package class,  not use





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [hbase] WenFeiYi commented on a change in pull request #1962: HBASE-24615 MutableRangeHistogram#updateSnapshotRangeMetrics doesn't calculate the distribution for last bucket.

2020-07-07 Thread GitBox


WenFeiYi commented on a change in pull request #1962:
URL: https://github.com/apache/hbase/pull/1962#discussion_r451243720



##
File path: 
hbase-hadoop-compat/src/test/java/org/apache/hadoop/metrics2/impl/TestMutableRangeHistogram.java
##
@@ -0,0 +1,66 @@
+package org.apache.hadoop.metrics2.impl;
+
+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.MetricsRecordBuilder;
+import org.apache.hadoop.metrics2.lib.MutableRangeHistogram;
+import org.apache.hadoop.metrics2.lib.MutableSizeHistogram;
+import org.apache.hadoop.metrics2.lib.MutableTimeHistogram;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Collection;
+
+@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_METRIC_NAME = "TestSize";
+private static final String TIME_METRIC_NAME = "TestTime";
+
+@Test
+public void testMutableSizeHistogram() {
+testMutableRangeHistogram(SIZE_METRIC_NAME, new 
MutableSizeHistogram(SIZE_METRIC_NAME, ""));
+}
+
+@Test
+public void testMutableTimeHistogram() {
+testMutableRangeHistogram(TIME_METRIC_NAME, new 
MutableTimeHistogram(TIME_METRIC_NAME, ""));
+}
+
+private static void testMutableRangeHistogram(String metricName, 
MutableRangeHistogram histogram) {
+// fill up values
+long[] ranges = histogram.getRanges();
+for (long val : ranges) {
+histogram.add(val - 1);
+}
+histogram.add(ranges[ranges.length - 1] + 1);
+// put into metrics collector
+MetricsCollectorImpl collector = new MetricsCollectorImpl();
+MetricsRecordBuilder builder = collector.addRecord(RECORD_NAME);
+histogram.snapshot(builder, true);
+// get and print
+Collection records = collector.getRecords();
+assertEquals(records.size(), 1);
+MetricsRecordImpl record = records.iterator().next();
+assertEquals(record.name(), RECORD_NAME);
+String prefix = metricName + "_" + histogram.getRangeType();
+int count = 0;
+for (AbstractMetric metric : record.metrics()) {

Review comment:
   I go it, thank you very much! I try to push again





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org