diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java index f561dbb..b26fdbb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java @@ -358,11 +358,10 @@ private NodeStatus getNodeStatus(int responseId) throws IOException { List containerStatuses = new ArrayList(); for (Container container : this.context.getContainers().values()) { ContainerId containerId = container.getContainerId(); - ApplicationId applicationId = container.getContainerId() - .getApplicationAttemptId().getApplicationId(); + ApplicationId applicationId = containerId.getApplicationAttemptId() + .getApplicationId(); org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus = container.cloneAndGetContainerStatus(); - containerStatuses.add(containerStatus); if (containerStatus.getState() == ContainerState.COMPLETE) { if (isApplicationStopped(applicationId)) { if (LOG.isDebugEnabled()) { @@ -371,11 +370,16 @@ private NodeStatus getNodeStatus(int responseId) throws IOException { } context.getContainers().remove(containerId); } else { - // Adding to finished containers cache. Cache will keep it around at - // least for #durationToTrackStoppedContainers duration. In the - // subsequent call to stop container it will get removed from cache. - addCompletedContainer(container.getContainerId()); + if (!isContainerRecentlyStopped(containerId)) { + containerStatuses.add(containerStatus); + // Adding to finished containers cache. Cache will keep it around at + // least for #durationToTrackStoppedContainers duration. In the + // subsequent call to stop container it will get removed from cache. + addCompletedContainer(containerId); + } } + } else { + containerStatuses.add(containerStatus); } } if (LOG.isDebugEnabled()) { @@ -397,8 +401,8 @@ private NodeStatus getNodeStatus(int responseId) throws IOException { new ArrayList(); for (Container container : this.context.getContainers().values()) { ContainerId containerId = container.getContainerId(); - ApplicationId applicationId = container.getContainerId() - .getApplicationAttemptId().getApplicationId(); + ApplicationId applicationId = containerId.getApplicationAttemptId() + .getApplicationId(); if (!this.context.getApplications().containsKey(applicationId)) { context.getContainers().remove(containerId); continue; @@ -410,7 +414,7 @@ private NodeStatus getNodeStatus(int responseId) throws IOException { // Adding to finished containers cache. Cache will keep it around at // least for #durationToTrackStoppedContainers duration. In the // subsequent call to stop container it will get removed from cache. - addCompletedContainer(container.getContainerId()); + addCompletedContainer(containerId); } } LOG.info("Sending out " + containerStatuses.size()