Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java (revision 1462469) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java (working copy) @@ -252,6 +252,15 @@ } synchronized (application) { + + // make sure we aren't stopping/removing the application + // when the allocate comes in + if (application.isStopped()) { + LOG.info("Calling allocate on a stopped " + + "application " + applicationAttemptId); + return EMPTY_ALLOCATION; + } + if (!ask.isEmpty()) { LOG.debug("allocate: pre-update" + " applicationId=" + applicationAttemptId + Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java (revision 1462469) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java (working copy) @@ -91,6 +91,9 @@ final Map> reservedContainers = new HashMap>(); + + private boolean isStopped = false; + /** * Count how many times the application has been given an opportunity @@ -132,7 +135,9 @@ public synchronized void updateResourceRequests( List requests) { - this.appSchedulingInfo.updateResourceRequests(requests); + if (!isStopped) { + this.appSchedulingInfo.updateResourceRequests(requests); + } } public Map getResourceRequests(Priority priority) { @@ -168,6 +173,10 @@ return this.appSchedulingInfo.isPending(); } + public synchronized boolean isStopped() { + return this.isStopped; + } + public String getQueueName() { return this.appSchedulingInfo.getQueueName(); } @@ -183,6 +192,7 @@ public synchronized void stop(RMAppAttemptState rmAppAttemptFinalState) { // Cleanup all scheduling information + this.isStopped = true; this.appSchedulingInfo.stop(rmAppAttemptFinalState); } @@ -234,6 +244,10 @@ synchronized public RMContainer allocate(NodeType type, FiCaSchedulerNode node, Priority priority, ResourceRequest request, Container container) { + + if (isStopped) { + return null; + } // Required sanity check - AM can call 'allocate' to update resource // request without locking the scheduler, hence we need to check Index: 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 =================================================================== --- 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 (revision 1462469) +++ 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 (working copy) @@ -504,6 +504,14 @@ synchronized (application) { + // make sure we aren't stopping/removing the application + // when the allocate comes in + if (application.isStopped()) { + LOG.info("Calling allocate on a stopped " + + "application " + applicationAttemptId); + return EMPTY_ALLOCATION; + } + if (!ask.isEmpty()) { if(LOG.isDebugEnabled()) {