From ab727f4966b9f177784b84ac130a72e44347ecc4 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Wed, 17 Oct 2012 01:24:50 +0000 Subject: [PATCH] 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 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../yarn/server/resourcemanager/ClusterMetrics.java | 9 ++++++++- .../resourcemanager/TestResourceTrackerService.java | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 22ead622a5..c575c3b964 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/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 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 BUG FIXES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClusterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClusterMetrics.java index e187fbdbde..5c94ef4190 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClusterMetrics.java +++ b/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.lib.DefaultMetricsSystem; import org.apache.hadoop.metrics2.lib.MetricsRegistry; import org.apache.hadoop.metrics2.lib.MutableGaugeInt; -import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEventType; +import com.google.common.annotations.VisibleForTesting; @InterfaceAudience.Private @Metrics(context="yarn") @@ -71,6 +71,12 @@ private static void registerMetrics() { ms.register("ClusterMetrics", "Metrics for the Yarn Cluster", INSTANCE); } } + + @VisibleForTesting + synchronized static void destroy() { + isInitialized.set(false); + INSTANCE = null; + } //Active Nodemanagers public int getNumActiveNMs() { @@ -136,4 +142,5 @@ public void incrNumActiveNodes() { public void decrNumActiveNodes() { numActiveNMs.decr(); } + } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java index 45b0c9933d..7e5b5da935 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java +++ b/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 void tearDown() { if (hostFile != null && hostFile.exists()) { hostFile.delete(); } + ClusterMetrics.destroy(); if (rm != null) { rm.stop(); }