use of io.cdap.cdap.proto.ProgramType in project cdap by caskdata.
the class DefaultRuntimeJob method createModules.
/**
* Returns list of guice modules used to start the program run.
*/
@VisibleForTesting
List<Module> createModules(RuntimeJobEnvironment runtimeJobEnv, CConfiguration cConf, ProgramRunId programRunId, ProgramOptions programOpts) {
List<Module> modules = new ArrayList<>();
modules.add(new ConfigModule(cConf));
RuntimeMonitorType runtimeMonitorType = SystemArguments.getRuntimeMonitorType(cConf, programOpts);
modules.add(RuntimeMonitors.getRemoteAuthenticatorModule(runtimeMonitorType, programOpts));
modules.add(new IOModule());
modules.add(new TMSLogAppenderModule());
modules.add(new RemoteExecutionDiscoveryModule());
modules.add(new AuthorizationEnforcementModule().getDistributedModules());
modules.add(new AuthenticationContextModules().getProgramContainerModule(cConf));
modules.add(new MetricsClientRuntimeModule().getDistributedModules());
modules.add(new MessagingServerRuntimeModule().getStandaloneModules());
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(ClusterMode.class).toInstance(ClusterMode.ISOLATED);
bind(UGIProvider.class).to(CurrentUGIProvider.class).in(Scopes.SINGLETON);
// Bindings from the environment
bind(TwillRunner.class).annotatedWith(Constants.AppFabric.ProgramRunner.class).toInstance(runtimeJobEnv.getTwillRunner());
bind(LocationFactory.class).toInstance(runtimeJobEnv.getLocationFactory());
MapBinder<ProgramType, ProgramRunner> defaultProgramRunnerBinder = MapBinder.newMapBinder(binder(), ProgramType.class, ProgramRunner.class);
bind(ProgramRuntimeProvider.Mode.class).toInstance(ProgramRuntimeProvider.Mode.DISTRIBUTED);
bind(ProgramRunnerFactory.class).annotatedWith(Constants.AppFabric.ProgramRunner.class).to(DefaultProgramRunnerFactory.class).in(Scopes.SINGLETON);
bind(ProgramStateWriter.class).to(MessagingProgramStateWriter.class).in(Scopes.SINGLETON);
defaultProgramRunnerBinder.addBinding(ProgramType.MAPREDUCE).to(DistributedMapReduceProgramRunner.class);
defaultProgramRunnerBinder.addBinding(ProgramType.WORKFLOW).to(DistributedWorkflowProgramRunner.class);
defaultProgramRunnerBinder.addBinding(ProgramType.WORKER).to(DistributedWorkerProgramRunner.class);
bind(ProgramRunnerFactory.class).to(DefaultProgramRunnerFactory.class).in(Scopes.SINGLETON);
bind(ProgramRunId.class).toInstance(programRunId);
bind(RuntimeMonitorType.class).toInstance(runtimeMonitorType);
install(new FactoryModuleBuilder().implement(Configurator.class, InMemoryConfigurator.class).build(ConfiguratorFactory.class));
bind(String.class).annotatedWith(Names.named(RemoteIsolatedPluginFinder.ISOLATED_PLUGIN_DIR)).toInstance(programOpts.getArguments().getOption(ProgramOptionConstants.PLUGIN_DIR, DistributedProgramRunner.PLUGIN_DIR));
bind(PluginFinder.class).to(RemoteIsolatedPluginFinder.class);
bind(ArtifactRepositoryReader.class).to(RemoteArtifactRepositoryReader.class).in(Scopes.SINGLETON);
bind(ArtifactRepository.class).to(RemoteArtifactRepository.class);
}
});
return modules;
}
use of io.cdap.cdap.proto.ProgramType in project cdap by caskdata.
the class DistributedServiceProgramRunner method validateOptions.
@Override
protected void validateOptions(Program program, ProgramOptions options) {
super.validateOptions(program, options);
// Extract and verify parameters
ApplicationSpecification appSpec = program.getApplicationSpecification();
Preconditions.checkNotNull(appSpec, "Missing application specification.");
ProgramType processorType = program.getType();
Preconditions.checkNotNull(processorType, "Missing processor type.");
Preconditions.checkArgument(processorType == ProgramType.SERVICE, "Only SERVICE process type is supported.");
ServiceSpecification serviceSpec = appSpec.getServices().get(program.getName());
Preconditions.checkNotNull(serviceSpec, "Missing ServiceSpecification for %s", program.getName());
}
use of io.cdap.cdap.proto.ProgramType 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.proto.ProgramType in project cdap by caskdata.
the class ProgramGenerationStage method process.
@Override
public void process(final ApplicationDeployable input) throws Exception {
List<ProgramDescriptor> programDescriptors = new ArrayList<>();
final ApplicationSpecification appSpec = input.getSpecification();
// Now, we iterate through all ProgramSpecification and generate programs
Iterable<ProgramSpecification> specifications = Iterables.concat(appSpec.getMapReduce().values(), appSpec.getWorkflows().values(), appSpec.getServices().values(), appSpec.getSpark().values(), appSpec.getWorkers().values());
for (ProgramSpecification spec : specifications) {
ProgramType type = ProgramTypes.fromSpecification(spec);
ProgramId programId = input.getApplicationId().program(type, spec.getName());
programDescriptors.add(new ProgramDescriptor(programId, appSpec));
}
emit(new ApplicationWithPrograms(input, programDescriptors));
}
use of io.cdap.cdap.proto.ProgramType in project cdap by caskdata.
the class DeletedProgramHandlerStage method process.
@Override
public void process(ApplicationDeployable appSpec) throws Exception {
List<ProgramSpecification> deletedSpecs = store.getDeletedProgramSpecifications(appSpec.getApplicationId(), appSpec.getSpecification());
// TODO: this should also delete logs and run records (or not?), and do it for all program types [CDAP-2187]
Set<ProgramId> deletedPrograms = new HashSet<>();
for (ProgramSpecification spec : deletedSpecs) {
// call the deleted spec
ProgramType type = ProgramTypes.fromSpecification(spec);
ProgramId programId = appSpec.getApplicationId().program(type, spec.getName());
programTerminator.stop(programId);
programScheduler.deleteSchedules(programId);
programScheduler.modifySchedulesTriggeredByDeletedProgram(programId);
// Remove metadata for the deleted program
metadataServiceClient.drop(new MetadataMutation.Drop(programId.toMetadataEntity()));
deletedPrograms.add(programId);
}
deleteMetrics(deletedPrograms);
emit(appSpec);
}
Aggregations