YARN-9645. Fix Invalid event FINISHED_CONTAINERS_PULLED_BY_AM at NEW on NM restart. Contributed by Bilwa S T.

This commit is contained in:
bibinchundatt 2019-07-16 14:03:22 +05:30
parent 395cb3cfd7
commit 7a93be0f60
2 changed files with 26 additions and 0 deletions

View File

@ -216,6 +216,9 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
.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 class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
attrMgr.getAttributesForNode(hostName);
return nodeattrs.keySet();
}
@VisibleForTesting
public Set<ContainerId> getContainersToBeRemovedFromNM() {
return containersToBeRemovedFromNM;
}
}

View File

@ -195,6 +195,13 @@ public class TestRMNodeTransitions {
return appIdList;
}
private List<ContainerId> getContainerIdList() {
List<ContainerId> containerIdList = new ArrayList<ContainerId>();
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 class TestRMNodeTransitions {
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());
}
}