@Override protected void configure() { LOGGER.debug("Configuring guice"); bind(MyriadConfiguration.class).toInstance(cfg); bind(Configuration.class).toInstance(hadoopConf); bind(RMContext.class).toInstance(rmContext); bind(AbstractYarnScheduler.class).toInstance(yarnScheduler); bind(InterceptorRegistry.class).toInstance(interceptorRegistry); bind(MyriadDriverManager.class).in(Scopes.SINGLETON); bind(org.apache.myriad.scheduler.MyriadScheduler.class).in(Scopes.SINGLETON); bind(ServiceProfileManager.class).in(Scopes.SINGLETON); bind(DisruptorManager.class).in(Scopes.SINGLETON); bind(ReconcileService.class).in(Scopes.SINGLETON); bind(HttpConnectorProvider.class).in(Scopes.SINGLETON); bind(MyriadWebServer.class).in(Scopes.SINGLETON); // add special binding between TaskFactory and NMTaskFactory to ease up // usage of TaskFactory bind(TaskFactory.class).annotatedWith(NMTaskFactoryAnnotation.class).to(NMTaskFactory.class); bind(YarnNodeCapacityManager.class).in(Scopes.SINGLETON); bind(NodeStore.class).in(Scopes.SINGLETON); bind(OfferLifecycleManager.class).in(Scopes.SINGLETON); bind(NMHeartBeatHandler.class).asEagerSingleton(); MapBinder<String, TaskFactory> mapBinder = MapBinder.newMapBinder(binder(), String.class, TaskFactory.class); mapBinder .addBinding(NodeManagerConfiguration.DEFAULT_NM_TASK_PREFIX) .to(NMTaskFactory.class) .in(Scopes.SINGLETON); Map<String, ServiceConfiguration> auxServicesConfigs = cfg.getServiceConfigurations(); for (Map.Entry<String, ServiceConfiguration> entry : auxServicesConfigs.entrySet()) { if (entry.getValue().getTaskFactoryImplName().isPresent()) { String taskFactoryClass = entry.getValue().getTaskFactoryImplName().get(); try { Class<? extends TaskFactory> implClass = getTaskFactoryClass(taskFactoryClass); mapBinder.addBinding(entry.getKey()).to(implClass).in(Scopes.SINGLETON); } catch (ClassNotFoundException e) { LOGGER.error("ClassNotFoundException", e); } } else { // TODO (hokiegeek2) Confirm if this else statement and logic should still be here mapBinder.addBinding(entry.getKey()).to(ServiceTaskFactory.class).in(Scopes.SINGLETON); } } // TODO(Santosh): Should be configurable as well bind(NodeScaleDownPolicy.class).to(LeastAMNodesFirstPolicy.class).in(Scopes.SINGLETON); }