Browse Source

YARN-43. Fix TestResourceTrackerService to not depend on test order and thus pass on JDK7. Contributed by Thomas Graves.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1399066 13f79535-47bb-0310-9956-ffa450edef68
Vinod Kumar Vavilapalli 12 years ago
parent
commit
ab727f4966

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -148,6 +148,9 @@ Release 0.23.5 - UNRELEASED
     YARN-161. Fix multiple compiler warnings for unchecked operations in YARN
     YARN-161. Fix multiple compiler warnings for unchecked operations in YARN
     common. (Chris Nauroth via vinodkv)
     common. (Chris Nauroth via vinodkv)
 
 
+    YARN-43. Fix TestResourceTrackerService to not depend on test order and thus
+    pass on JDK7. (Thomas Graves via vinodkv)
+
   OPTIMIZATIONS
   OPTIMIZATIONS
 
 
   BUG FIXES
   BUG FIXES

+ 8 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClusterMetrics.java

@@ -30,7 +30,7 @@ import org.apache.hadoop.metrics2.annotation.Metrics;
 import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
 import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
 import org.apache.hadoop.metrics2.lib.MetricsRegistry;
 import org.apache.hadoop.metrics2.lib.MetricsRegistry;
 import org.apache.hadoop.metrics2.lib.MutableGaugeInt;
 import org.apache.hadoop.metrics2.lib.MutableGaugeInt;
-import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEventType;
+import com.google.common.annotations.VisibleForTesting;
 
 
 @InterfaceAudience.Private
 @InterfaceAudience.Private
 @Metrics(context="yarn")
 @Metrics(context="yarn")
@@ -71,6 +71,12 @@ public class ClusterMetrics {
       ms.register("ClusterMetrics", "Metrics for the Yarn Cluster", INSTANCE);
       ms.register("ClusterMetrics", "Metrics for the Yarn Cluster", INSTANCE);
     }
     }
   }
   }
+
+  @VisibleForTesting
+  synchronized static void destroy() {
+    isInitialized.set(false);
+    INSTANCE = null;
+  }
   
   
   //Active Nodemanagers
   //Active Nodemanagers
   public int getNumActiveNMs() {
   public int getNumActiveNMs() {
@@ -136,4 +142,5 @@ public class ClusterMetrics {
   public void decrNumActiveNodes() {
   public void decrNumActiveNodes() {
     numActiveNMs.decr();
     numActiveNMs.decr();
   }
   }
+
 }
 }

+ 1 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java

@@ -414,6 +414,7 @@ public class TestResourceTrackerService {
     if (hostFile != null && hostFile.exists()) {
     if (hostFile != null && hostFile.exists()) {
       hostFile.delete();
       hostFile.delete();
     }
     }
+    ClusterMetrics.destroy();
     if (rm != null) {
     if (rm != null) {
       rm.stop();
       rm.stop();
     }
     }