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 e94dfe0d86..a565fe7565 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 @@ -216,6 +216,9 @@ RMNodeEventType.STARTED, new AddNodeTransition()) .addTransition(NodeState.NEW, NodeState.DECOMMISSIONED, RMNodeEventType.DECOMMISSION, new DeactivateNodeTransition(NodeState.DECOMMISSIONED)) + .addTransition(NodeState.NEW, NodeState.NEW, + RMNodeEventType.FINISHED_CONTAINERS_PULLED_BY_AM, + new AddContainersToBeRemovedFromNMTransition()) //Transitions from RUNNING state .addTransition(NodeState.RUNNING, @@ -1598,4 +1601,9 @@ public Set getAllNodeAttributes() { attrMgr.getAttributesForNode(hostName); return nodeattrs.keySet(); } + + @VisibleForTesting + public Set getContainersToBeRemovedFromNM() { + return containersToBeRemovedFromNM; + } } 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 fb2dd2019c..1f1e164cf5 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 @@ -195,6 +195,13 @@ private List getAppIdList() { return appIdList; } + private List getContainerIdList() { + List containerIdList = new ArrayList(); + containerIdList.add(BuilderUtils.newContainerId(BuilderUtils + .newApplicationAttemptId(BuilderUtils.newApplicationId(0, 0), 0), 0)); + return containerIdList; + } + private RMNodeStatusEvent getMockRMNodeStatusEventWithoutRunningApps() { NodeHealthStatus healthStatus = mock(NodeHealthStatus.class); Boolean yes = new Boolean(true); @@ -1105,4 +1112,15 @@ public void testForHandlingDuplicatedCompltedContainers() { Assert.assertEquals(1, hbrsp.getContainersToBeRemovedFromNM().size()); Assert.assertEquals(0, node.getCompletedContainers().size()); } + + @Test + public void testFinishedContainersPulledByAMOnNewNode() { + RMNodeImpl rmNode = getNewNode(); + NodeId nodeId = BuilderUtils.newNodeId("localhost", 0); + + rmNode.handle(new RMNodeFinishedContainersPulledByAMEvent(nodeId, + getContainerIdList())); + Assert.assertEquals(1, rmNode.getContainersToBeRemovedFromNM().size()); + + } }