From 32d3e4e9f533154cc4f9f8e553c98c48240e53be Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Wed, 17 Oct 2012 01:29:12 +0000 Subject: [PATCH] YARN-43. Fix TestResourceTrackerService to not depend on test order and thus pass on JDK7. Contributed by Thomas Graves. svn merge --ignore-ancestry -c 1399066 ../../trunk/ git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1399067 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 5f5973f36dd..c69c3417443 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -130,6 +130,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 e187fbdbdec..5c94ef4190d 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.annotation.Metrics; 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 @@ public class ClusterMetrics { 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 class ClusterMetrics { 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 45b0c9933d0..7e5b5da9356 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 class TestResourceTrackerService { if (hostFile != null && hostFile.exists()) { hostFile.delete(); } + ClusterMetrics.destroy(); if (rm != null) { rm.stop(); }