diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractYarnScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractYarnScheduler.java index da5353014a..fe7379a5ab 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractYarnScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractYarnScheduler.java @@ -148,6 +148,7 @@ public abstract class AbstractYarnScheduler @VisibleForTesting Thread updateThread; private final Object updateThreadMonitor = new Object(); + private Timer releaseCache; /* * All schedulers which are inheriting AbstractYarnScheduler should use @@ -208,7 +209,7 @@ public void serviceInit(Configuration conf) throws Exception { nodeTracker.setConfiguredMaxAllocationWaitTime( configuredMaximumAllocationWaitTime); maxClusterLevelAppPriority = getMaxPriorityFromConf(conf); - createReleaseCache(); + this.releaseCache = new Timer("Pending Container Clear Timer"); autoUpdateContainers = conf.getBoolean(YarnConfiguration.RM_AUTO_UPDATE_CONTAINERS, YarnConfiguration.DEFAULT_RM_AUTO_UPDATE_CONTAINERS); @@ -230,6 +231,7 @@ protected void serviceStart() throws Exception { updateThread.start(); } schedulingMonitorManager.startAll(); + createReleaseCache(); super.serviceStart(); } @@ -239,6 +241,12 @@ protected void serviceStop() throws Exception { updateThread.interrupt(); updateThread.join(THREAD_JOIN_TIMEOUT_MS); } + + //Stop Timer + if (releaseCache != null) { + releaseCache.cancel(); + releaseCache = null; + } schedulingMonitorManager.stop(); super.serviceStop(); } @@ -635,7 +643,7 @@ private void recoverResourceRequestForContainer(RMContainer rmContainer) { protected void createReleaseCache() { // Cleanup the cache after nm expire interval. - new Timer().schedule(new TimerTask() { + releaseCache.schedule(new TimerTask() { @Override public void run() { clearPendingContainerCache();