Search in sources :

Example 1 with LevelDBTableFactory

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);
}
Also used : InMemoryNamespaceAdmin(io.cdap.cdap.common.namespace.InMemoryNamespaceAdmin) LevelDBTableFactory(io.cdap.cdap.messaging.store.leveldb.LevelDBTableFactory) BeforeClass(org.junit.BeforeClass)

Example 2 with LevelDBTableFactory

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);
        }
    });
}
Also used : MessageTableCacheProvider(io.cdap.cdap.messaging.store.cache.MessageTableCacheProvider) DefaultMessageTableCacheProvider(io.cdap.cdap.messaging.store.cache.DefaultMessageTableCacheProvider) ZKDiscoveryModule(io.cdap.cdap.common.guice.ZKDiscoveryModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) CachingTableFactory(io.cdap.cdap.messaging.store.cache.CachingTableFactory) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) AbstractModule(com.google.inject.AbstractModule) MessagingService(io.cdap.cdap.messaging.MessagingService) ZKClientModule(io.cdap.cdap.common.guice.ZKClientModule) DFSLocationModule(io.cdap.cdap.common.guice.DFSLocationModule) CachingTableFactory(io.cdap.cdap.messaging.store.cache.CachingTableFactory) TableFactory(io.cdap.cdap.messaging.store.TableFactory) LevelDBTableFactory(io.cdap.cdap.messaging.store.leveldb.LevelDBTableFactory) PrivateModule(com.google.inject.PrivateModule)

Aggregations

LevelDBTableFactory (io.cdap.cdap.messaging.store.leveldb.LevelDBTableFactory)2 AbstractModule (com.google.inject.AbstractModule)1 PrivateModule (com.google.inject.PrivateModule)1 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)1 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)1 DFSLocationModule (io.cdap.cdap.common.guice.DFSLocationModule)1 ZKClientModule (io.cdap.cdap.common.guice.ZKClientModule)1 ZKDiscoveryModule (io.cdap.cdap.common.guice.ZKDiscoveryModule)1 NoOpMetricsCollectionService (io.cdap.cdap.common.metrics.NoOpMetricsCollectionService)1 InMemoryNamespaceAdmin (io.cdap.cdap.common.namespace.InMemoryNamespaceAdmin)1 MessagingService (io.cdap.cdap.messaging.MessagingService)1 TableFactory (io.cdap.cdap.messaging.store.TableFactory)1 CachingTableFactory (io.cdap.cdap.messaging.store.cache.CachingTableFactory)1 DefaultMessageTableCacheProvider (io.cdap.cdap.messaging.store.cache.DefaultMessageTableCacheProvider)1 MessageTableCacheProvider (io.cdap.cdap.messaging.store.cache.MessageTableCacheProvider)1 BeforeClass (org.junit.BeforeClass)1