hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jzh...@apache.org
Subject hadoop git commit: Revert "HADOOP-14954. MetricsSystemImpl#init should increment refCount when already initialized. Contributed by John Zhuge."
Date Mon, 23 Oct 2017 22:35:15 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 0f2a69127 -> c904d60c3


Revert "HADOOP-14954. MetricsSystemImpl#init should increment refCount when already initialized.
Contributed by John Zhuge."

This reverts commit 14b3c2695b152285ed2919f2aa5a25e247c47871.


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

Branch: refs/heads/trunk
Commit: c904d60c38fe2720513a4824a56e9e8ebef6e17f
Parents: 0f2a691
Author: John Zhuge <jzhuge@apache.org>
Authored: Mon Oct 23 15:29:12 2017 -0700
Committer: John Zhuge <jzhuge@apache.org>
Committed: Mon Oct 23 15:32:25 2017 -0700

----------------------------------------------------------------------
 .../hadoop/metrics2/impl/MetricsSystemImpl.java | 12 +----
 .../metrics2/impl/TestMetricsSystemImpl.java    | 46 --------------------
 2 files changed, 1 insertion(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c904d60c/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 c507a77..ee1672e 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
@@ -140,16 +140,6 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource
{
     this(null);
   }
 
-  @VisibleForTesting
-  boolean isMonitoring() {
-    return monitoring;
-  }
-
-  @VisibleForTesting
-  int getRefCount() {
-    return refCount;
-  }
-
   /**
    * Initialized the metrics system with a prefix.
    * @param prefix  the system will look for configs with the prefix
@@ -157,12 +147,12 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource
{
    */
   @Override
   public synchronized MetricsSystem init(String prefix) {
-    ++refCount;
     if (monitoring && !DefaultMetricsSystem.inMiniClusterMode()) {
       LOG.warn(this.prefix +" metrics system already initialized!");
       return this;
     }
     this.prefix = checkNotNull(prefix, "prefix");
+    ++refCount;
     if (monitoring) {
       // in mini cluster mode
       LOG.info(this.prefix +" metrics system started (again)");

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c904d60c/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 879de2d..abd1b13 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
@@ -26,8 +26,6 @@ import java.util.concurrent.atomic.*;
 
 import javax.annotation.Nullable;
 
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -561,50 +559,6 @@ public class TestMetricsSystemImpl {
     ms.shutdown();
   }
 
-  @Test
-  public void testInitShutdown() {
-    boolean oldMode = DefaultMetricsSystem.inMiniClusterMode();
-    try {
-      DefaultMetricsSystem.setMiniClusterMode(true);
-      runInitShutdownTests();
-
-      DefaultMetricsSystem.setMiniClusterMode(false);
-      runInitShutdownTests();
-    } finally {
-      DefaultMetricsSystem.setMiniClusterMode(oldMode);
-    }
-  }
-
-  private void runInitShutdownTests() {
-    MetricsSystemImpl ms = new MetricsSystemImpl();
-    Assert.assertThat(ms.isMonitoring(), CoreMatchers.is(false));
-    Assert.assertThat(ms.getRefCount(), CoreMatchers.is(0));
-
-    ms.init("TestMetricsSystem1");
-    Assert.assertThat(ms.isMonitoring(), CoreMatchers.is(true));
-    Assert.assertThat(ms.getRefCount(), CoreMatchers.is(1));
-
-    ms.shutdown();
-    Assert.assertThat(ms.isMonitoring(), CoreMatchers.is(false));
-    Assert.assertThat(ms.getRefCount(), CoreMatchers.is(0));
-
-    ms.init("TestMetricsSystem2");
-    Assert.assertThat(ms.isMonitoring(), CoreMatchers.is(true));
-    Assert.assertThat(ms.getRefCount(), CoreMatchers.is(1));
-
-    ms.init("TestMetricsSystem3");
-    Assert.assertThat(ms.isMonitoring(), CoreMatchers.is(true));
-    Assert.assertThat(ms.getRefCount(), CoreMatchers.is(2));
-
-    ms.shutdown();
-    Assert.assertThat(ms.isMonitoring(), CoreMatchers.is(true));
-    Assert.assertThat(ms.getRefCount(), CoreMatchers.is(1));
-
-    ms.shutdown();
-    Assert.assertThat(ms.isMonitoring(), CoreMatchers.is(false));
-    Assert.assertThat(ms.getRefCount(), CoreMatchers.is(0));
-  }
-
   @Metrics(context="test")
   private static class TestSource {
     @Metric("C1 desc") MutableCounterLong c1;


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message