Search in sources :

Example 6 with ProgramRunner

use of co.cask.cdap.app.runtime.ProgramRunner 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)

Example 7 with ProgramRunner

use of co.cask.cdap.app.runtime.ProgramRunner in project cdap by caskdata.

the class DefaultProgramRunnerFactory method create.

@Override
public ProgramRunner create(ProgramType programType) {
    ProgramRuntimeProvider provider = runtimeProviderLoader.get(programType);
    if (provider != null) {
        LOG.debug("Using runtime provider {} for program type {}", provider, programType);
        return provider.createProgramRunner(programType, mode, injector);
    }
    Provider<ProgramRunner> defaultProvider = defaultRunnerProviders.get(programType);
    if (defaultProvider == null) {
        throw new IllegalArgumentException("Unsupported program type: " + programType);
    }
    return defaultProvider.get();
}
Also used : ProgramRuntimeProvider(co.cask.cdap.app.runtime.ProgramRuntimeProvider) ProgramRunner(co.cask.cdap.app.runtime.ProgramRunner)

Aggregations

ProgramRunner (co.cask.cdap.app.runtime.ProgramRunner)7 ProgramId (co.cask.cdap.proto.id.ProgramId)3 Program (co.cask.cdap.app.program.Program)2 ProgramType (co.cask.cdap.proto.ProgramType)2 Closeable (java.io.Closeable)2 IOException (java.io.IOException)2 Resources (co.cask.cdap.api.Resources)1 CloseableClassLoader (co.cask.cdap.api.artifact.CloseableClassLoader)1 SchedulableProgramType (co.cask.cdap.api.schedule.SchedulableProgramType)1 ScheduleProgramInfo (co.cask.cdap.api.workflow.ScheduleProgramInfo)1 WorkflowActionNode (co.cask.cdap.api.workflow.WorkflowActionNode)1 WorkflowSpecification (co.cask.cdap.api.workflow.WorkflowSpecification)1 ProgramDescriptor (co.cask.cdap.app.program.ProgramDescriptor)1 ProgramClassLoaderProvider (co.cask.cdap.app.runtime.ProgramClassLoaderProvider)1 ProgramRunnerFactory (co.cask.cdap.app.runtime.ProgramRunnerFactory)1 ProgramRuntimeProvider (co.cask.cdap.app.runtime.ProgramRuntimeProvider)1 StreamWriterFactory (co.cask.cdap.app.stream.StreamWriterFactory)1 FilterClassLoader (co.cask.cdap.common.lang.FilterClassLoader)1 QueueReaderFactory (co.cask.cdap.internal.app.queue.QueueReaderFactory)1 BasicArguments (co.cask.cdap.internal.app.runtime.BasicArguments)1