use of io.cdap.cdap.app.guice.DistributedArtifactManagerModule 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);
}
use of io.cdap.cdap.app.guice.DistributedArtifactManagerModule in project cdap by caskdata.
the class ArtifactLocalizerTwillRunnable method createInjector.
@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf) {
List<Module> modules = new ArrayList<>();
CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
modules.add(new ConfigModule(cConf, hConf));
modules.add(new IOModule());
modules.add(RemoteAuthenticatorModules.getDefaultModule());
modules.add(new AuthenticationContextModules().getMasterModule());
modules.add(coreSecurityModule);
// If MasterEnvironment is not available, assuming it is the old hadoop stack with ZK, Kafka
MasterEnvironment masterEnv = MasterEnvironments.getMasterEnvironment();
if (masterEnv == null) {
modules.add(new ZKClientModule());
modules.add(new ZKDiscoveryModule());
modules.add(new KafkaClientModule());
modules.add(new KafkaLogAppenderModule());
} else {
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(DiscoveryService.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceSupplier()));
bind(DiscoveryServiceClient.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceClientSupplier()));
}
});
modules.add(new RemoteLogAppenderModule());
modules.add(new LocalLocationModule());
if (coreSecurityModule.requiresZKClient()) {
modules.add(new ZKClientModule());
}
}
modules.add(new DistributedArtifactManagerModule());
return Guice.createInjector(modules);
}
use of io.cdap.cdap.app.guice.DistributedArtifactManagerModule in project cdap by caskdata.
the class SparkRuntimeContextProvider method createInjector.
@VisibleForTesting
public static Injector createInjector(CConfiguration cConf, Configuration hConf, ProgramId programId, ProgramOptions programOptions) {
String runId = programOptions.getArguments().getOption(ProgramOptionConstants.RUN_ID);
List<Module> modules = new ArrayList<>();
modules.add(new DistributedProgramContainerModule(cConf, hConf, programId.run(runId), programOptions));
ClusterMode clusterMode = ProgramRunners.getClusterMode(programOptions);
modules.add(clusterMode == ClusterMode.ON_PREMISE ? new DistributedArtifactManagerModule() : new AbstractModule() {
@Override
protected void configure() {
bind(PluginFinder.class).to(UnsupportedPluginFinder.class);
}
});
return Guice.createInjector(modules);
}
Aggregations