Search in sources :

Example 1 with DistributedArtifactManagerModule

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

Example 2 with DistributedArtifactManagerModule

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);
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) ZKDiscoveryModule(io.cdap.cdap.common.guice.ZKDiscoveryModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) AuthenticationContextModules(io.cdap.cdap.security.auth.context.AuthenticationContextModules) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) ArrayList(java.util.ArrayList) KafkaLogAppenderModule(io.cdap.cdap.logging.guice.KafkaLogAppenderModule) AbstractModule(com.google.inject.AbstractModule) ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) MasterEnvironment(io.cdap.cdap.master.spi.environment.MasterEnvironment) KafkaClientModule(io.cdap.cdap.common.guice.KafkaClientModule) DistributedArtifactManagerModule(io.cdap.cdap.app.guice.DistributedArtifactManagerModule) SupplierProviderBridge(io.cdap.cdap.common.guice.SupplierProviderBridge) Module(com.google.inject.Module) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) KafkaClientModule(io.cdap.cdap.common.guice.KafkaClientModule) ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) IOModule(io.cdap.cdap.common.guice.IOModule) KafkaLogAppenderModule(io.cdap.cdap.logging.guice.KafkaLogAppenderModule) DistributedArtifactManagerModule(io.cdap.cdap.app.guice.DistributedArtifactManagerModule) ZKDiscoveryModule(io.cdap.cdap.common.guice.ZKDiscoveryModule) AbstractModule(com.google.inject.AbstractModule) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with DistributedArtifactManagerModule

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

Aggregations

AbstractModule (com.google.inject.AbstractModule)3 Module (com.google.inject.Module)3 DistributedArtifactManagerModule (io.cdap.cdap.app.guice.DistributedArtifactManagerModule)3 ArrayList (java.util.ArrayList)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 UnsupportedPluginFinder (io.cdap.cdap.app.guice.UnsupportedPluginFinder)2 PrivateModule (com.google.inject.PrivateModule)1 MapBinder (com.google.inject.multibindings.MapBinder)1 ClusterMode (io.cdap.cdap.app.guice.ClusterMode)1 DefaultProgramRunnerFactory (io.cdap.cdap.app.guice.DefaultProgramRunnerFactory)1 DistributedProgramContainerModule (io.cdap.cdap.app.guice.DistributedProgramContainerModule)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 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)1 IOModule (io.cdap.cdap.common.guice.IOModule)1 KafkaClientModule (io.cdap.cdap.common.guice.KafkaClientModule)1 LocalLocationModule (io.cdap.cdap.common.guice.LocalLocationModule)1 SupplierProviderBridge (io.cdap.cdap.common.guice.SupplierProviderBridge)1 ZKClientModule (io.cdap.cdap.common.guice.ZKClientModule)1