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);
}
Aggregations