AzkabanWebServer extends AzkabanServer implements IMBeanRegistrable { @Deprecated public static AzkabanWebServer getInstance() { return app; } @Inject  AzkabanWebServer(final Props props,
      final Server server,
      final ExecutorManagerAdapter executorManagerAdapter,
      final ProjectManager projectManager,
      final TriggerManager triggerManager,
      final WebMetrics webMetrics,
      final SessionCache sessionCache,
      final UserManager userManager,
      final ScheduleManager scheduleManager,
      final VelocityEngine velocityEngine,
      final FlowTriggerScheduler flowTriggerScheduler,
      final FlowTriggerService flowTriggerService,
      final StatusService statusService,
      final ExecutionLogsCleaner executionLogsCleaner); @Deprecated static AzkabanWebServer getInstance(); static void main(final String[] args); static void launch(final AzkabanWebServer webServer); FlowTriggerService getFlowTriggerService(); FlowTriggerScheduler getFlowTriggerScheduler(); @Override SessionCache getSessionCache(); @Override VelocityEngine getVelocityEngine(); @Override UserManager getUserManager(); ProjectManager getProjectManager(); ExecutorManagerAdapter getExecutorManager(); ScheduleManager getScheduleManager(); TriggerManager getTriggerManager(); WebMetrics getWebMetrics(); @Override Props getServerProps(); Map<String, TriggerPlugin> getTriggerPlugins(); @Override MBeanRegistrationManager getMBeanRegistrationManager(); @Override void configureMBeanServer(); void close();  }
@Test public void testInjection() throws Exception { final Injector injector = Guice.createInjector( new AzkabanCommonModule(props), new AzkabanWebServerModule(props) ); SERVICE_PROVIDER.unsetInjector(); SERVICE_PROVIDER.setInjector(injector); final ExecutorLoader executorLoader = injector.getInstance(ExecutorLoader.class); assertNotNull(executorLoader); final Executor executor = executorLoader.addExecutor("localhost", 60000); executor.setActive(true); executorLoader.updateExecutor(executor); assertNotNull(injector.getInstance(ExecutionFlowDao.class)); assertNotNull(injector.getInstance(DatabaseOperator.class)); assertSingleton(ExecutorLoader.class, injector); assertSingleton(ExecutorManagerAdapter.class, injector); assertSingleton(ProjectLoader.class, injector); assertSingleton(ProjectManager.class, injector); assertSingleton(Storage.class, injector); assertSingleton(TriggerLoader.class, injector); assertSingleton(TriggerManager.class, injector); assertSingleton(AlerterHolder.class, injector); assertSingleton(Emailer.class, injector); assertSingleton(ExecutionFlowDao.class, injector); assertSingleton(ExecutorDao.class, injector); assertSingleton(ExecutionJobDao.class, injector); assertSingleton(ExecutionLogsDao.class, injector); assertSingleton(ExecutorEventsDao.class, injector); assertSingleton(ActiveExecutingFlowsDao.class, injector); assertSingleton(FlowTriggerScheduler.class, injector); assertSingleton(FetchActiveFlowDao.class, injector); assertSingleton(AzkabanWebServer.class, injector); assertSingleton(H2FileDataSource.class, injector); assertSingleton(QuartzScheduler.class, injector); SERVICE_PROVIDER.unsetInjector(); }
@Test public void testDispatchMethod()throws Exception { props.put(ConfigurationKeys.AZKABAN_EXECUTION_DISPATCH_METHOD, DispatchMethod.PUSH.name()); final Injector injector = Guice.createInjector( new AzkabanCommonModule(props), new AzkabanWebServerModule(props) ); SERVICE_PROVIDER.unsetInjector(); SERVICE_PROVIDER.setInjector(injector); final ExecutorManagerAdapter executorManagerAdapter = injector.getInstance(ExecutorManagerAdapter.class); assertNotNull(executorManagerAdapter); assertEquals(executorManagerAdapter.getDispatchMethod(), DispatchMethod.PUSH); props.put(ConfigurationKeys.AZKABAN_EXECUTION_DISPATCH_METHOD,"POLL"); final Injector pollInjector = Guice.createInjector( new AzkabanCommonModule(props), new AzkabanWebServerModule(props) ); SERVICE_PROVIDER.unsetInjector(); SERVICE_PROVIDER.setInjector(pollInjector); final ExecutorManagerAdapter pollExecutorManagerAdapter = pollInjector.getInstance(ExecutorManagerAdapter.class); assertNotNull(pollExecutorManagerAdapter); assertEquals(pollExecutorManagerAdapter.getDispatchMethod(), DispatchMethod.POLL); props.put(ConfigurationKeys.AZKABAN_EXECUTION_DISPATCH_METHOD,"PUSH_CONTAINERIZED"); final Injector containerizedInjector = Guice.createInjector( new AzkabanCommonModule(props), new AzkabanWebServerModule(props) ); SERVICE_PROVIDER.unsetInjector(); SERVICE_PROVIDER.setInjector(containerizedInjector); final ExecutorManagerAdapter containerizedInjectorInstance = containerizedInjector.getInstance(ExecutorManagerAdapter.class); assertNotNull(containerizedInjectorInstance); assertEquals(containerizedInjectorInstance.getDispatchMethod(), DispatchMethod.PUSH_CONTAINERIZED); props.put(ConfigurationKeys.AZKABAN_EXECUTION_DISPATCH_METHOD,"UNKNOWN"); final Injector defaultInjector = Guice.createInjector( new AzkabanCommonModule(props), new AzkabanWebServerModule(props) ); SERVICE_PROVIDER.unsetInjector(); SERVICE_PROVIDER.setInjector(defaultInjector); final ExecutorManagerAdapter defaultInjectorInstance = defaultInjector.getInstance(ExecutorManagerAdapter.class); assertNotNull(defaultInjectorInstance); assertEquals(defaultInjectorInstance.getDispatchMethod(), DispatchMethod.PUSH); }