YARN-5262. Optimize sending RMNodeFinishedContainersPulledByAMEvent for every AM heartbeat. Contributed by Rohith Sharma K S

(cherry picked from commit 26b5e6116f392b6be91dca57968259f87554ce33)
This commit is contained in:
Jason Lowe 2016-08-09 22:18:24 +00:00
parent 4feb17ea28
commit 2dc43a2054
3 changed files with 16 additions and 3 deletions

View File

@ -13,6 +13,9 @@ Release 2.6.5 - UNRELEASED
YARN-4690. Skip object allocation in FSAppAttempt#getResourceUsage when YARN-4690. Skip object allocation in FSAppAttempt#getResourceUsage when
possible (Ming Ma via sjlee) possible (Ming Ma via sjlee)
YARN-5262. Optimize sending RMNodeFinishedContainersPulledByAMEvent for
every AM heartbeat (Rohith Sharma K S via jlowe)
BUG FIXES BUG FIXES
YARN-2046. Out of band heartbeats are sent only on container kill and YARN-2046. Out of band heartbeats are sent only on container kill and

View File

@ -712,9 +712,11 @@ public List<ContainerStatus> pullJustFinishedContainers() {
} }
} }
finishedContainersSentToAM.putIfAbsent(nodeId, new ArrayList if (!finishedContainers.isEmpty()) {
<ContainerStatus>()); finishedContainersSentToAM.putIfAbsent(nodeId,
finishedContainersSentToAM.get(nodeId).addAll(finishedContainers); new ArrayList<ContainerStatus>());
finishedContainersSentToAM.get(nodeId).addAll(finishedContainers);
}
} }
return returnList; return returnList;
@ -1629,6 +1631,7 @@ private void sendFinishedContainersToNM() {
eventHandler.handle(new RMNodeFinishedContainersPulledByAMEvent(nodeId, eventHandler.handle(new RMNodeFinishedContainersPulledByAMEvent(nodeId,
containerIdList)); containerIdList));
} }
this.finishedContainersSentToAM.clear();
} }
// Add am container to the list so that am container instance will be // Add am container to the list so that am container instance will be

View File

@ -1317,6 +1317,13 @@ public void testFinishedContainer() {
Assert.assertTrue(applicationAttempt.getJustFinishedContainers().isEmpty()); Assert.assertTrue(applicationAttempt.getJustFinishedContainers().isEmpty());
Assert.assertEquals(0, getFinishedContainersSentToAM(applicationAttempt) Assert.assertEquals(0, getFinishedContainersSentToAM(applicationAttempt)
.size()); .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( private static List<ContainerStatus> getFinishedContainersSentToAM(