Search in sources :

Example 6 with SupplierProviderBridge

use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by caskdata.

the class SparkContainerDriverLauncher method createInjector.

@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf, MasterEnvironment masterEnv) {
    List<Module> modules = new ArrayList<>();
    CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
    modules.add(new ConfigModule(cConf, hConf));
    modules.add(RemoteAuthenticatorModules.getDefaultModule());
    modules.add(new IOModule());
    modules.add(new AuthenticationContextModules().getMasterWorkerModule());
    modules.add(coreSecurityModule);
    modules.add(new MessagingClientModule());
    modules.add(new MetricsClientRuntimeModule().getDistributedModules());
    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());
    return Guice.createInjector(modules);
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) 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) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) AbstractModule(com.google.inject.AbstractModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) SupplierProviderBridge(io.cdap.cdap.common.guice.SupplierProviderBridge) Module(com.google.inject.Module) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) IOModule(io.cdap.cdap.common.guice.IOModule) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) AbstractModule(com.google.inject.AbstractModule) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with SupplierProviderBridge

use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by cdapio.

the class PreviewServiceMain method getServiceModules.

@Override
protected List<Module> getServiceModules(MasterEnvironment masterEnv, EnvironmentOptions options, CConfiguration cConf) {
    List<Module> modules = new ArrayList<>(Arrays.asList(new DataSetServiceModules().getStandaloneModules(), new DataSetsModules().getStandaloneModules(), new AppFabricServiceRuntimeModule(cConf).getStandaloneModules(), new ProgramRunnerRuntimeModule().getStandaloneModules(), new MetricsStoreModule(), new MessagingClientModule(), new AuditModule(), new SecureStoreClientModule(), new MetadataReaderWriterModules().getStandaloneModules(), getDataFabricModule(), new DFSLocationModule(), new MetadataServiceModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getDistributedModules(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(TwillRunnerService.class).toProvider(new SupplierProviderBridge<>(masterEnv.getTwillRunnerSupplier())).in(Scopes.SINGLETON);
            bind(TwillRunner.class).to(TwillRunnerService.class);
            bind(ExploreClient.class).to(UnsupportedExploreClient.class);
        }
    }));
    if (cConf.getInt(Constants.Preview.CONTAINER_COUNT) > 0) {
        modules.add(new PreviewManagerModule(true));
    } else {
        modules.add(new PreviewManagerModule(false));
        modules.add(new PreviewRunnerManagerModule().getStandaloneModules());
    }
    return modules;
}
Also used : MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) UnsupportedExploreClient(io.cdap.cdap.app.guice.UnsupportedExploreClient) ExploreClient(io.cdap.cdap.explore.client.ExploreClient) DataSetServiceModules(io.cdap.cdap.data.runtime.DataSetServiceModules) MetricsStoreModule(io.cdap.cdap.metrics.guice.MetricsStoreModule) PreviewManagerModule(io.cdap.cdap.app.preview.PreviewManagerModule) SecureStoreClientModule(io.cdap.cdap.security.guice.SecureStoreClientModule) DataSetsModules(io.cdap.cdap.data.runtime.DataSetsModules) TwillRunner(org.apache.twill.api.TwillRunner) ArrayList(java.util.ArrayList) MetadataServiceModule(io.cdap.cdap.metadata.MetadataServiceModule) AbstractModule(com.google.inject.AbstractModule) MetadataReaderWriterModules(io.cdap.cdap.metadata.MetadataReaderWriterModules) DFSLocationModule(io.cdap.cdap.common.guice.DFSLocationModule) ProgramRunnerRuntimeModule(io.cdap.cdap.app.guice.ProgramRunnerRuntimeModule) AuditModule(io.cdap.cdap.data2.audit.AuditModule) SupplierProviderBridge(io.cdap.cdap.common.guice.SupplierProviderBridge) PreviewRunnerManagerModule(io.cdap.cdap.app.preview.PreviewRunnerManagerModule) Module(com.google.inject.Module) SecureStoreClientModule(io.cdap.cdap.security.guice.SecureStoreClientModule) PreviewManagerModule(io.cdap.cdap.app.preview.PreviewManagerModule) MetricsStoreModule(io.cdap.cdap.metrics.guice.MetricsStoreModule) AuthorizationModule(io.cdap.cdap.app.guice.AuthorizationModule) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) AppFabricServiceRuntimeModule(io.cdap.cdap.app.guice.AppFabricServiceRuntimeModule) DFSLocationModule(io.cdap.cdap.common.guice.DFSLocationModule) AuditModule(io.cdap.cdap.data2.audit.AuditModule) ProgramRunnerRuntimeModule(io.cdap.cdap.app.guice.ProgramRunnerRuntimeModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) MetadataServiceModule(io.cdap.cdap.metadata.MetadataServiceModule) AbstractModule(com.google.inject.AbstractModule) PreviewRunnerManagerModule(io.cdap.cdap.app.preview.PreviewRunnerManagerModule) AuthorizationModule(io.cdap.cdap.app.guice.AuthorizationModule) AppFabricServiceRuntimeModule(io.cdap.cdap.app.guice.AppFabricServiceRuntimeModule) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule)

Example 8 with SupplierProviderBridge

use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by cdapio.

the class DistributedProgramContainerModule method addOnPremiseModules.

private void addOnPremiseModules(List<Module> modules) {
    CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
    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());
        return;
    }
    if (coreSecurityModule.requiresZKClient()) {
        modules.add(new ZKClientModule());
    }
    modules.add(new AbstractModule() {

        @Override
        protected void configure() {
            bind(DiscoveryService.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceSupplier()));
            bind(DiscoveryServiceClient.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceClientSupplier()));
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
        }
    });
    modules.add(new RemoteLogAppenderModule());
}
Also used : ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) MasterEnvironment(io.cdap.cdap.master.spi.environment.MasterEnvironment) ZKDiscoveryModule(io.cdap.cdap.common.guice.ZKDiscoveryModule) AuthenticationContextModules(io.cdap.cdap.security.auth.context.AuthenticationContextModules) KafkaClientModule(io.cdap.cdap.common.guice.KafkaClientModule) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) SupplierProviderBridge(io.cdap.cdap.common.guice.SupplierProviderBridge) DefaultOwnerAdmin(io.cdap.cdap.security.impersonation.DefaultOwnerAdmin) KafkaLogAppenderModule(io.cdap.cdap.logging.guice.KafkaLogAppenderModule) AbstractModule(com.google.inject.AbstractModule)

Example 9 with SupplierProviderBridge

use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by cdapio.

the class SparkContainerDriverLauncher method createInjector.

@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf, MasterEnvironment masterEnv) {
    List<Module> modules = new ArrayList<>();
    CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
    modules.add(new ConfigModule(cConf, hConf));
    modules.add(RemoteAuthenticatorModules.getDefaultModule());
    modules.add(new IOModule());
    modules.add(new AuthenticationContextModules().getMasterWorkerModule());
    modules.add(coreSecurityModule);
    modules.add(new MessagingClientModule());
    modules.add(new MetricsClientRuntimeModule().getDistributedModules());
    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());
    return Guice.createInjector(modules);
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) 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) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) AbstractModule(com.google.inject.AbstractModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) SupplierProviderBridge(io.cdap.cdap.common.guice.SupplierProviderBridge) Module(com.google.inject.Module) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) IOModule(io.cdap.cdap.common.guice.IOModule) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) AbstractModule(com.google.inject.AbstractModule) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 10 with SupplierProviderBridge

use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by cdapio.

the class SystemWorkerTwillRunnable method createInjector.

@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf, SConfiguration sConf) {
    List<Module> modules = new ArrayList<>();
    ExecutorService cleanupExecutorService = Executors.newFixedThreadPool(cConf.getInt(Constants.SystemWorker.CLEANUP_THREADS));
    CoreSecurityModule coreSecurityModule = new FileBasedCoreSecurityModule() {

        @Override
        protected void bindKeyManager(Binder binder) {
            super.bindKeyManager(binder);
            expose(KeyManager.class);
        }
    };
    modules.add(new RemoteTwillModule());
    modules.add(new ConfigModule(cConf, hConf, sConf));
    modules.add(RemoteAuthenticatorModules.getDefaultModule());
    modules.add(new IOModule());
    modules.add(new AuthenticationContextModules().getMasterModule());
    modules.add(coreSecurityModule);
    modules.add(new MetricsClientRuntimeModule().getDistributedModules());
    modules.addAll(Arrays.asList(// In K8s, there won't be HBase and the cdap-site should be set to use SQL store for StructuredTable.
    new DataSetServiceModules().getStandaloneModules(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(ExecutorService.class).annotatedWith(Names.named(Constants.SystemWorker.CLEANUP_EXECUTOR_SERVICE_BINDING)).toInstance(cleanupExecutorService);
        }
    }, // The Dataset set modules are only needed to satisfy dependency injection
    new DataSetsModules().getStandaloneModules(), new MessagingClientModule(), new ExploreClientModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getDistributedModules(), Modules.override(new AppFabricServiceRuntimeModule(cConf).getDistributedModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(StorageProviderNamespaceAdmin.class).to(LocalStorageProviderNamespaceAdmin.class);
        }
    }, new DistributedArtifactManagerModule()), Modules.override(new ProgramRunnerRuntimeModule().getDistributedModules(true)).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(RemoteExecutionTwillRunnerService.class).to(FireAndForgetTwillRunnerService.class).in(Scopes.SINGLETON);
        }
    }), new SecureStoreClientModule(), new AbstractModule() {

        @Override
        protected void configure() {
            install(new StorageModule());
            install(new TransactionExecutorModule());
            bind(TransactionSystemClientService.class).to(DelegatingTransactionSystemClientService.class);
            bind(TransactionSystemClient.class).to(ConstantTransactionSystemClient.class);
        }
    }, new DFSLocationModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetadataPublisher.class).to(MessagingMetadataPublisher.class);
            bind(MetadataServiceClient.class).to(DefaultMetadataServiceClient.class);
        }
    }));
    // 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());
        if (coreSecurityModule.requiresZKClient()) {
            modules.add(new ZKClientModule());
        }
    }
    return Guice.createInjector(modules);
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) DataSetServiceModules(io.cdap.cdap.data.runtime.DataSetServiceModules) StorageModule(io.cdap.cdap.data.runtime.StorageModule) SecureStoreClientModule(io.cdap.cdap.security.guice.SecureStoreClientModule) ZKDiscoveryModule(io.cdap.cdap.common.guice.ZKDiscoveryModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) ArrayList(java.util.ArrayList) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) Binder(com.google.inject.Binder) LocalStorageProviderNamespaceAdmin(io.cdap.cdap.internal.app.namespace.LocalStorageProviderNamespaceAdmin) TransactionExecutorModule(io.cdap.cdap.data.runtime.TransactionExecutorModule) ConstantTransactionSystemClient(io.cdap.cdap.data.runtime.ConstantTransactionSystemClient) TransactionSystemClient(org.apache.tephra.TransactionSystemClient) ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) FileBasedCoreSecurityModule(io.cdap.cdap.security.guice.FileBasedCoreSecurityModule) KafkaClientModule(io.cdap.cdap.common.guice.KafkaClientModule) DistributedArtifactManagerModule(io.cdap.cdap.app.guice.DistributedArtifactManagerModule) TransactionSystemClientService(io.cdap.cdap.data2.transaction.TransactionSystemClientService) DelegatingTransactionSystemClientService(io.cdap.cdap.data2.transaction.DelegatingTransactionSystemClientService) SupplierProviderBridge(io.cdap.cdap.common.guice.SupplierProviderBridge) AuthorizationModule(io.cdap.cdap.app.guice.AuthorizationModule) AuthenticationContextModules(io.cdap.cdap.security.auth.context.AuthenticationContextModules) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) DataSetsModules(io.cdap.cdap.data.runtime.DataSetsModules) RemoteExecutionTwillRunnerService(io.cdap.cdap.internal.app.runtime.distributed.remote.RemoteExecutionTwillRunnerService) MessagingMetadataPublisher(io.cdap.cdap.data2.metadata.writer.MessagingMetadataPublisher) MetadataPublisher(io.cdap.cdap.data2.metadata.writer.MetadataPublisher) AbstractModule(com.google.inject.AbstractModule) KafkaLogAppenderModule(io.cdap.cdap.logging.guice.KafkaLogAppenderModule) DefaultMetadataServiceClient(io.cdap.cdap.data2.metadata.writer.DefaultMetadataServiceClient) MetadataServiceClient(io.cdap.cdap.data2.metadata.writer.MetadataServiceClient) DFSLocationModule(io.cdap.cdap.common.guice.DFSLocationModule) ProgramRunnerRuntimeModule(io.cdap.cdap.app.guice.ProgramRunnerRuntimeModule) ExploreClientModule(io.cdap.cdap.explore.guice.ExploreClientModule) MasterEnvironment(io.cdap.cdap.master.spi.environment.MasterEnvironment) ExecutorService(java.util.concurrent.ExecutorService) Module(com.google.inject.Module) SecureStoreClientModule(io.cdap.cdap.security.guice.SecureStoreClientModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) AuthorizationModule(io.cdap.cdap.app.guice.AuthorizationModule) ExploreClientModule(io.cdap.cdap.explore.guice.ExploreClientModule) AppFabricServiceRuntimeModule(io.cdap.cdap.app.guice.AppFabricServiceRuntimeModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) DFSLocationModule(io.cdap.cdap.common.guice.DFSLocationModule) TransactionExecutorModule(io.cdap.cdap.data.runtime.TransactionExecutorModule) ProgramRunnerRuntimeModule(io.cdap.cdap.app.guice.ProgramRunnerRuntimeModule) KafkaLogAppenderModule(io.cdap.cdap.logging.guice.KafkaLogAppenderModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) FileBasedCoreSecurityModule(io.cdap.cdap.security.guice.FileBasedCoreSecurityModule) KafkaClientModule(io.cdap.cdap.common.guice.KafkaClientModule) ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) StorageModule(io.cdap.cdap.data.runtime.StorageModule) IOModule(io.cdap.cdap.common.guice.IOModule) DistributedArtifactManagerModule(io.cdap.cdap.app.guice.DistributedArtifactManagerModule) ZKDiscoveryModule(io.cdap.cdap.common.guice.ZKDiscoveryModule) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) AbstractModule(com.google.inject.AbstractModule) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) AppFabricServiceRuntimeModule(io.cdap.cdap.app.guice.AppFabricServiceRuntimeModule) FileBasedCoreSecurityModule(io.cdap.cdap.security.guice.FileBasedCoreSecurityModule) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

AbstractModule (com.google.inject.AbstractModule)18 SupplierProviderBridge (io.cdap.cdap.common.guice.SupplierProviderBridge)18 Module (com.google.inject.Module)16 RemoteLogAppenderModule (io.cdap.cdap.logging.guice.RemoteLogAppenderModule)16 AuthenticationContextModules (io.cdap.cdap.security.auth.context.AuthenticationContextModules)16 ArrayList (java.util.ArrayList)16 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)14 IOModule (io.cdap.cdap.common.guice.IOModule)14 ZKClientModule (io.cdap.cdap.common.guice.ZKClientModule)14 MessagingClientModule (io.cdap.cdap.messaging.guice.MessagingClientModule)14 CoreSecurityModule (io.cdap.cdap.security.guice.CoreSecurityModule)14 VisibleForTesting (com.google.common.annotations.VisibleForTesting)12 KafkaClientModule (io.cdap.cdap.common.guice.KafkaClientModule)12 ZKDiscoveryModule (io.cdap.cdap.common.guice.ZKDiscoveryModule)12 KafkaLogAppenderModule (io.cdap.cdap.logging.guice.KafkaLogAppenderModule)12 MasterEnvironment (io.cdap.cdap.master.spi.environment.MasterEnvironment)12 MetricsClientRuntimeModule (io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule)12 CoreSecurityRuntimeModule (io.cdap.cdap.security.guice.CoreSecurityRuntimeModule)10 DFSLocationModule (io.cdap.cdap.common.guice.DFSLocationModule)8 LocalLocationModule (io.cdap.cdap.common.guice.LocalLocationModule)6