Search in sources :

Example 1 with RuntimeMonitorType

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;
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) RuntimeMonitorType(io.cdap.cdap.runtime.spi.RuntimeMonitorType) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) InMemoryConfigurator(io.cdap.cdap.internal.app.deploy.InMemoryConfigurator) Configurator(io.cdap.cdap.app.deploy.Configurator) UGIProvider(io.cdap.cdap.security.impersonation.UGIProvider) CurrentUGIProvider(io.cdap.cdap.security.impersonation.CurrentUGIProvider) TwillRunner(org.apache.twill.api.TwillRunner) ArrayList(java.util.ArrayList) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) RemoteExecutionDiscoveryModule(io.cdap.cdap.app.guice.RemoteExecutionDiscoveryModule) ProgramRunnerFactory(io.cdap.cdap.app.runtime.ProgramRunnerFactory) DefaultProgramRunnerFactory(io.cdap.cdap.app.guice.DefaultProgramRunnerFactory) ArtifactRepositoryReader(io.cdap.cdap.internal.app.runtime.artifact.ArtifactRepositoryReader) RemoteArtifactRepositoryReader(io.cdap.cdap.internal.app.runtime.artifact.RemoteArtifactRepositoryReader) TMSLogAppenderModule(io.cdap.cdap.logging.guice.TMSLogAppenderModule) ProgramStateWriter(io.cdap.cdap.app.runtime.ProgramStateWriter) MessagingProgramStateWriter(io.cdap.cdap.internal.app.program.MessagingProgramStateWriter) RemoteArtifactRepository(io.cdap.cdap.internal.app.runtime.artifact.RemoteArtifactRepository) ProgramType(io.cdap.cdap.proto.ProgramType) DistributedWorkflowProgramRunner(io.cdap.cdap.internal.app.runtime.distributed.DistributedWorkflowProgramRunner) DistributedProgramRunner(io.cdap.cdap.internal.app.runtime.distributed.DistributedProgramRunner) DistributedMapReduceProgramRunner(io.cdap.cdap.internal.app.runtime.distributed.DistributedMapReduceProgramRunner) DistributedWorkerProgramRunner(io.cdap.cdap.internal.app.runtime.distributed.DistributedWorkerProgramRunner) ProgramRunner(io.cdap.cdap.app.runtime.ProgramRunner) DistributedWorkflowProgramRunner(io.cdap.cdap.internal.app.runtime.distributed.DistributedWorkflowProgramRunner) AuthenticationContextModules(io.cdap.cdap.security.auth.context.AuthenticationContextModules) Constants(io.cdap.cdap.common.conf.Constants) ProgramOptionConstants(io.cdap.cdap.internal.app.runtime.ProgramOptionConstants) RemoteIsolatedPluginFinder(io.cdap.cdap.internal.app.runtime.artifact.RemoteIsolatedPluginFinder) DistributedMapReduceProgramRunner(io.cdap.cdap.internal.app.runtime.distributed.DistributedMapReduceProgramRunner) AbstractModule(com.google.inject.AbstractModule) ProgramRuntimeProvider(io.cdap.cdap.app.runtime.ProgramRuntimeProvider) MapBinder(com.google.inject.multibindings.MapBinder) DistributedWorkerProgramRunner(io.cdap.cdap.internal.app.runtime.distributed.DistributedWorkerProgramRunner) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) TMSLogAppenderModule(io.cdap.cdap.logging.guice.TMSLogAppenderModule) IOModule(io.cdap.cdap.common.guice.IOModule) AbstractModule(com.google.inject.AbstractModule) Module(com.google.inject.Module) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) RemoteExecutionDiscoveryModule(io.cdap.cdap.app.guice.RemoteExecutionDiscoveryModule) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) InMemoryConfigurator(io.cdap.cdap.internal.app.deploy.InMemoryConfigurator) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with RuntimeMonitorType

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));
    }
}
Also used : ProxySelector(java.net.ProxySelector) RuntimeMonitorType(io.cdap.cdap.runtime.spi.RuntimeMonitorType) WorkflowProgramInfo(io.cdap.cdap.internal.app.runtime.workflow.WorkflowProgramInfo) ProgramRunId(io.cdap.cdap.proto.id.ProgramRunId) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) URI(java.net.URI) Authenticator(java.net.Authenticator)

Example 3 with RuntimeMonitorType

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);
}
Also used : RuntimeMonitorType(io.cdap.cdap.runtime.spi.RuntimeMonitorType) UsageWriter(io.cdap.cdap.data2.registry.UsageWriter) MessagingUsageWriter(io.cdap.cdap.data2.registry.MessagingUsageWriter) FieldLineageWriter(io.cdap.cdap.data2.metadata.writer.FieldLineageWriter) LineageWriter(io.cdap.cdap.data2.metadata.writer.LineageWriter) MessagingLineageWriter(io.cdap.cdap.data2.metadata.writer.MessagingLineageWriter) MetadataStorage(io.cdap.cdap.spi.metadata.MetadataStorage) NoopMetadataStorage(io.cdap.cdap.spi.metadata.noop.NoopMetadataStorage) Module(com.google.inject.Module) SecureStoreClientModule(io.cdap.cdap.security.guice.SecureStoreClientModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) NamespaceQueryAdminModule(io.cdap.cdap.common.namespace.guice.NamespaceQueryAdminModule) SystemDatasetRuntimeModule(io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) DFSLocationModule(io.cdap.cdap.common.guice.DFSLocationModule) KafkaLogAppenderModule(io.cdap.cdap.logging.guice.KafkaLogAppenderModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) KafkaClientModule(io.cdap.cdap.common.guice.KafkaClientModule) ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) TMSLogAppenderModule(io.cdap.cdap.logging.guice.TMSLogAppenderModule) AuditModule(io.cdap.cdap.data2.audit.AuditModule) IOModule(io.cdap.cdap.common.guice.IOModule) ZKDiscoveryModule(io.cdap.cdap.common.guice.ZKDiscoveryModule) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) AbstractModule(com.google.inject.AbstractModule) AbstractModule(com.google.inject.AbstractModule) FieldLineageWriter(io.cdap.cdap.data2.metadata.writer.FieldLineageWriter)

Example 4 with 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);
}
Also used : VersionInfo(io.cdap.cdap.runtime.spi.VersionInfo) RuntimeMonitorType(io.cdap.cdap.runtime.spi.RuntimeMonitorType)

Aggregations

RuntimeMonitorType (io.cdap.cdap.runtime.spi.RuntimeMonitorType)4 AbstractModule (com.google.inject.AbstractModule)2 Module (com.google.inject.Module)2 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)2 IOModule (io.cdap.cdap.common.guice.IOModule)2 TMSLogAppenderModule (io.cdap.cdap.logging.guice.TMSLogAppenderModule)2 MetricsClientRuntimeModule (io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 MapBinder (com.google.inject.multibindings.MapBinder)1 Configurator (io.cdap.cdap.app.deploy.Configurator)1 DefaultProgramRunnerFactory (io.cdap.cdap.app.guice.DefaultProgramRunnerFactory)1 RemoteExecutionDiscoveryModule (io.cdap.cdap.app.guice.RemoteExecutionDiscoveryModule)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 ProgramStateWriter (io.cdap.cdap.app.runtime.ProgramStateWriter)1 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)1 Constants (io.cdap.cdap.common.conf.Constants)1 DFSLocationModule (io.cdap.cdap.common.guice.DFSLocationModule)1