YARN-9396. Fixed duplicated RM Container created event to ATS.

Contributed by Prabhu Joseph
This commit is contained in:
Eric Yang 2019-04-04 13:01:56 -04:00
parent c90736350b
commit 8d150067e2
2 changed files with 7 additions and 4 deletions

View File

@ -608,9 +608,12 @@ public void transition(RMContainerImpl container, RMContainerEvent event) {
container.eventHandler.handle(new RMAppRunningOnNodeEvent(container
.getApplicationAttemptId().getApplicationId(), container.nodeId));
// Opportunistic containers move directly from NEW to ACQUIRED
if (container.getState() == RMContainerState.NEW) {
publishNonAMContainerEventstoATS(container);
}
}
}
private static final class ContainerAcquiredWhileRunningTransition extends
BaseTransition {

View File

@ -150,7 +150,7 @@ public void testReleaseWhileRunning() {
RMContainerEventType.LAUNCHED));
drainDispatcher.await();
assertEquals(RMContainerState.RUNNING, rmContainer.getState());
verify(publisher, times(2)).containerCreated(any(RMContainer.class),
verify(publisher, times(1)).containerCreated(any(RMContainer.class),
anyLong());
assertEquals("http://host:3465/node/containerlogs/container_1_0001_01_000001/user",
rmContainer.getLogURL());
@ -253,7 +253,7 @@ public void testExpireWhileRunning() {
RMContainerEventType.ACQUIRED));
drainDispatcher.await();
assertEquals(RMContainerState.ACQUIRED, rmContainer.getState());
verify(publisher, times(2)).containerCreated(any(RMContainer.class),
verify(publisher, times(1)).containerCreated(any(RMContainer.class),
anyLong());
rmContainer.handle(new RMContainerEvent(containerId,
@ -345,7 +345,7 @@ public void testStoreAllContainerMetrics() throws Exception {
// RMContainer should be publishing system metrics for all containers.
// Since there is 1 AM container and 1 non-AM container, there should be 2
// container created events and 2 container finished events.
verify(publisher, times(4)).containerCreated(any(RMContainer.class),
verify(publisher, times(2)).containerCreated(any(RMContainer.class),
anyLong());
verify(publisher, times(2)).containerFinished(any(RMContainer.class), anyLong());
}