use of io.cdap.cdap.messaging.store.leveldb.LevelDBTableFactory in project cdap by caskdata.
the class LeaderElectionMessagingServiceTest method init.
@BeforeClass
public static void init() throws IOException {
zkServer = InMemoryZKServer.builder().setDataDir(TEMP_FOLDER.newFolder()).build();
zkServer.startAndWait();
cConf = CConfiguration.create();
cConf.set(Constants.Zookeeper.QUORUM, zkServer.getConnectionStr());
cConf.setInt(Constants.Zookeeper.CFG_SESSION_TIMEOUT_MILLIS, 2000);
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.set(Constants.MessagingSystem.HTTP_SERVER_BIND_ADDRESS, InetAddress.getLocalHost().getHostName());
cConf.set(Constants.MessagingSystem.SYSTEM_TOPICS, "topic");
cConf.setLong(Constants.MessagingSystem.HA_FENCING_DELAY_SECONDS, 0L);
namespaceQueryAdmin = new InMemoryNamespaceAdmin();
levelDBTableFactory = new LevelDBTableFactory(cConf);
}
use of io.cdap.cdap.messaging.store.leveldb.LevelDBTableFactory in project cdap by caskdata.
the class LeaderElectionMessagingServiceTest method createInjector.
private Injector createInjector(int instanceId) {
CConfiguration cConf = CConfiguration.copy(LeaderElectionMessagingServiceTest.cConf);
cConf.setInt(Constants.MessagingSystem.CONTAINER_INSTANCE_ID, instanceId);
return Guice.createInjector(new ConfigModule(cConf), new ZKClientModule(), new ZKDiscoveryModule(), new DFSLocationModule(), new AbstractModule() {
@Override
protected void configure() {
// Bindings to services for testing only
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
// Use the same in memory client across all injectors.
bind(NamespaceQueryAdmin.class).toInstance(namespaceQueryAdmin);
}
}, new PrivateModule() {
@Override
protected void configure() {
// This is very similar to bindings in distributed mode, except we bind to level db instead of HBase
// Also the level DB has to be one instance since unit-test runs in the same process.
bind(TableFactory.class).annotatedWith(Names.named(CachingTableFactory.DELEGATE_TABLE_FACTORY)).toInstance(levelDBTableFactory);
// The cache must be in singleton scope
bind(MessageTableCacheProvider.class).to(DefaultMessageTableCacheProvider.class).in(Scopes.SINGLETON);
bind(TableFactory.class).to(CachingTableFactory.class);
// Bind http handlers
MessagingServerRuntimeModule.bindHandlers(binder(), Constants.MessagingSystem.HANDLER_BINDING_NAME);
bind(MessagingService.class).to(LeaderElectionMessagingService.class).in(Scopes.SINGLETON);
expose(MessagingService.class);
}
});
}
Aggregations