Search in sources :

Example 1 with LevelDBTableFactory

use of co.cask.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 DiscoveryRuntimeModule().getDistributedModules(), new LocationRuntimeModule().getDistributedModules(), 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 : DefaultMessageTableCacheProvider(co.cask.cdap.messaging.store.cache.DefaultMessageTableCacheProvider) MessageTableCacheProvider(co.cask.cdap.messaging.store.cache.MessageTableCacheProvider) ConfigModule(co.cask.cdap.common.guice.ConfigModule) CachingTableFactory(co.cask.cdap.messaging.store.cache.CachingTableFactory) LocationRuntimeModule(co.cask.cdap.common.guice.LocationRuntimeModule) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) CConfiguration(co.cask.cdap.common.conf.CConfiguration) AbstractModule(com.google.inject.AbstractModule) MessagingService(co.cask.cdap.messaging.MessagingService) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) CachingTableFactory(co.cask.cdap.messaging.store.cache.CachingTableFactory) TableFactory(co.cask.cdap.messaging.store.TableFactory) LevelDBTableFactory(co.cask.cdap.messaging.store.leveldb.LevelDBTableFactory) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) PrivateModule(com.google.inject.PrivateModule)

Example 2 with LevelDBTableFactory

use of co.cask.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 InMemoryNamespaceClient();
    levelDBTableFactory = new LevelDBTableFactory(cConf);
}
Also used : LevelDBTableFactory(co.cask.cdap.messaging.store.leveldb.LevelDBTableFactory) InMemoryNamespaceClient(co.cask.cdap.common.namespace.InMemoryNamespaceClient) BeforeClass(org.junit.BeforeClass)

Aggregations

LevelDBTableFactory (co.cask.cdap.messaging.store.leveldb.LevelDBTableFactory)2 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 ConfigModule (co.cask.cdap.common.guice.ConfigModule)1 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)1 LocationRuntimeModule (co.cask.cdap.common.guice.LocationRuntimeModule)1 ZKClientModule (co.cask.cdap.common.guice.ZKClientModule)1 NoOpMetricsCollectionService (co.cask.cdap.common.metrics.NoOpMetricsCollectionService)1 InMemoryNamespaceClient (co.cask.cdap.common.namespace.InMemoryNamespaceClient)1 MessagingService (co.cask.cdap.messaging.MessagingService)1 TableFactory (co.cask.cdap.messaging.store.TableFactory)1 CachingTableFactory (co.cask.cdap.messaging.store.cache.CachingTableFactory)1 DefaultMessageTableCacheProvider (co.cask.cdap.messaging.store.cache.DefaultMessageTableCacheProvider)1 MessageTableCacheProvider (co.cask.cdap.messaging.store.cache.MessageTableCacheProvider)1 AbstractModule (com.google.inject.AbstractModule)1 PrivateModule (com.google.inject.PrivateModule)1 BeforeClass (org.junit.BeforeClass)1