浏览代码

YARN-460. CS user left in list of active users for the queue even when application finished (tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1462486 13f79535-47bb-0310-9956-ffa450edef68
Thomas Graves 12 年之前
父节点
当前提交
01aabf7363

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -499,6 +499,9 @@ Release 0.23.7 - UNRELEASED
     YARN-109. .tmp file is not deleted for localized archives (Mayank Bansal 
     via bobby)
 
+    YARN-460. CS user left in list of active users for the queue even when 
+    application finished (tgraves)
+
 Release 0.23.6 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 8 - 0
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

@@ -504,6 +504,14 @@ implements ResourceScheduler, CapacitySchedulerContext, Configurable {
 
     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()) {

+ 15 - 1
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

@@ -91,6 +91,9 @@ public class FiCaSchedulerApp extends SchedulerApplication {
 
   final Map<Priority, Map<NodeId, RMContainer>> reservedContainers = 
       new HashMap<Priority, Map<NodeId, RMContainer>>();
+
+  private boolean isStopped = false;
+
   
   /**
    * Count how many times the application has been given an opportunity
@@ -132,7 +135,9 @@ public class FiCaSchedulerApp extends SchedulerApplication {
 
   public synchronized void updateResourceRequests(
       List<ResourceRequest> requests) {
-    this.appSchedulingInfo.updateResourceRequests(requests);
+    if (!isStopped) {
+      this.appSchedulingInfo.updateResourceRequests(requests);
+    }
   }
 
   public Map<String, ResourceRequest> getResourceRequests(Priority priority) {
@@ -168,6 +173,10 @@ public class FiCaSchedulerApp extends SchedulerApplication {
     return this.appSchedulingInfo.isPending();
   }
 
+  public synchronized boolean isStopped() {
+    return this.isStopped;
+  }
+
   public String getQueueName() {
     return this.appSchedulingInfo.getQueueName();
   }
@@ -183,6 +192,7 @@ public class FiCaSchedulerApp extends SchedulerApplication {
 
   public synchronized void stop(RMAppAttemptState rmAppAttemptFinalState) {
     // Cleanup all scheduling information
+    this.isStopped = true;
     this.appSchedulingInfo.stop(rmAppAttemptFinalState);
   }
 
@@ -234,6 +244,10 @@ public class FiCaSchedulerApp extends SchedulerApplication {
   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

+ 9 - 0
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

@@ -252,6 +252,15 @@ public class FifoScheduler implements ResourceScheduler, Configurable {
     }
 
     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 +