Search in sources :

Example 1 with ServiceAnnouncer

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));
}
Also used : WebappHttpHandlerFactory(co.cask.cdap.internal.app.runtime.webapp.WebappHttpHandlerFactory) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) QueueReaderFactory(co.cask.cdap.internal.app.queue.QueueReaderFactory) InMemoryProgramRuntimeService(co.cask.cdap.internal.app.runtime.service.InMemoryProgramRuntimeService) ProgramType(co.cask.cdap.proto.ProgramType) StreamWriterFactory(co.cask.cdap.app.stream.StreamWriterFactory) InMemoryServiceProgramRunner(co.cask.cdap.internal.app.runtime.service.InMemoryServiceProgramRunner) WorkerProgramRunner(co.cask.cdap.internal.app.runtime.worker.WorkerProgramRunner) FlowProgramRunner(co.cask.cdap.internal.app.runtime.flow.FlowProgramRunner) WorkflowProgramRunner(co.cask.cdap.internal.app.runtime.workflow.WorkflowProgramRunner) ServiceProgramRunner(co.cask.cdap.internal.app.runtime.service.ServiceProgramRunner) WebappProgramRunner(co.cask.cdap.internal.app.runtime.webapp.WebappProgramRunner) FlowletProgramRunner(co.cask.cdap.internal.app.runtime.flow.FlowletProgramRunner) ProgramRunner(co.cask.cdap.app.runtime.ProgramRunner) MapReduceProgramRunner(co.cask.cdap.internal.app.runtime.batch.MapReduceProgramRunner) ServiceAnnouncer(org.apache.twill.api.ServiceAnnouncer)

Aggregations

ProgramRunner (co.cask.cdap.app.runtime.ProgramRunner)1 StreamWriterFactory (co.cask.cdap.app.stream.StreamWriterFactory)1 QueueReaderFactory (co.cask.cdap.internal.app.queue.QueueReaderFactory)1 MapReduceProgramRunner (co.cask.cdap.internal.app.runtime.batch.MapReduceProgramRunner)1 FlowProgramRunner (co.cask.cdap.internal.app.runtime.flow.FlowProgramRunner)1 FlowletProgramRunner (co.cask.cdap.internal.app.runtime.flow.FlowletProgramRunner)1 InMemoryProgramRuntimeService (co.cask.cdap.internal.app.runtime.service.InMemoryProgramRuntimeService)1 InMemoryServiceProgramRunner (co.cask.cdap.internal.app.runtime.service.InMemoryServiceProgramRunner)1 ServiceProgramRunner (co.cask.cdap.internal.app.runtime.service.ServiceProgramRunner)1 WebappHttpHandlerFactory (co.cask.cdap.internal.app.runtime.webapp.WebappHttpHandlerFactory)1 WebappProgramRunner (co.cask.cdap.internal.app.runtime.webapp.WebappProgramRunner)1 WorkerProgramRunner (co.cask.cdap.internal.app.runtime.worker.WorkerProgramRunner)1 WorkflowProgramRunner (co.cask.cdap.internal.app.runtime.workflow.WorkflowProgramRunner)1 ProgramType (co.cask.cdap.proto.ProgramType)1 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 ServiceAnnouncer (org.apache.twill.api.ServiceAnnouncer)1