diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java index 8837c02b99d..6c5a71a708f 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java @@ -280,7 +280,6 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource { } return sink; } - allSinks.put(name, sink); if (config != null) { registerSink(name, description, sink); } @@ -301,6 +300,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource { ? newSink(name, desc, sink, conf) : newSink(name, desc, sink, config.subset(SINK_KEY)); sinks.put(name, sa); + allSinks.put(name, sink); sa.start(); LOG.info("Registered sink "+ name); } @@ -508,6 +508,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource { conf.getString(DESC_KEY, sinkName), conf); sa.start(); sinks.put(sinkName, sa); + allSinks.put(sinkName, sa.sink()); } catch (Exception e) { LOG.warn("Error creating sink '"+ sinkName +"'", e); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java index 5a1f1d1376d..1e841a68654 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java @@ -438,6 +438,8 @@ public class TestMetricsSystemImpl { r = recs.get(1); assertTrue("NumActiveSinks should be 3", Iterables.contains(r.metrics(), new MetricGaugeInt(MsInfo.NumActiveSinks, 3))); + assertTrue("NumAllSinks should be 3", + Iterables.contains(r.metrics(), new MetricGaugeInt(MsInfo.NumAllSinks, 3))); } @Test