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));
}
}
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();
}
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;
}
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));
}
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();
}
Aggregations