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

(cherry picked from commit 26b5e6116f)
This commit is contained in:
Jason Lowe 2016-08-09 22:12:35 +00:00
parent bfc261f2a0
commit 5580626ea0
3 changed files with 16 additions and 3 deletions

View File

@ -10,6 +10,9 @@ Release 2.7.4 - UNRELEASED
OPTIMIZATIONS
YARN-5262. Optimize sending RMNodeFinishedContainersPulledByAMEvent for
every AM heartbeat (Rohith Sharma K S via jlowe)
BUG FIXES
YARN-5197. RM leaks containers if running container disappears from

View File

@ -763,9 +763,11 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
}
}
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;
@ -1713,6 +1715,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
eventHandler.handle(new RMNodeFinishedContainersPulledByAMEvent(nodeId,
containerIdList));
}
this.finishedContainersSentToAM.clear();
}
// Add am container to the list so that am container instance will be

View File

@ -1427,6 +1427,13 @@ public class TestRMAppAttemptTransitions {
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(