[
https://issues.apache.org/jira/browse/HADOOP-18502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17628083#comment-17628083
]
ASF GitHub Bot commented on HADOOP-18502:
-----------------------------------------
ZanderXu commented on code in PR #5058:
URL: https://github.com/apache/hadoop/pull/5058#discussion_r1012451085
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##########
@@ -290,6 +290,26 @@ private static void snapshotMutableRatesWithAggregation(
}
}
+ /**
+ * MutableStat should output 0 instead of the previous state when there is
no change
Review Comment:
Should end with `.`
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##########
@@ -290,6 +290,26 @@ private static void snapshotMutableRatesWithAggregation(
}
}
+ /**
+ * MutableStat should output 0 instead of the previous state when there is
no change
+ */
+ @Test public void testMutableWithoutChanged() {
+ MetricsRecordBuilder builderWithChange = mockMetricsRecordBuilder();
+ MetricsRecordBuilder builderWithoutChange = mockMetricsRecordBuilder();
+ MetricsRegistry registry = new MetricsRegistry("test");
+ MutableStat stat = registry.newStat("Test", "Test", "Ops", "Val", false);
+
+ stat.add(1000, 1000);
+ stat.add(1000, 2000);
+ registry.snapshot(builderWithChange, true);
+
+ assertCounter("TestNumOps", 2000L, builderWithChange);
+ assertGauge("TestAvgVal", 1.5, builderWithChange);
+
+ registry.snapshot(builderWithoutChange, true);
+ assertGauge("TestAvgVal", 0.0, builderWithoutChange);
Review Comment:
Here too. Can add one UT to verify the `INumOps`?
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##########
@@ -290,6 +290,26 @@ private static void snapshotMutableRatesWithAggregation(
}
}
+ /**
+ * MutableStat should output 0 instead of the previous state when there is
no change
+ */
+ @Test public void testMutableWithoutChanged() {
+ MetricsRecordBuilder builderWithChange = mockMetricsRecordBuilder();
+ MetricsRecordBuilder builderWithoutChange = mockMetricsRecordBuilder();
+ MetricsRegistry registry = new MetricsRegistry("test");
+ MutableStat stat = registry.newStat("Test", "Test", "Ops", "Val", false);
+
+ stat.add(1000, 1000);
+ stat.add(1000, 2000);
+ registry.snapshot(builderWithChange, true);
+
+ assertCounter("TestNumOps", 2000L, builderWithChange);
Review Comment:
Can add one UT to verify the `INumOps`?
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##########
@@ -290,6 +290,26 @@ private static void snapshotMutableRatesWithAggregation(
}
}
+ /**
+ * MutableStat should output 0 instead of the previous state when there is
no change
+ */
+ @Test public void testMutableWithoutChanged() {
+ MetricsRecordBuilder builderWithChange = mockMetricsRecordBuilder();
+ MetricsRecordBuilder builderWithoutChange = mockMetricsRecordBuilder();
+ MetricsRegistry registry = new MetricsRegistry("test");
+ MutableStat stat = registry.newStat("Test", "Test", "Ops", "Val", false);
+
Review Comment:
Can remove this empty line.
> Hadoop metrics should return 0 when there is no change
> ------------------------------------------------------
>
> Key: HADOOP-18502
> URL: https://issues.apache.org/jira/browse/HADOOP-18502
> Project: Hadoop Common
> Issue Type: Improvement
> Reporter: leo sun
> Assignee: leo sun
> Priority: Major
> Labels: pull-request-available
> Attachments: image-2022-10-21-14-41-43-105.png
>
>
> When we try to switch active NN to standby, we find that the
> getContentSummary average time is always a very high value even if there is
> no more query. For us, the metrics return 0 is more reasonable. The monitor
> is as below:
> !image-2022-10-21-14-41-43-105.png!
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]