diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java index cec9915e0d..6070d02217 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java @@ -1464,6 +1464,11 @@ public int getQueueSize() { return nodeUpdateQueue.size(); } + // For test only. + @VisibleForTesting + public Map getUpdatedExistContainers() { + return this.updatedExistContainers; + } // For test only. @VisibleForTesting public Set getLaunchedContainers() { @@ -1582,6 +1587,7 @@ private void handleContainerStatus(List containerStatuses) { } else { // A finished container launchedContainers.remove(containerId); + updatedExistContainers.remove(containerId); if (completedContainers.add(containerId)) { newlyCompletedContainers.add(remoteContainer); } @@ -1595,6 +1601,7 @@ private void handleContainerStatus(List containerStatuses) { findLostContainers(numRemoteRunningContainers, containerStatuses); for (ContainerStatus remoteContainer : lostContainers) { ContainerId containerId = remoteContainer.getContainerId(); + updatedExistContainers.remove(containerId); if (completedContainers.add(containerId)) { newlyCompletedContainers.add(remoteContainer); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java index b21bf394ea..dad27839cf 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java @@ -1096,6 +1096,12 @@ public void testDisappearingContainer() { node.getLaunchedContainers().contains(cid1)); Assert.assertTrue("second container not running", node.getLaunchedContainers().contains(cid2)); + assertEquals("unexpected number of running containers", + 2, node.getUpdatedExistContainers().size()); + Assert.assertTrue("first container not running", + node.getUpdatedExistContainers().containsKey(cid1)); + Assert.assertTrue("second container not running", + node.getUpdatedExistContainers().containsKey(cid2)); assertEquals("already completed containers", 0, completedContainers.size()); containerStats.remove(0); @@ -1115,6 +1121,10 @@ public void testDisappearingContainer() { 1, node.getLaunchedContainers().size()); Assert.assertTrue("second container not running", node.getLaunchedContainers().contains(cid2)); + assertEquals("unexpected number of running containers", + 1, node.getUpdatedExistContainers().size()); + Assert.assertTrue("second container not running", + node.getUpdatedExistContainers().containsKey(cid2)); } @Test