From 4dcc08b656b0b8f5db61b3befe3daf7b7aa7d288 Mon Sep 17 00:00:00 2001 From: Jason Darrell Lowe Date: Tue, 15 Jul 2014 19:51:55 +0000 Subject: [PATCH] Addendum patch for HADOOP-10468 TestMetricsSystemImpl.testMultiThreadedPublish fails intermediately. Contributed by Akira AJISAKA git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1610829 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/metrics2/impl/MetricsConfig.java | 2 +- .../metrics2/impl/TestGangliaMetrics.java | 12 +++---- .../metrics2/impl/TestMetricsSystemImpl.java | 33 ++++++++++--------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java index 2c236bc533..e4b5580536 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java @@ -85,7 +85,7 @@ class MetricsConfig extends SubsetConfiguration { private ClassLoader pluginLoader; MetricsConfig(Configuration c, String prefix) { - super(c, prefix, "."); + super(c, prefix.toLowerCase(Locale.US), "."); } static MetricsConfig create(String prefix) { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java index 178719589b..e097a0f873 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java @@ -60,12 +60,12 @@ public class TestGangliaMetrics { @Test public void testTagsForPrefix() throws Exception { ConfigBuilder cb = new ConfigBuilder() - .add("Test.sink.ganglia.tagsForPrefix.all", "*") - .add("Test.sink.ganglia.tagsForPrefix.some", "NumActiveSinks, " + + .add("test.sink.ganglia.tagsForPrefix.all", "*") + .add("test.sink.ganglia.tagsForPrefix.some", "NumActiveSinks, " + "NumActiveSources") - .add("Test.sink.ganglia.tagsForPrefix.none", ""); + .add("test.sink.ganglia.tagsForPrefix.none", ""); GangliaSink30 sink = new GangliaSink30(); - sink.init(cb.subset("Test.sink.ganglia")); + sink.init(cb.subset("test.sink.ganglia")); List tags = new ArrayList(); tags.add(new MetricsTag(MsInfo.Context, "all")); @@ -98,8 +98,8 @@ public void testTagsForPrefix() throws Exception { @Test public void testGangliaMetrics2() throws Exception { ConfigBuilder cb = new ConfigBuilder().add("default.period", 10) - .add("Test.sink.gsink30.context", "test") // filter out only "test" - .add("Test.sink.gsink31.context", "test") // filter out only "test" + .add("test.sink.gsink30.context", "test") // filter out only "test" + .add("test.sink.gsink31.context", "test") // filter out only "test" .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test")); MetricsSystemImpl ms = new MetricsSystemImpl("Test"); 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 564214bba6..63dcbb2afa 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 @@ -88,11 +88,11 @@ public static class TestSink implements MetricsSink { DefaultMetricsSystem.shutdown(); new ConfigBuilder().add("*.period", 8) //.add("test.sink.plugin.urls", getPluginUrlsAsString()) - .add("Test.sink.test.class", TestSink.class.getName()) - .add("Test.*.source.filter.exclude", "s0") - .add("Test.source.s1.metric.filter.exclude", "X*") - .add("Test.sink.sink1.metric.filter.exclude", "Y*") - .add("Test.sink.sink2.metric.filter.exclude", "Y*") + .add("test.sink.test.class", TestSink.class.getName()) + .add("test.*.source.filter.exclude", "s0") + .add("test.source.s1.metric.filter.exclude", "X*") + .add("test.sink.sink1.metric.filter.exclude", "Y*") + .add("test.sink.sink2.metric.filter.exclude", "Y*") .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test")); MetricsSystemImpl ms = new MetricsSystemImpl("Test"); ms.start(); @@ -130,11 +130,11 @@ public static class TestSink implements MetricsSink { DefaultMetricsSystem.shutdown(); new ConfigBuilder().add("*.period", 8) //.add("test.sink.plugin.urls", getPluginUrlsAsString()) - .add("Test.sink.test.class", TestSink.class.getName()) - .add("Test.*.source.filter.exclude", "s0") - .add("Test.source.s1.metric.filter.exclude", "X*") - .add("Test.sink.sink1.metric.filter.exclude", "Y*") - .add("Test.sink.sink2.metric.filter.exclude", "Y*") + .add("test.sink.test.class", TestSink.class.getName()) + .add("test.*.source.filter.exclude", "s0") + .add("test.source.s1.metric.filter.exclude", "X*") + .add("test.sink.sink1.metric.filter.exclude", "Y*") + .add("test.sink.sink2.metric.filter.exclude", "Y*") .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test")); MetricsSystemImpl ms = new MetricsSystemImpl("Test"); ms.start(); @@ -169,13 +169,14 @@ public static class TestSink implements MetricsSink { @Test public void testMultiThreadedPublish() throws Exception { final int numThreads = 10; new ConfigBuilder().add("*.period", 80) - .add("Test.sink.Collector." + MetricsConfig.QUEUE_CAPACITY_KEY, + .add("test.sink.collector." + MetricsConfig.QUEUE_CAPACITY_KEY, numThreads) .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test")); final MetricsSystemImpl ms = new MetricsSystemImpl("Test"); ms.start(); + final CollectingSink sink = new CollectingSink(numThreads); - ms.registerSink("Collector", + ms.registerSink("collector", "Collector of values from all threads.", sink); final TestSource[] sources = new TestSource[numThreads]; final Thread[] threads = new Thread[numThreads]; @@ -280,10 +281,10 @@ public void flush() { @Test public void testHangingSink() { new ConfigBuilder().add("*.period", 8) - .add("Test.sink.test.class", TestSink.class.getName()) - .add("Test.sink.hanging.retry.delay", "1") - .add("Test.sink.hanging.retry.backoff", "1.01") - .add("Test.sink.hanging.retry.count", "0") + .add("test.sink.test.class", TestSink.class.getName()) + .add("test.sink.hanging.retry.delay", "1") + .add("test.sink.hanging.retry.backoff", "1.01") + .add("test.sink.hanging.retry.count", "0") .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test")); MetricsSystemImpl ms = new MetricsSystemImpl("Test"); ms.start();