use of io.cdap.cdap.runtime.spi.RuntimeMonitorType 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 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.runtime.spi.RuntimeMonitorType in project cdap by caskdata.
the class RuntimeMonitors method setupMonitoring.
/**
* Setups the monitoring routes and proxy for runtime monitoring.
*/
public static void setupMonitoring(Injector injector, ProgramOptions programOpts) throws Exception {
CConfiguration cConf = injector.getInstance(CConfiguration.class);
RuntimeMonitorType monitorType = injector.getInstance(RuntimeMonitorType.class);
if (monitorType == RuntimeMonitorType.URL) {
// This shouldn't be null, otherwise the type won't be URL.
String monitorURL = cConf.get(Constants.RuntimeMonitor.MONITOR_URL);
monitorURL = monitorURL.endsWith("/") ? monitorURL : monitorURL + "/";
ProgramRunId programRunId = injector.getInstance(ProgramRunId.class);
WorkflowProgramInfo workflowInfo = WorkflowProgramInfo.create(programOpts.getArguments());
if (workflowInfo != null) {
// If the program is launched by Workflow, use the Workflow run id to make service request.
programRunId = new ProgramRunId(programRunId.getNamespace(), programRunId.getApplication(), ProgramType.WORKFLOW, workflowInfo.getName(), workflowInfo.getRunId().getId());
}
URI runtimeServiceBaseURI = URI.create(monitorURL).resolve(String.format("v3Internal/runtime/namespaces/%s/apps/%s/versions/%s/%s/%s/runs/%s/services/", programRunId.getNamespace(), programRunId.getApplication(), programRunId.getVersion(), programRunId.getType().getCategoryName(), programRunId.getProgram(), programRunId.getRun()));
System.setProperty(RemoteClient.RUNTIME_SERVICE_ROUTING_BASE_URI, runtimeServiceBaseURI.toString());
LOG.debug("Setting runtime service routing base URI to {}", runtimeServiceBaseURI);
} else {
Authenticator.setDefault(injector.getInstance(Authenticator.class));
ProxySelector.setDefault(injector.getInstance(ProxySelector.class));
}
}
use of io.cdap.cdap.runtime.spi.RuntimeMonitorType in project cdap by caskdata.
the class DistributedProgramContainerModule method configure.
@Override
protected void configure() {
List<Module> modules = getCoreModules();
RuntimeMonitorType runtimeMonitorType = SystemArguments.getRuntimeMonitorType(cConf, programOpts);
modules.add(RuntimeMonitors.getRemoteAuthenticatorModule(runtimeMonitorType, programOpts));
install(Modules.override(modules).with(new AbstractModule() {
@Override
protected void configure() {
// Overrides the LineageWriter, UsageWriter to write to TMS instead
bind(LineageWriter.class).to(MessagingLineageWriter.class);
bind(FieldLineageWriter.class).to(MessagingLineageWriter.class);
bind(UsageWriter.class).to(MessagingUsageWriter.class);
// Overrides the metadata store to be no-op (programs never access it directly)
bind(MetadataStorage.class).to(NoopMetadataStorage.class);
}
}));
bind(RuntimeMonitorType.class).toInstance(runtimeMonitorType);
}
use of io.cdap.cdap.runtime.spi.RuntimeMonitorType in project cdap by caskdata.
the class ProvisioningService method createContext.
private ProvisionerContext createContext(CConfiguration cConf, ProgramOptions programOptions, ProgramRunId programRunId, String userId, Map<String, String> properties, @Nullable SSHContext sshContext) {
RuntimeMonitorType runtimeMonitorType = SystemArguments.getRuntimeMonitorType(cConf, programOptions);
Map<String, String> systemArgs = programOptions.getArguments().asMap();
String provisionerName = SystemArguments.getProfileProvisioner(systemArgs);
String profileName = SystemArguments.getProfileIdFromArgs(programRunId.getNamespaceId(), systemArgs).map(ProfileId::getEntityName).orElse(null);
VersionInfo appCDAPVersion = getAppCDAPVersion(programOptions);
Map<String, String> evaluated = evaluateMacros(secureStore, userId, programRunId.getNamespace(), properties);
return new DefaultProvisionerContext(programRunId, provisionerName, evaluated, sparkCompat, sshContext, appCDAPVersion, locationFactory, runtimeMonitorType, metricsCollectionService, profileName, contextExecutor);
}
Aggregations