Search in sources :

Example 16 with MessagingServerRuntimeModule

use of io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule in project cdap by caskdata.

the class TestTMSLogging method init.

@BeforeClass
public static void init() throws IOException, TopicAlreadyExistsException, UnauthorizedException {
    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 InMemoryDiscoveryModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).toInstance(new NoOpMetricsCollectionService());
        }
    });
    client = injector.getInstance(MessagingService.class);
    tmsLogAppender = injector.getInstance(TMSLogAppender.class);
    String topicPrefic = cConf.get(Constants.Logging.TMS_TOPIC_PREFIX);
    int numPartitions = cConf.getInt(Constants.Logging.NUM_PARTITIONS);
    topicIds = new HashMap<>(numPartitions);
    for (int i = 0; i < numPartitions; i++) {
        topicIds.put(i, NamespaceId.SYSTEM.topic(topicPrefic + i));
    }
    for (TopicId topicId : topicIds.values()) {
        client.createTopic(new TopicMetadata(topicId));
    }
}
Also used : InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) AbstractModule(com.google.inject.AbstractModule) MessagingService(io.cdap.cdap.messaging.MessagingService) TopicMetadata(io.cdap.cdap.messaging.TopicMetadata) Injector(com.google.inject.Injector) TopicId(io.cdap.cdap.proto.id.TopicId) BeforeClass(org.junit.BeforeClass)

Example 17 with MessagingServerRuntimeModule

use of io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule in project cdap by caskdata.

the class MetricsAdminSubscriberServiceTest method init.

@BeforeClass
public static void init() throws IOException {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    // Shorten delay to speed up test
    cConf.setLong(Constants.Metrics.ADMIN_POLL_DELAY_MILLIS, 100L);
    injector = Guice.createInjector(new ConfigModule(cConf), new IOModule(), new InMemoryDiscoveryModule(), new MessagingServerRuntimeModule().getStandaloneModules(), new SystemDatasetRuntimeModule().getStandaloneModules(), // distributed mode. It requires bindings that are too cumbersome to construct them one by one.
    new PrivateModule() {

        @Override
        protected void configure() {
            install(new MetricsHandlerModule());
            expose(MetricsQueryService.class);
            install(new MetricsStoreModule());
            bind(MetricsCollectionService.class).to(LocalMetricsCollectionService.class).in(Scopes.SINGLETON);
            expose(MetricsCollectionService.class);
            // Bind the RemoteMetricsSystemClient for testing.
            bind(MetricsSystemClient.class).to(DirectMetricsSystemClient.class);
            expose(MetricsSystemClient.class);
            // Bind the admin subscriber
            bind(MetricsAdminSubscriberService.class).in(Scopes.SINGLETON);
            expose(MetricsAdminSubscriberService.class);
        }
    });
    messagingService = injector.getInstance(MessagingService.class);
    metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
    metricsQueryService = injector.getInstance(MetricsQueryService.class);
    if (messagingService instanceof Service) {
        ((Service) messagingService).startAndWait();
    }
    metricsCollectionService.startAndWait();
    metricsQueryService.startAndWait();
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) LocalMetricsCollectionService(io.cdap.cdap.metrics.collect.LocalMetricsCollectionService) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) MetricsStoreModule(io.cdap.cdap.metrics.guice.MetricsStoreModule) MetricsQueryService(io.cdap.cdap.metrics.query.MetricsQueryService) LocalMetricsCollectionService(io.cdap.cdap.metrics.collect.LocalMetricsCollectionService) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) LocalMetricsCollectionService(io.cdap.cdap.metrics.collect.LocalMetricsCollectionService) MetricsQueryService(io.cdap.cdap.metrics.query.MetricsQueryService) MessagingService(io.cdap.cdap.messaging.MessagingService) Service(com.google.common.util.concurrent.Service) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) MessagingService(io.cdap.cdap.messaging.MessagingService) MetricsHandlerModule(io.cdap.cdap.metrics.guice.MetricsHandlerModule) SystemDatasetRuntimeModule(io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule) MetricsSystemClient(io.cdap.cdap.api.metrics.MetricsSystemClient) PrivateModule(com.google.inject.PrivateModule) BeforeClass(org.junit.BeforeClass)

Example 18 with MessagingServerRuntimeModule

use of io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule 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(RemoteAuthenticatorModules.getNoOpModule());
    modules.add(new InMemoryDiscoveryModule());
    modules.add(new MessagingServerRuntimeModule().getInMemoryModules());
    modules.add(new MockMetricsWriterModule());
    modules.add(new AbstractModule() {

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

Example 19 with MessagingServerRuntimeModule

use of io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule in project cdap by caskdata.

the class TetheringProvisionerTest method testGuiceInjector.

@Test
public void testGuiceInjector() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocalLocationModule(), new InMemoryDiscoveryModule(), new StorageModule(), new ProvisionerModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
            bind(SecureStore.class).toInstance(FakeSecureStore.builder().build());
            bind(ProgramStateWriter.class).to(NoOpProgramStateWriter.class);
        }
    });
    ProvisionerProvider provisionerProvider = injector.getInstance(ProvisionerProvider.class);
    Map<String, Provisioner> provisioners = provisionerProvider.loadProvisioners();
    Assert.assertNotNull(provisioners.get(TetheringProvisioner.TETHERING_NAME));
    ProvisionerConfigProvider configProvider = injector.getInstance(ProvisionerConfigProvider.class);
    Map<String, ProvisionerConfig> configs = configProvider.loadProvisionerConfigs(provisioners.values());
    Assert.assertNotNull(configs.get(TetheringProvisioner.TETHERING_NAME));
}
Also used : NoOpProgramStateWriter(io.cdap.cdap.app.runtime.NoOpProgramStateWriter) ProvisionerProvider(io.cdap.cdap.internal.provision.ProvisionerProvider) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) ProvisionerConfigProvider(io.cdap.cdap.internal.provision.ProvisionerConfigProvider) StorageModule(io.cdap.cdap.data.runtime.StorageModule) ProvisionerModule(io.cdap.cdap.internal.provision.ProvisionerModule) ProvisionerConfig(io.cdap.cdap.internal.provision.ProvisionerConfig) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) Provisioner(io.cdap.cdap.runtime.spi.provisioner.Provisioner) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) AbstractModule(com.google.inject.AbstractModule) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 20 with MessagingServerRuntimeModule

use of io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule in project cdap by caskdata.

the class TetheringServerHandlerTest method setup.

@BeforeClass
public static void setup() throws IOException {
    cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    topicPrefix = cConf.get(Constants.Tethering.TOPIC_PREFIX);
    injector = Guice.createInjector(new ConfigModule(cConf), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new InMemoryDiscoveryModule(), new LocalLocationModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new StorageModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new PrivateModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
            expose(MetricsCollectionService.class);
        }
    });
    tetheringStore = new TetheringStore(injector.getInstance(TransactionRunner.class));
    messagingService = injector.getInstance(MessagingService.class);
    if (messagingService instanceof Service) {
        ((Service) messagingService).startAndWait();
    }
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
}
Also used : InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) StorageModule(io.cdap.cdap.data.runtime.StorageModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) AuthenticationContextModules(io.cdap.cdap.security.auth.context.AuthenticationContextModules) NettyHttpService(io.cdap.http.NettyHttpService) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) MessagingService(io.cdap.cdap.messaging.MessagingService) Service(com.google.common.util.concurrent.Service) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) AuthorizationTestModule(io.cdap.cdap.security.authorization.AuthorizationTestModule) MessagingService(io.cdap.cdap.messaging.MessagingService) TransactionModules(org.apache.tephra.runtime.TransactionModules) TransactionExecutorModule(io.cdap.cdap.data.runtime.TransactionExecutorModule) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) TransactionManager(org.apache.tephra.TransactionManager) SystemDatasetRuntimeModule(io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) PrivateModule(com.google.inject.PrivateModule) BeforeClass(org.junit.BeforeClass)

Aggregations

ConfigModule (io.cdap.cdap.common.guice.ConfigModule)32 MessagingServerRuntimeModule (io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule)32 InMemoryDiscoveryModule (io.cdap.cdap.common.guice.InMemoryDiscoveryModule)28 AbstractModule (com.google.inject.AbstractModule)24 AuthenticationContextModules (io.cdap.cdap.security.auth.context.AuthenticationContextModules)22 NoOpMetricsCollectionService (io.cdap.cdap.common.metrics.NoOpMetricsCollectionService)20 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)16 LocalLocationModule (io.cdap.cdap.common.guice.LocalLocationModule)16 MessagingService (io.cdap.cdap.messaging.MessagingService)16 Service (com.google.common.util.concurrent.Service)14 MetricsCollectionService (io.cdap.cdap.api.metrics.MetricsCollectionService)14 Injector (com.google.inject.Injector)12 IOModule (io.cdap.cdap.common.guice.IOModule)12 AuthorizationEnforcementModule (io.cdap.cdap.security.authorization.AuthorizationEnforcementModule)12 BeforeClass (org.junit.BeforeClass)12 MetricsClientRuntimeModule (io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule)10 RuntimeServerModule (io.cdap.cdap.app.guice.RuntimeServerModule)8 DataSetServiceModules (io.cdap.cdap.data.runtime.DataSetServiceModules)8 DataSetsModules (io.cdap.cdap.data.runtime.DataSetsModules)8 TransactionExecutorModule (io.cdap.cdap.data.runtime.TransactionExecutorModule)8