hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java appAttempt.finishedContainersSentToAM.putIfAbsent(nodeId, new ArrayList()); appAttempt.finishedContainersSentToAM.get(nodeId).add(containerStatus); + for (Map.Entry> justFinishedContainer + : appAttempt.justFinishedContainers.entrySet()) { + List justFinishedContainerStatus = justFinishedContainer.getValue(); + NodeId justFinishedNodeId = justFinishedContainer.getKey(); + appAttempt.finishedContainersSentToAM.putIfAbsent(justFinishedNodeId,new ArrayList()); + appAttempt.finishedContainersSentToAM.get(justFinishedNodeId).addAll(justFinishedContainerStatus); + } appAttempt.sendFinishedContainersToNM(); } else { appAttempt.sendFinishedAMContainerToNM(nodeId, @@ -2015,9 +2025,17 @@ private static void addJustFinishedContainer(RMAppAttemptImpl appAttempt, transition(RMAppAttemptImpl appAttempt, RMAppAttemptEvent event) { RMAppAttemptContainerFinishedEvent containerFinishedEvent = (RMAppAttemptContainerFinishedEvent) event; - - // Normal container. Add it in completed containers list - addJustFinishedContainer(appAttempt, containerFinishedEvent); + + // This container may be normal container or amcontainer. + // Add it in completed containers list, then send to NM + //addJustFinishedContainer(appAttempt, containerFinishedEvent); + NodeId nodeId = containerFinishedEvent.getNodeId(); + ContainerStatus containerFinished = containerFinishedEvent.getContainerStatus(); + appAttempt.finishedContainersSentToAM.putIfAbsent(nodeId, new ArrayList()); + appAttempt.finishedContainersSentToAM.get(nodeId).add(containerFinished); + appAttempt.sendFinishedContainersToNM(); + appAttempt.finishedContainersSentToAM.clear(); } }