Search in sources :

Example 1 with DistributedProgramContainerModule

use of io.cdap.cdap.app.guice.DistributedProgramContainerModule 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);
}
Also used : ClusterMode(io.cdap.cdap.app.guice.ClusterMode) PluginFinder(io.cdap.cdap.internal.app.runtime.artifact.PluginFinder) UnsupportedPluginFinder(io.cdap.cdap.app.guice.UnsupportedPluginFinder) DistributedArtifactManagerModule(io.cdap.cdap.app.guice.DistributedArtifactManagerModule) ArrayList(java.util.ArrayList) Module(com.google.inject.Module) DistributedProgramContainerModule(io.cdap.cdap.app.guice.DistributedProgramContainerModule) DistributedArtifactManagerModule(io.cdap.cdap.app.guice.DistributedArtifactManagerModule) AbstractModule(com.google.inject.AbstractModule) DistributedProgramContainerModule(io.cdap.cdap.app.guice.DistributedProgramContainerModule) AbstractModule(com.google.inject.AbstractModule) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with DistributedProgramContainerModule

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

the class DistributedMapReduceTaskContextProvider method createInjector.

private static Injector createInjector(CConfiguration cConf, Configuration hConf) {
    MapReduceContextConfig mapReduceContextConfig = new MapReduceContextConfig(hConf);
    // principal will be null if running on a kerberos distributed cluster
    ProgramOptions programOptions = mapReduceContextConfig.getProgramOptions();
    Arguments systemArgs = programOptions.getArguments();
    String runId = systemArgs.getOption(ProgramOptionConstants.RUN_ID);
    return Guice.createInjector(new DistributedProgramContainerModule(cConf, hConf, mapReduceContextConfig.getProgramId().run(runId), programOptions));
}
Also used : MapReduceContextConfig(io.cdap.cdap.internal.app.runtime.batch.MapReduceContextConfig) Arguments(io.cdap.cdap.app.runtime.Arguments) SystemArguments(io.cdap.cdap.internal.app.runtime.SystemArguments) ProgramOptions(io.cdap.cdap.app.runtime.ProgramOptions) DistributedProgramContainerModule(io.cdap.cdap.app.guice.DistributedProgramContainerModule)

Aggregations

DistributedProgramContainerModule (io.cdap.cdap.app.guice.DistributedProgramContainerModule)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 ClusterMode (io.cdap.cdap.app.guice.ClusterMode)1 DistributedArtifactManagerModule (io.cdap.cdap.app.guice.DistributedArtifactManagerModule)1 UnsupportedPluginFinder (io.cdap.cdap.app.guice.UnsupportedPluginFinder)1 Arguments (io.cdap.cdap.app.runtime.Arguments)1 ProgramOptions (io.cdap.cdap.app.runtime.ProgramOptions)1 SystemArguments (io.cdap.cdap.internal.app.runtime.SystemArguments)1 PluginFinder (io.cdap.cdap.internal.app.runtime.artifact.PluginFinder)1 MapReduceContextConfig (io.cdap.cdap.internal.app.runtime.batch.MapReduceContextConfig)1 ArrayList (java.util.ArrayList)1