YARN-9645. Fix Invalid event FINISHED_CONTAINERS_PULLED_BY_AM at NEW on NM restart. Contributed by Bilwa S T.
(cherry picked from commit 7a93be0f60
)
This commit is contained in:
parent
7c9cfc0996
commit
4866735cde
|
@ -205,6 +205,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,
|
||||
|
@ -1557,4 +1560,9 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
|
|||
attrMgr.getAttributesForNode(hostName);
|
||||
return nodeattrs.keySet();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public Set<ContainerId> getContainersToBeRemovedFromNM() {
|
||||
return containersToBeRemovedFromNM;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -1104,4 +1111,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());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue