Search in sources :

Example 1 with DefaultProgramRunnerFactory

use of io.cdap.cdap.app.guice.DefaultProgramRunnerFactory in project cdap by caskdata.

the class WorkflowTwillRunnable method createModule.

@Override
protected Module createModule(CConfiguration cConf, Configuration hConf, ProgramOptions programOptions, ProgramRunId programRunId) {
    List<Module> modules = new ArrayList<>();
    modules.add(super.createModule(cConf, hConf, programOptions, programRunId));
    if (ProgramRunners.getClusterMode(programOptions) == ClusterMode.ON_PREMISE) {
        modules.add(new DistributedArtifactManagerModule());
    } else {
        modules.add(new AbstractModule() {

            @Override
            protected void configure() {
                bind(PluginFinder.class).to(UnsupportedPluginFinder.class);
            }
        });
    }
    modules.add(new PrivateModule() {

        @Override
        protected void configure() {
            // Bind ProgramRunner for MR, which is used by Workflow.
            // The ProgramRunner for Spark is provided by the DefaultProgramRunnerFactory through the extension mechanism
            MapBinder<ProgramType, ProgramRunner> runnerFactoryBinder = MapBinder.newMapBinder(binder(), ProgramType.class, ProgramRunner.class);
            runnerFactoryBinder.addBinding(ProgramType.MAPREDUCE).to(MapReduceProgramRunner.class);
            // It uses local mode factory because for Workflow we launch the job from the Workflow container directly.
            // The actual execution mode of the job is governed by the framework configuration
            // For mapreduce, it's in the mapred-site.xml
            // for spark, it's in the hConf we shipped from DistributedWorkflowProgramRunner
            bind(ProgramRuntimeProvider.Mode.class).toInstance(ProgramRuntimeProvider.Mode.LOCAL);
            bind(ProgramRunnerFactory.class).to(DefaultProgramRunnerFactory.class).in(Scopes.SINGLETON);
            expose(ProgramRunnerFactory.class);
        }
    });
    return Modules.combine(modules);
}
Also used : ArrayList(java.util.ArrayList) UnsupportedPluginFinder(io.cdap.cdap.app.guice.UnsupportedPluginFinder) DefaultProgramRunnerFactory(io.cdap.cdap.app.guice.DefaultProgramRunnerFactory) ProgramRunnerFactory(io.cdap.cdap.app.runtime.ProgramRunnerFactory) AbstractModule(com.google.inject.AbstractModule) ProgramRuntimeProvider(io.cdap.cdap.app.runtime.ProgramRuntimeProvider) DistributedArtifactManagerModule(io.cdap.cdap.app.guice.DistributedArtifactManagerModule) MapReduceProgramRunner(io.cdap.cdap.internal.app.runtime.batch.MapReduceProgramRunner) MapBinder(com.google.inject.multibindings.MapBinder) ProgramType(io.cdap.cdap.proto.ProgramType) Module(com.google.inject.Module) PrivateModule(com.google.inject.PrivateModule) DistributedArtifactManagerModule(io.cdap.cdap.app.guice.DistributedArtifactManagerModule) AbstractModule(com.google.inject.AbstractModule) WorkflowProgramRunner(io.cdap.cdap.internal.app.runtime.workflow.WorkflowProgramRunner) ProgramRunner(io.cdap.cdap.app.runtime.ProgramRunner) MapReduceProgramRunner(io.cdap.cdap.internal.app.runtime.batch.MapReduceProgramRunner) PrivateModule(com.google.inject.PrivateModule)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 PrivateModule (com.google.inject.PrivateModule)1 MapBinder (com.google.inject.multibindings.MapBinder)1 DefaultProgramRunnerFactory (io.cdap.cdap.app.guice.DefaultProgramRunnerFactory)1 DistributedArtifactManagerModule (io.cdap.cdap.app.guice.DistributedArtifactManagerModule)1 UnsupportedPluginFinder (io.cdap.cdap.app.guice.UnsupportedPluginFinder)1 ProgramRunner (io.cdap.cdap.app.runtime.ProgramRunner)1 ProgramRunnerFactory (io.cdap.cdap.app.runtime.ProgramRunnerFactory)1 ProgramRuntimeProvider (io.cdap.cdap.app.runtime.ProgramRuntimeProvider)1 MapReduceProgramRunner (io.cdap.cdap.internal.app.runtime.batch.MapReduceProgramRunner)1 WorkflowProgramRunner (io.cdap.cdap.internal.app.runtime.workflow.WorkflowProgramRunner)1 ProgramType (io.cdap.cdap.proto.ProgramType)1 ArrayList (java.util.ArrayList)1