use of org.apache.hadoop.yarn.server.api.ContainerInitializationContext in project hadoop by apache.
the class TestPerNodeTimelineCollectorsAuxService method createCollectorAndAddApplication.
private PerNodeTimelineCollectorsAuxService createCollectorAndAddApplication() {
PerNodeTimelineCollectorsAuxService service = createCollector();
// create an AM container
ContainerId containerId = getAMContainerId();
ContainerInitializationContext context = mock(ContainerInitializationContext.class);
when(context.getContainerId()).thenReturn(containerId);
when(context.getContainerType()).thenReturn(ContainerType.APPLICATION_MASTER);
service.initializeContainer(context);
return service;
}
use of org.apache.hadoop.yarn.server.api.ContainerInitializationContext in project hadoop by apache.
the class TestPerNodeTimelineCollectorsAuxService method testAddApplicationNonAMContainer.
@Test
public void testAddApplicationNonAMContainer() throws Exception {
auxService = createCollector();
// not an AM
ContainerId containerId = getContainerId(2L);
ContainerInitializationContext context = mock(ContainerInitializationContext.class);
when(context.getContainerId()).thenReturn(containerId);
auxService.initializeContainer(context);
// auxService should not have that app
assertFalse(auxService.hasApplication(appAttemptId.getApplicationId()));
}
use of org.apache.hadoop.yarn.server.api.ContainerInitializationContext 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