/** * Returns a list of {@link Service} to start before the program execution and shutdown when program completed. */ private Deque<Service> createCoreServices(Injector injector, ProgramOptions programOptions) { Deque<Service> services = new LinkedList<>(); MetricsCollectionService metricsCollectionService = injector.getInstance(MetricsCollectionService.class); services.add(metricsCollectionService); services.add(injector.getInstance(ZKClientService.class)); switch (ProgramRunners.getClusterMode(programOptions)) { case ON_PREMISE: addOnPremiseServices(injector, programOptions, metricsCollectionService, services); break; case ISOLATED: addIsolatedServices(injector, services); break; default: // This shouldn't happen. Just do nothing. } return services; }
/** * Returns a list of {@link Service} to start before the program execution and shutdown when program completed. */ private Deque<Service> createCoreServices(Injector injector, ProgramOptions programOptions) { Deque<Service> services = new LinkedList<>(); MetricsCollectionService metricsCollectionService = injector.getInstance(MetricsCollectionService.class); services.add(metricsCollectionService); services.add(injector.getInstance(ZKClientService.class)); switch (ProgramRunners.getClusterMode(programOptions)) { case ON_PREMISE: addOnPremiseServices(injector, programOptions, metricsCollectionService, services); break; case ISOLATED: addIsolatedServices(injector, services); break; default: // This shouldn't happen. Just do nothing. } return services; }
public DistributedMapReduceTaskContextProvider(CConfiguration cConf, Configuration hConf, MapReduceClassLoader mapReduceClassLoader) { super(createInjector(cConf, hConf), mapReduceClassLoader); MapReduceContextConfig mapReduceContextConfig = new MapReduceContextConfig(hConf); Injector injector = getInjector(); Deque<Service> coreServices = new LinkedList<>(); coreServices.add(injector.getInstance(ZKClientService.class)); coreServices.add(injector.getInstance(MetricsCollectionService.class)); if (ProgramRunners.getClusterMode(mapReduceContextConfig.getProgramOptions()) == ClusterMode.ON_PREMISE) { coreServices.add(injector.getInstance(KafkaClientService.class)); } this.coreServices = coreServices; this.logAppenderInitializer = injector.getInstance(LogAppenderInitializer.class); this.mapReduceContextConfig = new MapReduceContextConfig(hConf); }
public DistributedMapReduceTaskContextProvider(CConfiguration cConf, Configuration hConf, MapReduceClassLoader mapReduceClassLoader) { super(createInjector(cConf, hConf), mapReduceClassLoader); MapReduceContextConfig mapReduceContextConfig = new MapReduceContextConfig(hConf); Injector injector = getInjector(); Deque<Service> coreServices = new LinkedList<>(); coreServices.add(injector.getInstance(ZKClientService.class)); coreServices.add(injector.getInstance(MetricsCollectionService.class)); if (ProgramRunners.getClusterMode(mapReduceContextConfig.getProgramOptions()) == ClusterMode.ON_PREMISE) { coreServices.add(injector.getInstance(KafkaClientService.class)); } this.coreServices = coreServices; this.logAppenderInitializer = injector.getInstance(LogAppenderInitializer.class); this.mapReduceContextConfig = new MapReduceContextConfig(hConf); }
if (ProgramRunners.getClusterMode(programOptions) == ClusterMode.ON_PREMISE) { modules.add(new DistributedArtifactManagerModule()); } else {
@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.getArguments())); 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); }
@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.getArguments())); 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); }
if (ProgramRunners.getClusterMode(programOptions) == ClusterMode.ON_PREMISE) { modules.add(new DistributedArtifactManagerModule()); } else {
@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.getArguments())); 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); }
@Override protected Module createModule(CConfiguration cConf, Configuration hConf, ProgramOptions programOptions, ProgramRunId programRunId) { Module module = super.createModule(cConf, hConf, programOptions, programRunId); // Only supports dynamic artifacts fetching when running on-prem return ProgramRunners.getClusterMode(programOptions) == ClusterMode.ON_PREMISE ? Modules.combine(module, new DistributedArtifactManagerModule()) : Modules.combine(module, new AbstractModule() { @Override protected void configure() { bind(PluginFinder.class).to(UnsupportedPluginFinder.class); } }); } }
@Override protected Module createModule(CConfiguration cConf, Configuration hConf, ProgramOptions programOptions, ProgramRunId programRunId) { Module module = super.createModule(cConf, hConf, programOptions, programRunId); // Only supports dynamic artifacts fetching when running on-prem return ProgramRunners.getClusterMode(programOptions) == ClusterMode.ON_PREMISE ? Modules.combine(module, new DistributedArtifactManagerModule()) : Modules.combine(module, new AbstractModule() { @Override protected void configure() { bind(PluginFinder.class).to(UnsupportedPluginFinder.class); } }); } }
@Override protected Module createModule(CConfiguration cConf, Configuration hConf, ProgramOptions programOptions, ProgramRunId programRunId) { Module module = super.createModule(cConf, hConf, programOptions, programRunId); // Only supports dynamic artifacts fetching when running on-prem return ProgramRunners.getClusterMode(programOptions) == ClusterMode.ON_PREMISE ? Modules.combine(module, new DistributedArtifactManagerModule()) : Modules.combine(module, new AbstractModule() { @Override protected void configure() { bind(PluginFinder.class).to(UnsupportedPluginFinder.class); } }); } }
ClusterMode clusterMode = ProgramRunners.getClusterMode(programOptions);
ClusterMode clusterMode = ProgramRunners.getClusterMode(programOptions);
@Override public final RuntimeInfo run(ProgramDescriptor programDescriptor, ProgramOptions options, RunId runId) { ProgramId programId = programDescriptor.getProgramId(); ClusterMode clusterMode = ProgramRunners.getClusterMode(options);
@Override public final RuntimeInfo run(ProgramDescriptor programDescriptor, ProgramOptions options, RunId runId) { ProgramId programId = programDescriptor.getProgramId(); ClusterMode clusterMode = ProgramRunners.getClusterMode(options);
if (ProgramRunners.getClusterMode(contextConfig.getProgramOptions()) == ClusterMode.ON_PREMISE) { this.transaction = txClient.startLong();
/** * Creates a Guice {@link Module} that will be used to create the Guice {@link Injector} used for the * program execution. * * @param cConf the CDAP configuration * @param hConf the Hadoop configuration * @param programOptions the {@link ProgramOptions} for the program execution * @param programRunId the {@link ProgramRunId} for this program run. * @return a guice {@link Module}. */ protected Module createModule(CConfiguration cConf, Configuration hConf, ProgramOptions programOptions, ProgramRunId programRunId) { Module module = new DistributedProgramContainerModule(cConf, hConf, programRunId, programOptions.getArguments(), getServiceAnnouncer()); if (ProgramRunners.getClusterMode(programOptions) == ClusterMode.ISOLATED) { // In isolated mode, TMS runs in the "launcher" container. // We don't do this in the DistributedProgramContainerModule // because that module is used in both launcher and task containers module = Modules.override(module).with( new MessagingServerRuntimeModule().getStandaloneModules(), new AbstractModule() { @Override protected void configure() { // Bind a Cancellable for the RuntimeMonitor to stop this program run. bind(Cancellable.class).toInstance(() -> stop()); } }); } return module; }
if (ProgramRunners.getClusterMode(contextConfig.getProgramOptions()) == ClusterMode.ON_PREMISE) { this.transaction = txClient.startLong();
/** * Creates a Guice {@link Module} that will be used to create the Guice {@link Injector} used for the * program execution. * * @param cConf the CDAP configuration * @param hConf the Hadoop configuration * @param programOptions the {@link ProgramOptions} for the program execution * @param programRunId the {@link ProgramRunId} for this program run. * @return a guice {@link Module}. */ protected Module createModule(CConfiguration cConf, Configuration hConf, ProgramOptions programOptions, ProgramRunId programRunId) { Module module = new DistributedProgramContainerModule(cConf, hConf, programRunId, programOptions.getArguments(), getServiceAnnouncer()); if (ProgramRunners.getClusterMode(programOptions) == ClusterMode.ISOLATED) { // In isolated mode, TMS runs in the "launcher" container. // We don't do this in the DistributedProgramContainerModule // because that module is used in both launcher and task containers module = Modules.override(module).with( new MessagingServerRuntimeModule().getStandaloneModules(), new AbstractModule() { @Override protected void configure() { // Bind a Cancellable for the RuntimeMonitor to stop this program run. bind(Cancellable.class).toInstance(() -> stop()); } }); } return module; }