Search in sources :

Example 51 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class MessagingHttpServiceTest method init.

@BeforeClass
public static void init() throws IOException {
    cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    cConf.setInt(Constants.MessagingSystem.HTTP_SERVER_CONSUME_CHUNK_SIZE, 128);
    // Set max life time to a high value so that dummy tx ids that we create in the tests still work
    cConf.setLong(TxConstants.Manager.CFG_TX_MAX_LIFETIME, 10000000000L);
    Injector injector = Guice.createInjector(new ConfigModule(cConf), new DiscoveryRuntimeModule().getInMemoryModules(), new MessagingServerRuntimeModule().getInMemoryModules(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).toInstance(new NoOpMetricsCollectionService());
        }
    });
    httpService = injector.getInstance(MessagingHttpService.class);
    httpService.startAndWait();
    client = new ClientMessagingService(injector.getInstance(DiscoveryServiceClient.class));
}
Also used : Injector(com.google.inject.Injector) ConfigModule(co.cask.cdap.common.guice.ConfigModule) MessagingServerRuntimeModule(co.cask.cdap.messaging.guice.MessagingServerRuntimeModule) ClientMessagingService(co.cask.cdap.messaging.client.ClientMessagingService) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) AbstractModule(com.google.inject.AbstractModule) BeforeClass(org.junit.BeforeClass)

Example 52 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class DistributedLogFrameworkTest method createInjector.

private Injector createInjector() throws IOException {
    CConfiguration cConf = CConfiguration.copy(KAFKA_TESTER.getCConf());
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    // The event delay cannot be too small, otherwise the events will be out of order, especially on slow machine
    cConf.setLong(Constants.Logging.PIPELINE_EVENT_DELAY_MS, 2000);
    cConf.setLong("log.process.pipeline.checkpoint.interval.ms", 2000);
    return Guice.createInjector(new ConfigModule(cConf), new ZKClientModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new KafkaClientModule(), new LocationRuntimeModule().getInMemoryModules(), new DistributedLogFrameworkModule(new MockTwillContext()), new DataSetsModules().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new NamespaceClientRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
            bind(UGIProvider.class).to(CurrentUGIProvider.class);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
        }
    });
}
Also used : NamespaceClientRuntimeModule(co.cask.cdap.common.namespace.guice.NamespaceClientRuntimeModule) MockTwillContext(co.cask.cdap.common.test.MockTwillContext) ConfigModule(co.cask.cdap.common.guice.ConfigModule) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) LocationRuntimeModule(co.cask.cdap.common.guice.LocationRuntimeModule) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) DefaultOwnerAdmin(co.cask.cdap.security.impersonation.DefaultOwnerAdmin) CConfiguration(co.cask.cdap.common.conf.CConfiguration) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) AbstractModule(com.google.inject.AbstractModule) TransactionModules(org.apache.tephra.runtime.TransactionModules) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) TransactionExecutorModule(co.cask.cdap.data.runtime.TransactionExecutorModule) KafkaClientModule(co.cask.cdap.common.guice.KafkaClientModule) DistributedLogFrameworkModule(co.cask.cdap.logging.guice.DistributedLogFrameworkModule) CurrentUGIProvider(co.cask.cdap.security.impersonation.CurrentUGIProvider) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule)

Example 53 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class MetricsTestBase method getModules.

private List<Module> getModules() {
    List<Module> modules = new ArrayList<>();
    modules.add(new ConfigModule(cConf));
    modules.add(new DiscoveryRuntimeModule().getInMemoryModules());
    modules.add(new MessagingServerRuntimeModule().getInMemoryModules());
    modules.add(new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).toInstance(new NoOpMetricsCollectionService());
        }
    });
    modules.addAll(getAdditionalModules());
    return modules;
}
Also used : ConfigModule(co.cask.cdap.common.guice.ConfigModule) ArrayList(java.util.ArrayList) MessagingServerRuntimeModule(co.cask.cdap.messaging.guice.MessagingServerRuntimeModule) Module(com.google.inject.Module) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) MessagingServerRuntimeModule(co.cask.cdap.messaging.guice.MessagingServerRuntimeModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) AbstractModule(com.google.inject.AbstractModule) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) AbstractModule(com.google.inject.AbstractModule)

Example 54 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class ConfigurationCheckTest method runConfigurationCheck.

private void runConfigurationCheck(String param, String invalidValue) {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(param, invalidValue);
    Injector injector = Guice.createInjector(new ConfigModule(cConf));
    ConfigurationCheck configurationCheck = injector.getInstance(ConfigurationCheck.class);
    configurationCheck.run();
}
Also used : Injector(com.google.inject.Injector) ConfigModule(co.cask.cdap.common.guice.ConfigModule) CConfiguration(co.cask.cdap.common.conf.CConfiguration)

Example 55 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class CDAPLogAppenderTest method setUpContext.

@BeforeClass
public static void setUpContext() throws Exception {
    Configuration hConf = HBaseConfiguration.create();
    final CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TMP_FOLDER.newFolder().getAbsolutePath());
    String logBaseDir = cConf.get(LoggingConfiguration.LOG_BASE_DIR) + "/" + CDAPLogAppender.class.getSimpleName();
    cConf.set(LoggingConfiguration.LOG_BASE_DIR, logBaseDir);
    injector = Guice.createInjector(new ConfigModule(cConf, hConf), new NonCustomLocationUnitTestModule().getModule(), new TransactionModules().getInMemoryModules(), new LoggingModules().getInMemoryModules(), new DataSetsModules().getInMemoryModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
            bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
            bind(NamespaceQueryAdmin.class).to(SimpleNamespaceQueryAdmin.class);
        }
    });
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
}
Also used : CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) LoggingConfiguration(co.cask.cdap.logging.LoggingConfiguration) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) ConfigModule(co.cask.cdap.common.guice.ConfigModule) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) UGIProvider(co.cask.cdap.security.impersonation.UGIProvider) UnsupportedUGIProvider(co.cask.cdap.security.impersonation.UnsupportedUGIProvider) DefaultOwnerAdmin(co.cask.cdap.security.impersonation.DefaultOwnerAdmin) OwnerAdmin(co.cask.cdap.security.impersonation.OwnerAdmin) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) CConfiguration(co.cask.cdap.common.conf.CConfiguration) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) LoggingModules(co.cask.cdap.logging.guice.LoggingModules) AbstractModule(com.google.inject.AbstractModule) TransactionModules(org.apache.tephra.runtime.TransactionModules) TransactionManager(org.apache.tephra.TransactionManager) SimpleNamespaceQueryAdmin(co.cask.cdap.common.namespace.SimpleNamespaceQueryAdmin) NamespaceQueryAdmin(co.cask.cdap.common.namespace.NamespaceQueryAdmin) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Aggregations

ConfigModule (co.cask.cdap.common.guice.ConfigModule)77 AuthorizationEnforcementModule (co.cask.cdap.security.authorization.AuthorizationEnforcementModule)56 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)55 DataSetsModules (co.cask.cdap.data.runtime.DataSetsModules)53 AbstractModule (com.google.inject.AbstractModule)53 AuthenticationContextModules (co.cask.cdap.security.auth.context.AuthenticationContextModules)51 AuthorizationTestModule (co.cask.cdap.security.authorization.AuthorizationTestModule)48 CConfiguration (co.cask.cdap.common.conf.CConfiguration)46 BeforeClass (org.junit.BeforeClass)45 Injector (com.google.inject.Injector)44 NonCustomLocationUnitTestModule (co.cask.cdap.common.guice.NonCustomLocationUnitTestModule)41 UnsupportedUGIProvider (co.cask.cdap.security.impersonation.UnsupportedUGIProvider)35 DefaultOwnerAdmin (co.cask.cdap.security.impersonation.DefaultOwnerAdmin)34 DataFabricModules (co.cask.cdap.data.runtime.DataFabricModules)33 ExploreClientModule (co.cask.cdap.explore.guice.ExploreClientModule)31 SystemDatasetRuntimeModule (co.cask.cdap.data.runtime.SystemDatasetRuntimeModule)30 TransactionManager (org.apache.tephra.TransactionManager)27 TransactionMetricsModule (co.cask.cdap.data.runtime.TransactionMetricsModule)25 Configuration (org.apache.hadoop.conf.Configuration)25 ViewAdminModules (co.cask.cdap.data.view.ViewAdminModules)24