Search in sources :

Example 1 with SystemAppModule

use of io.cdap.cdap.internal.app.worker.SystemAppModule in project cdap by caskdata.

the class SystemWorkerTwillRunnable method createInjector.

@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf) {
    List<Module> modules = new ArrayList<>();
    CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
    modules.add(new ConfigModule(cConf, hConf));
    modules.add(new LocalLocationModule());
    modules.add(new IOModule());
    modules.add(new AuthenticationContextModules().getMasterWorkerModule());
    modules.add(coreSecurityModule);
    modules.add(new MessagingClientModule());
    modules.add(new SystemAppModule());
    modules.add(new MetricsClientRuntimeModule().getDistributedModules());
    // 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) ZKDiscoveryModule(io.cdap.cdap.common.guice.ZKDiscoveryModule) 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) KafkaLogAppenderModule(io.cdap.cdap.logging.guice.KafkaLogAppenderModule) AbstractModule(com.google.inject.AbstractModule) ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) CoreSecurityModule(io.cdap.cdap.security.guice.CoreSecurityModule) MasterEnvironment(io.cdap.cdap.master.spi.environment.MasterEnvironment) KafkaClientModule(io.cdap.cdap.common.guice.KafkaClientModule) 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) SystemAppModule(io.cdap.cdap.internal.app.worker.SystemAppModule) KafkaLogAppenderModule(io.cdap.cdap.logging.guice.KafkaLogAppenderModule) MessagingClientModule(io.cdap.cdap.messaging.guice.MessagingClientModule) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) RemoteLogAppenderModule(io.cdap.cdap.logging.guice.RemoteLogAppenderModule) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) KafkaClientModule(io.cdap.cdap.common.guice.KafkaClientModule) ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) 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) SystemAppModule(io.cdap.cdap.internal.app.worker.SystemAppModule) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)1 IOModule (io.cdap.cdap.common.guice.IOModule)1 KafkaClientModule (io.cdap.cdap.common.guice.KafkaClientModule)1 LocalLocationModule (io.cdap.cdap.common.guice.LocalLocationModule)1 SupplierProviderBridge (io.cdap.cdap.common.guice.SupplierProviderBridge)1 ZKClientModule (io.cdap.cdap.common.guice.ZKClientModule)1 ZKDiscoveryModule (io.cdap.cdap.common.guice.ZKDiscoveryModule)1 SystemAppModule (io.cdap.cdap.internal.app.worker.SystemAppModule)1 KafkaLogAppenderModule (io.cdap.cdap.logging.guice.KafkaLogAppenderModule)1 RemoteLogAppenderModule (io.cdap.cdap.logging.guice.RemoteLogAppenderModule)1 MasterEnvironment (io.cdap.cdap.master.spi.environment.MasterEnvironment)1 MessagingClientModule (io.cdap.cdap.messaging.guice.MessagingClientModule)1 MetricsClientRuntimeModule (io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule)1 AuthenticationContextModules (io.cdap.cdap.security.auth.context.AuthenticationContextModules)1 CoreSecurityModule (io.cdap.cdap.security.guice.CoreSecurityModule)1 CoreSecurityRuntimeModule (io.cdap.cdap.security.guice.CoreSecurityRuntimeModule)1 ArrayList (java.util.ArrayList)1