use of org.apache.hadoop.yarn.server.api.ContainerTerminationContext in project hadoop by apache.
the class TestPerNodeTimelineCollectorsAuxService method testRemoveApplication.
@Test
public void testRemoveApplication() throws Exception {
auxService = createCollectorAndAddApplication();
// auxService should have a single app
assertTrue(auxService.hasApplication(appAttemptId.getApplicationId()));
ContainerId containerId = getAMContainerId();
ContainerTerminationContext context = mock(ContainerTerminationContext.class);
when(context.getContainerId()).thenReturn(containerId);
when(context.getContainerType()).thenReturn(ContainerType.APPLICATION_MASTER);
auxService.stopContainer(context);
// auxService should have the app's collector and need to remove only after
// a configured period
assertTrue(auxService.hasApplication(appAttemptId.getApplicationId()));
for (int i = 0; i < 4; i++) {
Thread.sleep(500L);
if (!auxService.hasApplication(appAttemptId.getApplicationId())) {
break;
}
}
// auxService should not have that app
assertFalse(auxService.hasApplication(appAttemptId.getApplicationId()));
auxService.close();
}
use of org.apache.hadoop.yarn.server.api.ContainerTerminationContext in project hadoop by apache.
the class TestPerNodeTimelineCollectorsAuxService method testRemoveApplicationNonAMContainer.
@Test
public void testRemoveApplicationNonAMContainer() throws Exception {
auxService = createCollectorAndAddApplication();
// auxService should have a single app
assertTrue(auxService.hasApplication(appAttemptId.getApplicationId()));
// not an AM
ContainerId containerId = getContainerId(2L);
ContainerTerminationContext context = mock(ContainerTerminationContext.class);
when(context.getContainerId()).thenReturn(containerId);
auxService.stopContainer(context);
// auxService should still have that app
assertTrue(auxService.hasApplication(appAttemptId.getApplicationId()));
auxService.close();
}
use of org.apache.hadoop.yarn.server.api.ContainerTerminationContext in project hadoop by apache.
the class AuxServices method handle.
@Override
public void handle(AuxServicesEvent event) {
LOG.info("Got event " + event.getType() + " for appId " + event.getApplicationID());
switch(event.getType()) {
case APPLICATION_INIT:
LOG.info("Got APPLICATION_INIT for service " + event.getServiceID());
AuxiliaryService service = null;
try {
service = serviceMap.get(event.getServiceID());
service.initializeApplication(new ApplicationInitializationContext(event.getUser(), event.getApplicationID(), event.getServiceData()));
} catch (Throwable th) {
logWarningWhenAuxServiceThrowExceptions(service, AuxServicesEventType.APPLICATION_INIT, th);
}
break;
case APPLICATION_STOP:
for (AuxiliaryService serv : serviceMap.values()) {
try {
serv.stopApplication(new ApplicationTerminationContext(event.getApplicationID()));
} catch (Throwable th) {
logWarningWhenAuxServiceThrowExceptions(serv, AuxServicesEventType.APPLICATION_STOP, th);
}
}
break;
case CONTAINER_INIT:
for (AuxiliaryService serv : serviceMap.values()) {
try {
serv.initializeContainer(new ContainerInitializationContext(event.getUser(), event.getContainer().getContainerId(), event.getContainer().getResource(), event.getContainer().getContainerTokenIdentifier().getContainerType()));
} catch (Throwable th) {
logWarningWhenAuxServiceThrowExceptions(serv, AuxServicesEventType.CONTAINER_INIT, th);
}
}
break;
case CONTAINER_STOP:
for (AuxiliaryService serv : serviceMap.values()) {
try {
serv.stopContainer(new ContainerTerminationContext(event.getUser(), event.getContainer().getContainerId(), event.getContainer().getResource(), event.getContainer().getContainerTokenIdentifier().getContainerType()));
} catch (Throwable th) {
logWarningWhenAuxServiceThrowExceptions(serv, AuxServicesEventType.CONTAINER_STOP, th);
}
}
break;
default:
throw new RuntimeException("Unknown type: " + event.getType());
}
}
Aggregations