goiri commented on code in PR #5556:
URL: https://github.com/apache/hadoop/pull/5556#discussion_r1167234948
##
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableQuantiles.java:
##
@@ -130,11 +129,11 @@ public MutableQuantiles() {}
public synchronized void snapshot(MetricsRecordBuilder builder, boolean all)
{
if (all || changed()) {
builder.addGauge(numInfo, previousCount);
- for (int i = 0; i < quantiles.length; i++) {
+ for (int i = 0; i < getQuantiles().length; i++) {
Review Comment:
You probably need to extract `getQuantiles()`, otherwise you may end up with
two versions.
##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##
@@ -431,6 +431,46 @@ public void testMutableQuantilesError() throws Exception {
}
}
+ /**
+ * Ensure that quantile estimates from {@link MutableInverseQuantiles} are
within
+ * specified error bounds.
+ */
+ @Test(timeout = 3)
+ public void testMutableInverseQuantilesError() throws Exception {
+MetricsRecordBuilder mb = mockMetricsRecordBuilder();
+MetricsRegistry registry = new MetricsRegistry("test");
+// Use a 5s rollover period
+MutableQuantiles inverseQuantiles = registry.newInverseQuantiles("foo",
"stat", "Ops",
+"Latency", 5);
+// Push some values in and wait for it to publish
+long start = System.nanoTime() / 100;
Review Comment:
Use units in the vars.
##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##
@@ -431,6 +431,46 @@ public void testMutableQuantilesError() throws Exception {
}
}
+ /**
+ * Ensure that quantile estimates from {@link MutableInverseQuantiles} are
within
+ * specified error bounds.
+ */
+ @Test(timeout = 3)
+ public void testMutableInverseQuantilesError() throws Exception {
+MetricsRecordBuilder mb = mockMetricsRecordBuilder();
+MetricsRegistry registry = new MetricsRegistry("test");
+// Use a 5s rollover period
+MutableQuantiles inverseQuantiles = registry.newInverseQuantiles("foo",
"stat", "Ops",
+"Latency", 5);
+// Push some values in and wait for it to publish
+long start = System.nanoTime() / 100;
+for (long i = 1; i <= 1000; i++) {
Review Comment:
Declare constants.
##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##
@@ -431,6 +431,46 @@ public void testMutableQuantilesError() throws Exception {
}
}
+ /**
+ * Ensure that quantile estimates from {@link MutableInverseQuantiles} are
within
+ * specified error bounds.
+ */
+ @Test(timeout = 3)
+ public void testMutableInverseQuantilesError() throws Exception {
+MetricsRecordBuilder mb = mockMetricsRecordBuilder();
+MetricsRegistry registry = new MetricsRegistry("test");
+// Use a 5s rollover period
+MutableQuantiles inverseQuantiles = registry.newInverseQuantiles("foo",
"stat", "Ops",
+"Latency", 5);
+// Push some values in and wait for it to publish
+long start = System.nanoTime() / 100;
+for (long i = 1; i <= 1000; i++) {
+ inverseQuantiles.add(i);
+ inverseQuantiles.add(1001 - i);
+}
+long end = System.nanoTime() / 100;
+
+Thread.sleep(6000 - (end - start));
Review Comment:
Constant
--
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.
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org
-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org