hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject git commit: HADOOP-11163. MetricsSystemImpl may miss a registered source. Contributed by Chuan Liu.
Date Sat, 04 Oct 2014 04:06:12 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 b335df9a9 -> a828ef15b


HADOOP-11163. MetricsSystemImpl may miss a registered source. Contributed by Chuan Liu.

(cherry picked from commit 69c9af91031f345d9511618877646b8756b17863)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a828ef15
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a828ef15
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a828ef15

Branch: refs/heads/branch-2
Commit: a828ef15b0e2c63dac6854910bc9ae3b5f5ef755
Parents: b335df9
Author: cnauroth <cnauroth@apache.org>
Authored: Fri Oct 3 21:01:28 2014 -0700
Committer: cnauroth <cnauroth@apache.org>
Committed: Fri Oct 3 21:05:05 2014 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  2 ++
 .../hadoop/metrics2/impl/MetricsSystemImpl.java |  2 +-
 .../metrics2/impl/TestMetricsSystemImpl.java    | 32 ++++++++++++++++++++
 3 files changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a828ef15/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 9792075..cadb0b6 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -589,6 +589,8 @@ Release 2.6.0 - UNRELEASED
     HADOOP-11117 UGI HadoopLoginModule doesn't catch & wrap all
     kerberos-related exceptions (stevel)
 
+    HADOOP-11163 MetricsSystemImpl may miss a registered source. (cnauroth)
+
 Release 2.5.1 - 2014-09-05
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a828ef15/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java
----------------------------------------------------------------------
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 5e6c9ae..4507e35 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
@@ -234,7 +234,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource
{
     }
     // We want to re-register the source to pick up new config when the
     // metrics system restarts.
-    register(name, new AbstractCallback() {
+    register(finalName, new AbstractCallback() {
       @Override public void postStart() {
         registerSource(finalName, finalDesc, s);
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a828ef15/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java
----------------------------------------------------------------------
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 0122045..d59e80b 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
@@ -397,6 +397,24 @@ public class TestMetricsSystemImpl {
     ms.shutdown();
   }
 
+  @Test public void testRegisterSourceWithoutName() {
+    MetricsSystem ms = new MetricsSystemImpl();
+    TestSource ts = new TestSource("ts");
+    TestSource2 ts2 = new TestSource2("ts2");
+    ms.register(ts);
+    ms.register(ts2);
+    ms.init("TestMetricsSystem");
+    // if metrics source is registered without name,
+    // the class name will be used as the name
+    MetricsSourceAdapter sa = ((MetricsSystemImpl) ms)
+        .getSourceAdapter("TestSource");
+    assertNotNull(sa);
+    MetricsSourceAdapter sa2 = ((MetricsSystemImpl) ms)
+        .getSourceAdapter("TestSource2");
+    assertNotNull(sa2);
+    ms.shutdown();
+  }
+
   private void checkMetricsRecords(List<MetricsRecord> recs) {
     LOG.debug(recs);
     MetricsRecord r = recs.get(0);
@@ -430,6 +448,20 @@ public class TestMetricsSystemImpl {
     }
   }
 
+  @Metrics(context="test")
+  private static class TestSource2 {
+    @Metric("C1 desc") MutableCounterLong c1;
+    @Metric("XXX desc") MutableCounterLong xxx;
+    @Metric("G1 desc") MutableGaugeLong g1;
+    @Metric("YYY desc") MutableGaugeLong yyy;
+    @Metric MutableRate s1;
+    final MetricsRegistry registry;
+
+    TestSource2(String recName) {
+      registry = new MetricsRegistry(recName);
+    }
+  }
+
   private static String getPluginUrlsAsString() {
     return "file:metrics2-test-plugin.jar";
   }


Mime
View raw message