YARN-9642. Fix Memory Leak in AbstractYarnScheduler caused by timer. Contributed by Bibin A Chundatt.
This commit is contained in:
parent
6d7f01c92d
commit
d3ce53e507
|
@ -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 abstract class AbstractYarnScheduler
|
|||
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 @@ public abstract class AbstractYarnScheduler
|
|||
updateThread.start();
|
||||
}
|
||||
schedulingMonitorManager.startAll();
|
||||
createReleaseCache();
|
||||
super.serviceStart();
|
||||
}
|
||||
|
||||
|
@ -239,6 +241,12 @@ public abstract class AbstractYarnScheduler
|
|||
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 @@ public abstract class AbstractYarnScheduler
|
|||
|
||||
protected void createReleaseCache() {
|
||||
// Cleanup the cache after nm expire interval.
|
||||
new Timer().schedule(new TimerTask() {
|
||||
releaseCache.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
clearPendingContainerCache();
|
||||
|
|
Loading…
Reference in New Issue