Search in sources :

Example 1 with ContainersLauncherEvent

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent in project hadoop by apache.

the class ContainerImpl method sendLaunchEvent.

// dispatcher not typed
@SuppressWarnings("unchecked")
@Override
public void sendLaunchEvent() {
    ContainersLauncherEventType launcherEvent = ContainersLauncherEventType.LAUNCH_CONTAINER;
    if (recoveredStatus == RecoveredContainerStatus.LAUNCHED) {
        // try to recover a container that was previously launched
        launcherEvent = ContainersLauncherEventType.RECOVER_CONTAINER;
    }
    containerLaunchStartTime = clock.getTime();
    dispatcher.getEventHandler().handle(new ContainersLauncherEvent(this, launcherEvent));
}
Also used : ContainersLauncherEventType(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEventType) ContainersLauncherEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent)

Example 2 with ContainersLauncherEvent

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent in project hadoop by apache.

the class DummyContainerManager method createContainersLauncher.

@Override
@SuppressWarnings("unchecked")
protected ContainersLauncher createContainersLauncher(Context context, ContainerExecutor exec) {
    return new ContainersLauncher(context, super.dispatcher, exec, super.dirsHandler, this) {

        @Override
        public void handle(ContainersLauncherEvent event) {
            Container container = event.getContainer();
            ContainerId containerId = container.getContainerId();
            switch(event.getType()) {
                case LAUNCH_CONTAINER:
                    dispatcher.getEventHandler().handle(new ContainerEvent(containerId, ContainerEventType.CONTAINER_LAUNCHED));
                    break;
                case CLEANUP_CONTAINER:
                    dispatcher.getEventHandler().handle(new ContainerExitEvent(containerId, ContainerEventType.CONTAINER_KILLED_ON_REQUEST, 0, "Container exited with exit code 0."));
                    break;
            }
        }
    };
}
Also used : ContainerEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEvent) Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ContainersLauncher(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncher) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ContainerExitEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerExitEvent) ContainersLauncherEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent)

Example 3 with ContainersLauncherEvent

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent in project hadoop by apache.

the class TestContainer method testLocalizationLaunch.

/**
   * Verify container launch when all resources already cached.
   */
@Test
public void testLocalizationLaunch() throws Exception {
    WrappedContainer wc = null;
    try {
        wc = new WrappedContainer(8, 314159265358979L, 4344, "yak");
        assertEquals(ContainerState.NEW, wc.c.getContainerState());
        wc.initContainer();
        Map<Path, List<String>> localPaths = wc.localizeResources();
        // all resources should be localized
        assertEquals(ContainerState.SCHEDULED, wc.c.getContainerState());
        assertNotNull(wc.c.getLocalizedResources());
        for (Entry<Path, List<String>> loc : wc.c.getLocalizedResources().entrySet()) {
            assertEquals(localPaths.remove(loc.getKey()), loc.getValue());
        }
        assertTrue(localPaths.isEmpty());
        final WrappedContainer wcf = wc;
        // verify container launch
        ArgumentMatcher<ContainersLauncherEvent> matchesContainerLaunch = new ArgumentMatcher<ContainersLauncherEvent>() {

            @Override
            public boolean matches(Object o) {
                ContainersLauncherEvent launchEvent = (ContainersLauncherEvent) o;
                return wcf.c == launchEvent.getContainer();
            }
        };
        verify(wc.launcherBus).handle(argThat(matchesContainerLaunch));
    } finally {
        if (wc != null) {
            wc.finished();
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ArgumentMatcher(org.mockito.ArgumentMatcher) List(java.util.List) ContainersLauncherEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent) Test(org.junit.Test)

Example 4 with ContainersLauncherEvent

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent in project hadoop by apache.

the class ContainerImpl method sendRelaunchEvent.

// dispatcher not typed
@SuppressWarnings("unchecked")
private void sendRelaunchEvent() {
    ContainersLauncherEventType launcherEvent = ContainersLauncherEventType.RELAUNCH_CONTAINER;
    dispatcher.getEventHandler().handle(new ContainersLauncherEvent(this, launcherEvent));
}
Also used : ContainersLauncherEventType(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEventType) ContainersLauncherEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent)

Example 5 with ContainersLauncherEvent

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent in project hadoop by apache.

the class TestContainerManagerRecovery method createContainerManager.

private ContainerManagerImpl createContainerManager(Context context) {
    final LogHandler logHandler = mock(LogHandler.class);
    final ResourceLocalizationService rsrcSrv = new ResourceLocalizationService(null, null, null, null, context) {

        @Override
        public void serviceInit(Configuration conf) throws Exception {
        }

        @Override
        public void serviceStart() throws Exception {
        // do nothing
        }

        @Override
        public void serviceStop() throws Exception {
        // do nothing
        }

        @Override
        public void handle(LocalizationEvent event) {
        // do nothing
        }
    };
    final ContainersLauncher launcher = new ContainersLauncher(context, null, null, null, null) {

        @Override
        public void handle(ContainersLauncherEvent event) {
        // do nothing
        }
    };
    return new ContainerManagerImpl(context, mock(ContainerExecutor.class), mock(DeletionService.class), mock(NodeStatusUpdater.class), metrics, null) {

        @Override
        protected LogHandler createLogHandler(Configuration conf, Context context, DeletionService deletionService) {
            return logHandler;
        }

        @Override
        protected ResourceLocalizationService createResourceLocalizationService(ContainerExecutor exec, DeletionService deletionContext, Context context) {
            return rsrcSrv;
        }

        @Override
        protected ContainersLauncher createContainersLauncher(Context context, ContainerExecutor exec) {
            return launcher;
        }

        @Override
        public void setBlockNewContainerRequests(boolean blockNewContainerRequests) {
        // do nothing
        }

        @Override
        public NMTimelinePublisher createNMTimelinePublisher(Context context) {
            return null;
        }
    };
}
Also used : LogHandler(org.apache.hadoop.yarn.server.nodemanager.containermanager.loghandler.LogHandler) FileContext(org.apache.hadoop.fs.FileContext) NMContext(org.apache.hadoop.yarn.server.nodemanager.NodeManager.NMContext) ContainerLaunchContext(org.apache.hadoop.yarn.api.records.ContainerLaunchContext) LogAggregationContext(org.apache.hadoop.yarn.api.records.LogAggregationContext) Context(org.apache.hadoop.yarn.server.nodemanager.Context) ContainerExecutor(org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor) ResourceLocalizationService(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ResourceLocalizationService) ContainersLauncher(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncher) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) DeletionService(org.apache.hadoop.yarn.server.nodemanager.DeletionService) NodeStatusUpdater(org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdater) LocalizationEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizationEvent) ContainersLauncherEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent)

Aggregations

ContainersLauncherEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent)6 ContainersLauncher (org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncher)2 ContainersLauncherEventType (org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEventType)2 Test (org.junit.Test)2 ArgumentMatcher (org.mockito.ArgumentMatcher)2 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileContext (org.apache.hadoop.fs.FileContext)1 Path (org.apache.hadoop.fs.Path)1 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)1 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)1 LogAggregationContext (org.apache.hadoop.yarn.api.records.LogAggregationContext)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 ContainerExecutor (org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor)1 Context (org.apache.hadoop.yarn.server.nodemanager.Context)1 DeletionService (org.apache.hadoop.yarn.server.nodemanager.DeletionService)1