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/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java index 678fd2d6f8..5a7db5826c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java @@ -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); - activitiesManager.init(conf); + 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 { - activitiesManager.start(); + 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 { - this.activitiesManager.stop(); + 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; + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java index 3bfb0ab688..02545cbc32 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java @@ -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();