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:
parent
5ea35b2af2
commit
3b4d6ece1a
|
@ -823,10 +823,12 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finishedContainersSentToAM.putIfAbsent(nodeId, new ArrayList
|
if (!finishedContainers.isEmpty()) {
|
||||||
<ContainerStatus>());
|
finishedContainersSentToAM.putIfAbsent(nodeId,
|
||||||
|
new ArrayList<ContainerStatus>());
|
||||||
finishedContainersSentToAM.get(nodeId).addAll(finishedContainers);
|
finishedContainersSentToAM.get(nodeId).addAll(finishedContainers);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return returnList;
|
return returnList;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1841,6 +1843,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
||||||
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
|
||||||
|
|
|
@ -1444,6 +1444,13 @@ public class TestRMAppAttemptTransitions {
|
||||||
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(
|
||||||
|
|
Loading…
Reference in New Issue