use of org.apache.twill.api.ServiceAnnouncer in project cdap by caskdata.
the class InMemoryProgramRunnerModule method configure.
/**
* Configures a {@link com.google.inject.Binder} via the exposed methods.
*/
@Override
protected void configure() {
// Bind ServiceAnnouncer for service.
bind(ServiceAnnouncer.class).to(DiscoveryServiceAnnouncer.class);
// For Binding queue stuff
bind(QueueReaderFactory.class).in(Scopes.SINGLETON);
// Bind ProgramRunner
MapBinder<ProgramType, ProgramRunner> runnerFactoryBinder = MapBinder.newMapBinder(binder(), ProgramType.class, ProgramRunner.class);
runnerFactoryBinder.addBinding(ProgramType.FLOW).to(FlowProgramRunner.class);
runnerFactoryBinder.addBinding(ProgramType.MAPREDUCE).to(MapReduceProgramRunner.class);
runnerFactoryBinder.addBinding(ProgramType.WORKFLOW).to(WorkflowProgramRunner.class);
runnerFactoryBinder.addBinding(ProgramType.WEBAPP).to(WebappProgramRunner.class);
runnerFactoryBinder.addBinding(ProgramType.WORKER).to(InMemoryWorkerRunner.class);
runnerFactoryBinder.addBinding(ProgramType.SERVICE).to(InMemoryServiceProgramRunner.class);
// Bind these three program runner in private scope
// They should only be used by the ProgramRunners in the runnerFactoryBinder
bind(FlowletProgramRunner.class);
bind(ServiceProgramRunner.class);
bind(WorkerProgramRunner.class);
// ProgramRunnerFactory should be in local mode
bind(ProgramRuntimeProvider.Mode.class).toInstance(ProgramRuntimeProvider.Mode.LOCAL);
bind(ProgramRunnerFactory.class).to(DefaultProgramRunnerFactory.class).in(Scopes.SINGLETON);
// Note: Expose for test cases. Need to refactor test cases.
expose(ProgramRunnerFactory.class);
// Bind and expose runtime service
bind(ProgramRuntimeService.class).to(InMemoryProgramRuntimeService.class).in(Scopes.SINGLETON);
expose(ProgramRuntimeService.class);
// For binding DataSet transaction stuff
install(new DataFabricFacadeModule());
// Create webapp http handler factory.
install(new FactoryModuleBuilder().implement(JarHttpHandler.class, IntactJarHttpHandler.class).build(WebappHttpHandlerFactory.class));
// Create StreamWriter factory.
install(new FactoryModuleBuilder().implement(StreamWriter.class, streamWriterClass).build(StreamWriterFactory.class));
}
Aggregations