Search in sources :

Example 1 with ResourceLocalizationService

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ResourceLocalizationService in project hadoop by apache.

the class DummyContainerManager method createResourceLocalizationService.

@Override
@SuppressWarnings("unchecked")
protected ResourceLocalizationService createResourceLocalizationService(ContainerExecutor exec, DeletionService deletionContext, Context context) {
    return new ResourceLocalizationService(super.dispatcher, exec, deletionContext, super.dirsHandler, context) {

        @Override
        public void handle(LocalizationEvent event) {
            switch(event.getType()) {
                case INIT_APPLICATION_RESOURCES:
                    Application app = ((ApplicationLocalizationEvent) event).getApplication();
                    // Simulate event from ApplicationLocalization.
                    dispatcher.getEventHandler().handle(new ApplicationInitedEvent(app.getAppId()));
                    break;
                case LOCALIZE_CONTAINER_RESOURCES:
                    ContainerLocalizationRequestEvent rsrcReqs = (ContainerLocalizationRequestEvent) event;
                    // simulate localization of all requested resources
                    for (Collection<LocalResourceRequest> rc : rsrcReqs.getRequestedResources().values()) {
                        for (LocalResourceRequest req : rc) {
                            LOG.info("DEBUG: " + req + ":" + rsrcReqs.getContainer().getContainerId());
                            dispatcher.getEventHandler().handle(new ContainerResourceLocalizedEvent(rsrcReqs.getContainer().getContainerId(), req, new Path("file:///local" + req.getPath().toUri().getPath())));
                        }
                    }
                    break;
                case CLEANUP_CONTAINER_RESOURCES:
                    Container container = ((ContainerLocalizationEvent) event).getContainer();
                    // TODO: delete the container dir
                    this.dispatcher.getEventHandler().handle(new ContainerEvent(container.getContainerId(), ContainerEventType.CONTAINER_RESOURCES_CLEANEDUP));
                    break;
                case DESTROY_APPLICATION_RESOURCES:
                    Application application = ((ApplicationLocalizationEvent) event).getApplication();
                    // decrement reference counts of all resources associated with this
                    // app
                    this.dispatcher.getEventHandler().handle(new ApplicationEvent(application.getAppId(), ApplicationEventType.APPLICATION_RESOURCES_CLEANEDUP));
                    break;
                default:
                    fail("Unexpected event: " + event.getType());
            }
        }
    };
}
Also used : Path(org.apache.hadoop.fs.Path) ContainerEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEvent) LocalResourceRequest(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.LocalResourceRequest) ContainerResourceLocalizedEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceLocalizedEvent) ResourceLocalizationService(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ResourceLocalizationService) ContainerLocalizationRequestEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationRequestEvent) ContainerLocalizationEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationEvent) ApplicationEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationEvent) LocalizationEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizationEvent) ContainerLocalizationEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationEvent) ApplicationLocalizationEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ApplicationLocalizationEvent) Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ApplicationLocalizationEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ApplicationLocalizationEvent) ApplicationInitedEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationInitedEvent) Application(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application)

Example 2 with ResourceLocalizationService

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ResourceLocalizationService 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

ResourceLocalizationService (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ResourceLocalizationService)2 LocalizationEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizationEvent)2 Configuration (org.apache.hadoop.conf.Configuration)1 FileContext (org.apache.hadoop.fs.FileContext)1 Path (org.apache.hadoop.fs.Path)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 NMContext (org.apache.hadoop.yarn.server.nodemanager.NodeManager.NMContext)1 NodeStatusUpdater (org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdater)1 Application (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application)1 ApplicationEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationEvent)1 ApplicationInitedEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationInitedEvent)1 Container (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)1 ContainerEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEvent)1 ContainerResourceLocalizedEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceLocalizedEvent)1 ContainersLauncher (org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncher)1