From f6e4b13d5f1b254a009f21c064f48c818f241a0d Mon Sep 17 00:00:00 2001 From: Vrushali C Date: Wed, 5 Sep 2018 21:09:16 -0700 Subject: [PATCH] HADOOP-15657 Registering MutableQuantiles via Metric annotation. Contributed by Sushil Ks --- .../java/org/apache/hadoop/metrics2/annotation/Metric.java | 5 +++++ .../apache/hadoop/metrics2/lib/MutableMetricsFactory.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/annotation/Metric.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/annotation/Metric.java index 88fb070475b..516a3b8f3f3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/annotation/Metric.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/annotation/Metric.java @@ -67,4 +67,9 @@ public @interface Metric { * @return optional type (counter|gauge) of the metric */ Type type() default Type.DEFAULT; + + /** + * @return optional roll over interval in secs for MutableQuantiles + */ + int interval() default 10; } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java index 32099907fba..c415dd5a3da 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java @@ -83,6 +83,10 @@ public class MutableMetricsFactory { return registry.newMutableRollingAverages(info.name(), annotation.valueName()); } + if (cls == MutableQuantiles.class) { + return registry.newQuantiles(info.name(), annotation.about(), + annotation.sampleName(), annotation.valueName(), annotation.interval()); + } throw new MetricsException("Unsupported metric field "+ field.getName() + " of type "+ field.getType().getName()); }