Search in sources :

Example 1 with CacheModule

use of org.apache.druid.guice.CacheModule in project druid by druid-io.

the class SamplerModule method configure.

@Override
public void configure(Binder binder) {
    Jerseys.addResource(binder, SamplerResource.class);
    binder.install(new CacheModule());
    binder.bind(InputSourceSampler.class).in(Singleton.class);
    binder.bind(SamplerExceptionMapper.class).in(Singleton.class);
}
Also used : CacheModule(org.apache.druid.guice.CacheModule)

Example 2 with CacheModule

use of org.apache.druid.guice.CacheModule in project druid by druid-io.

the class CliBroker method getModules.

@Override
protected List<? extends Module> getModules() {
    return ImmutableList.of(new BrokerProcessingModule(), new QueryableModule(), new QueryRunnerFactoryModule(), new SegmentWranglerModule(), new JoinableFactoryModule(), new BrokerServiceModule(), binder -> {
        binder.bindConstant().annotatedWith(Names.named("serviceName")).to(TieredBrokerConfig.DEFAULT_BROKER_SERVICE_NAME);
        binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8082);
        binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(8282);
        binder.bindConstant().annotatedWith(PruneLoadSpec.class).to(true);
        binder.bind(ResponseContextConfig.class).toInstance(ResponseContextConfig.newConfig(false));
        binder.bind(CachingClusteredClient.class).in(LazySingleton.class);
        LifecycleModule.register(binder, BrokerServerView.class);
        binder.bind(TimelineServerView.class).to(BrokerServerView.class).in(LazySingleton.class);
        JsonConfigProvider.bind(binder, "druid.broker.cache", CacheConfig.class);
        binder.install(new CacheModule());
        JsonConfigProvider.bind(binder, "druid.broker.select", TierSelectorStrategy.class);
        JsonConfigProvider.bind(binder, "druid.broker.select.tier.custom", CustomTierSelectorStrategyConfig.class);
        JsonConfigProvider.bind(binder, "druid.broker.balancer", ServerSelectorStrategy.class);
        JsonConfigProvider.bind(binder, "druid.broker.retryPolicy", RetryQueryRunnerConfig.class);
        JsonConfigProvider.bind(binder, "druid.broker.segment", BrokerSegmentWatcherConfig.class);
        JsonConfigProvider.bind(binder, "druid.broker.internal.query.config", BrokerInternalQueryConfig.class);
        binder.bind(QuerySegmentWalker.class).to(ClientQuerySegmentWalker.class).in(LazySingleton.class);
        binder.bind(JettyServerInitializer.class).to(QueryJettyServerInitializer.class).in(LazySingleton.class);
        binder.bind(BrokerQueryResource.class).in(LazySingleton.class);
        Jerseys.addResource(binder, BrokerQueryResource.class);
        binder.bind(QueryCountStatsProvider.class).to(BrokerQueryResource.class).in(LazySingleton.class);
        Jerseys.addResource(binder, BrokerResource.class);
        Jerseys.addResource(binder, ClientInfoResource.class);
        LifecycleModule.register(binder, BrokerQueryResource.class);
        Jerseys.addResource(binder, HttpServerInventoryViewResource.class);
        LifecycleModule.register(binder, Server.class);
        binder.bind(SegmentManager.class).in(LazySingleton.class);
        binder.bind(ZkCoordinator.class).in(ManageLifecycle.class);
        binder.bind(ServerTypeConfig.class).toInstance(new ServerTypeConfig(ServerType.BROKER));
        Jerseys.addResource(binder, HistoricalResource.class);
        Jerseys.addResource(binder, SegmentListerResource.class);
        if (isZkEnabled) {
            LifecycleModule.register(binder, ZkCoordinator.class);
        }
        bindAnnouncer(binder, DiscoverySideEffectsProvider.withLegacyAnnouncer());
        Jerseys.addResource(binder, SelfDiscoveryResource.class);
        LifecycleModule.registerKey(binder, Key.get(SelfDiscoveryResource.class));
    }, new LookupModule(), new SqlModule());
}
Also used : CachingClusteredClient(org.apache.druid.client.CachingClusteredClient) SegmentManager(org.apache.druid.server.SegmentManager) SegmentWranglerModule(org.apache.druid.guice.SegmentWranglerModule) BrokerServerView(org.apache.druid.client.BrokerServerView) SelfDiscoveryResource(org.apache.druid.server.http.SelfDiscoveryResource) QueryRunnerFactoryModule(org.apache.druid.guice.QueryRunnerFactoryModule) CacheModule(org.apache.druid.guice.CacheModule) LookupModule(org.apache.druid.query.lookup.LookupModule) ResponseContextConfig(org.apache.druid.server.ResponseContextConfig) BrokerServiceModule(org.apache.druid.guice.BrokerServiceModule) ZkCoordinator(org.apache.druid.server.coordination.ZkCoordinator) QueryableModule(org.apache.druid.guice.QueryableModule) PruneLoadSpec(org.apache.druid.timeline.PruneLoadSpec) BrokerQueryResource(org.apache.druid.server.BrokerQueryResource) JoinableFactoryModule(org.apache.druid.guice.JoinableFactoryModule) ClientQuerySegmentWalker(org.apache.druid.server.ClientQuerySegmentWalker) BrokerProcessingModule(org.apache.druid.guice.BrokerProcessingModule) SqlModule(org.apache.druid.sql.guice.SqlModule) ServerTypeConfig(org.apache.druid.guice.ServerTypeConfig)

Example 3 with CacheModule

use of org.apache.druid.guice.CacheModule in project druid by druid-io.

the class CliHistorical method getModules.

@Override
protected List<? extends Module> getModules() {
    return ImmutableList.of(new DruidProcessingModule(), new QueryableModule(), new QueryRunnerFactoryModule(), new JoinableFactoryModule(), new HistoricalServiceModule(), binder -> {
        binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/historical");
        binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8083);
        binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(8283);
        binder.bindConstant().annotatedWith(PruneLastCompactionState.class).to(true);
        binder.bind(ResponseContextConfig.class).toInstance(ResponseContextConfig.newConfig(true));
        // register Server before binding ZkCoordinator to ensure HTTP endpoints are available immediately
        LifecycleModule.register(binder, Server.class);
        binder.bind(ServerManager.class).in(LazySingleton.class);
        binder.bind(SegmentManager.class).in(LazySingleton.class);
        binder.bind(ZkCoordinator.class).in(ManageLifecycle.class);
        bindQuerySegmentWalker(binder);
        binder.bind(ServerTypeConfig.class).toInstance(new ServerTypeConfig(ServerType.HISTORICAL));
        binder.bind(JettyServerInitializer.class).to(QueryJettyServerInitializer.class).in(LazySingleton.class);
        binder.bind(QueryCountStatsProvider.class).to(QueryResource.class);
        Jerseys.addResource(binder, QueryResource.class);
        Jerseys.addResource(binder, SegmentListerResource.class);
        Jerseys.addResource(binder, HistoricalResource.class);
        LifecycleModule.register(binder, QueryResource.class);
        if (isZkEnabled) {
            LifecycleModule.register(binder, ZkCoordinator.class);
        }
        JsonConfigProvider.bind(binder, "druid.historical.cache", CacheConfig.class);
        binder.install(new CacheModule());
        bindAnnouncer(binder, DiscoverySideEffectsProvider.create());
        Jerseys.addResource(binder, SelfDiscoveryResource.class);
        LifecycleModule.registerKey(binder, Key.get(SelfDiscoveryResource.class));
    }, new LookupModule());
}
Also used : ServerManager(org.apache.druid.server.coordination.ServerManager) SegmentManager(org.apache.druid.server.SegmentManager) QueryCountStatsProvider(org.apache.druid.server.metrics.QueryCountStatsProvider) SelfDiscoveryResource(org.apache.druid.server.http.SelfDiscoveryResource) QueryRunnerFactoryModule(org.apache.druid.guice.QueryRunnerFactoryModule) CacheModule(org.apache.druid.guice.CacheModule) LookupModule(org.apache.druid.query.lookup.LookupModule) ResponseContextConfig(org.apache.druid.server.ResponseContextConfig) HistoricalServiceModule(org.apache.druid.guice.HistoricalServiceModule) PruneLastCompactionState(org.apache.druid.timeline.PruneLastCompactionState) ZkCoordinator(org.apache.druid.server.coordination.ZkCoordinator) QueryableModule(org.apache.druid.guice.QueryableModule) DruidProcessingModule(org.apache.druid.guice.DruidProcessingModule) JoinableFactoryModule(org.apache.druid.guice.JoinableFactoryModule) ServerTypeConfig(org.apache.druid.guice.ServerTypeConfig)

Example 4 with CacheModule

use of org.apache.druid.guice.CacheModule in project druid by druid-io.

the class CliPeon method bindRealtimeCache.

static void bindRealtimeCache(Binder binder) {
    JsonConfigProvider.bind(binder, "druid.realtime.cache", CacheConfig.class);
    binder.install(new CacheModule());
}
Also used : CacheModule(org.apache.druid.guice.CacheModule)

Example 5 with CacheModule

use of org.apache.druid.guice.CacheModule in project druid by druid-io.

the class HybridCacheTest method testInjection.

@Test
public void testInjection() {
    final String prefix = "testInjectHybridCache";
    System.setProperty(prefix + ".type", "hybrid");
    System.setProperty(prefix + ".l1.type", "local");
    System.setProperty(prefix + ".l2.type", "memcached");
    System.setProperty(prefix + ".useL2", "false");
    System.setProperty(prefix + ".l2.hosts", "localhost:11711");
    final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.<Module>of(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bindConstant().annotatedWith(Names.named("serviceName")).to("hybridTest");
            binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
            binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
            binder.install(new CacheModule(prefix));
        }
    }));
    final CacheProvider cacheProvider = injector.getInstance(Key.get(CacheProvider.class, Global.class));
    Assert.assertNotNull(cacheProvider);
    Assert.assertEquals(HybridCacheProvider.class, cacheProvider.getClass());
    final Cache cache = cacheProvider.get();
    Assert.assertNotNull(cache);
    Assert.assertFalse(cache.isLocal());
    Assert.assertFalse(((HybridCacheProvider) cacheProvider).getUseL2());
    Assert.assertTrue(((HybridCacheProvider) cacheProvider).getPopulateL2());
    Assert.assertEquals(LocalCacheProvider.class, ((HybridCacheProvider) cacheProvider).level1.getClass());
    Assert.assertEquals(MemcachedCacheProvider.class, ((HybridCacheProvider) cacheProvider).level2.getClass());
}
Also used : Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) CacheModule(org.apache.druid.guice.CacheModule) Module(com.google.inject.Module) CacheModule(org.apache.druid.guice.CacheModule) Global(org.apache.druid.guice.annotations.Global) Test(org.junit.Test)

Aggregations

CacheModule (org.apache.druid.guice.CacheModule)5 JoinableFactoryModule (org.apache.druid.guice.JoinableFactoryModule)2 QueryRunnerFactoryModule (org.apache.druid.guice.QueryRunnerFactoryModule)2 QueryableModule (org.apache.druid.guice.QueryableModule)2 ServerTypeConfig (org.apache.druid.guice.ServerTypeConfig)2 LookupModule (org.apache.druid.query.lookup.LookupModule)2 ResponseContextConfig (org.apache.druid.server.ResponseContextConfig)2 SegmentManager (org.apache.druid.server.SegmentManager)2 ZkCoordinator (org.apache.druid.server.coordination.ZkCoordinator)2 SelfDiscoveryResource (org.apache.druid.server.http.SelfDiscoveryResource)2 Binder (com.google.inject.Binder)1 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 BrokerServerView (org.apache.druid.client.BrokerServerView)1 CachingClusteredClient (org.apache.druid.client.CachingClusteredClient)1 BrokerProcessingModule (org.apache.druid.guice.BrokerProcessingModule)1 BrokerServiceModule (org.apache.druid.guice.BrokerServiceModule)1 DruidProcessingModule (org.apache.druid.guice.DruidProcessingModule)1 HistoricalServiceModule (org.apache.druid.guice.HistoricalServiceModule)1 SegmentWranglerModule (org.apache.druid.guice.SegmentWranglerModule)1