YARN-10447. TestLeafQueue: ActivitiesManager thread might interfere with ongoing stubbing. Contributed by Peter Bacsko

This commit is contained in:
Adam Antal 2020-10-01 11:42:04 +02:00
parent d68d2a5c1e
commit bb8446e80c
2 changed files with 18 additions and 3 deletions

View File

@ -245,6 +245,8 @@ public Configuration getConf() {
private CSMaxRunningAppsEnforcer maxRunningEnforcer;
private boolean activitiesManagerEnabled = true;
public CapacityScheduler() {
super(CapacityScheduler.class.getName());
this.maxRunningEnforcer = new CSMaxRunningAppsEnforcer(this);
@ -342,7 +344,9 @@ void initScheduler(Configuration configuration) throws
this.workflowPriorityMappingsMgr = new WorkflowPriorityMappingsManager();
this.activitiesManager = new ActivitiesManager(rmContext);
if (activitiesManagerEnabled) {
activitiesManager.init(conf);
}
initializeQueues(this.conf);
this.isLazyPreemptionEnabled = conf.getLazyPreemptionEnabled();
@ -400,7 +404,9 @@ void initScheduler(Configuration configuration) throws
private void startSchedulerThreads() {
writeLock.lock();
try {
if (activitiesManagerEnabled) {
activitiesManager.start();
}
if (scheduleAsynchronously) {
Preconditions.checkNotNull(asyncSchedulerThreads,
"asyncSchedulerThreads is null");
@ -434,7 +440,9 @@ public void serviceStart() throws Exception {
public void serviceStop() throws Exception {
writeLock.lock();
try {
if (activitiesManagerEnabled) {
this.activitiesManager.stop();
}
if (scheduleAsynchronously && asyncSchedulerThreads != null) {
for (Thread t : asyncSchedulerThreads) {
t.interrupt();
@ -3286,6 +3294,7 @@ public void setMaxRunningAppsEnforcer(CSMaxRunningAppsEnforcer enforcer) {
this.maxRunningEnforcer = enforcer;
}
/**
* Returning true as capacity scheduler supports placement constraints.
*/
@ -3293,4 +3302,9 @@ public void setMaxRunningAppsEnforcer(CSMaxRunningAppsEnforcer enforcer) {
public boolean placementConstraintEnabled() {
return true;
}
@VisibleForTesting
public void setActivitiesManagerEnabled(boolean enabled) {
this.activitiesManagerEnabled = enabled;
}
}

View File

@ -162,6 +162,7 @@ private void setUpWithNodeLabels() throws Exception {
private void setUpInternal(ResourceCalculator rC, boolean withNodeLabels)
throws Exception {
CapacityScheduler spyCs = new CapacityScheduler();
spyCs.setActivitiesManagerEnabled(false);
queues = new CSQueueStore();
cs = spy(spyCs);
rmContext = TestUtils.getMockRMContext();