YARN-5262. Optimize sending RMNodeFinishedContainersPulledByAMEvent for every AM heartbeat.
(cherry picked from commit 26b5e6116f392b6be91dca57968259f87554ce33)
This commit is contained in:
parent
1e34763181
commit
d3fc1bddea
@ -826,9 +826,11 @@ public List<ContainerStatus> pullJustFinishedContainers() {
|
||||
}
|
||||
}
|
||||
|
||||
finishedContainersSentToAM.putIfAbsent(nodeId, new ArrayList
|
||||
<ContainerStatus>());
|
||||
finishedContainersSentToAM.get(nodeId).addAll(finishedContainers);
|
||||
if (!finishedContainers.isEmpty()) {
|
||||
finishedContainersSentToAM.putIfAbsent(nodeId,
|
||||
new ArrayList<ContainerStatus>());
|
||||
finishedContainersSentToAM.get(nodeId).addAll(finishedContainers);
|
||||
}
|
||||
}
|
||||
|
||||
return returnList;
|
||||
@ -1871,6 +1873,7 @@ private void sendFinishedContainersToNM() {
|
||||
eventHandler.handle(new RMNodeFinishedContainersPulledByAMEvent(nodeId,
|
||||
containerIdList));
|
||||
}
|
||||
this.finishedContainersSentToAM.clear();
|
||||
}
|
||||
|
||||
// Add am container to the list so that am container instance will be
|
||||
|
@ -1444,6 +1444,13 @@ public void testFinishedContainer() {
|
||||
Assert.assertTrue(applicationAttempt.getJustFinishedContainers().isEmpty());
|
||||
Assert.assertEquals(0, getFinishedContainersSentToAM(applicationAttempt)
|
||||
.size());
|
||||
|
||||
// verify if no containers to acknowledge to NM then event should not be
|
||||
// triggered. Number of times event invoked is 1 i.e on second pull
|
||||
containerStatuses = applicationAttempt.pullJustFinishedContainers();
|
||||
Assert.assertEquals(0, containerStatuses.size());
|
||||
Mockito.verify(rmnodeEventHandler, times(1))
|
||||
.handle(Mockito.any(RMNodeEvent.class));
|
||||
}
|
||||
|
||||
private static List<ContainerStatus> getFinishedContainersSentToAM(
|
||||
|
Loading…
x
Reference in New Issue
Block a user