Search in sources :

Example 1 with DruidGuiceExtensions

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

the class BrokerInternalQueryConfigTest method testDefaultBehavior.

/**
 * Test the behavior if the operator does not specify anything for druid.broker.internal.query.config.context in runtime.properties
 */
@Test
public void testDefaultBehavior() {
    Injector injector = Guice.createInjector(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.install(new ConfigModule());
            binder.install(new DruidGuiceExtensions());
            JsonConfigProvider.bind(binder, "druid.broker.internal.query.config", BrokerInternalQueryConfig.class);
        }

        @Provides
        @LazySingleton
        public ObjectMapper jsonMapper() {
            return new DefaultObjectMapper();
        }
    });
    BrokerInternalQueryConfig config = injector.getInstance(BrokerInternalQueryConfig.class);
    Assert.assertEquals(ImmutableMap.of(), config.getContext());
}
Also used : Binder(com.google.inject.Binder) LazySingleton(org.apache.druid.guice.LazySingleton) DruidGuiceExtensions(org.apache.druid.guice.DruidGuiceExtensions) Injector(com.google.inject.Injector) ConfigModule(org.apache.druid.guice.ConfigModule) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Module(com.google.inject.Module) ConfigModule(org.apache.druid.guice.ConfigModule) Provides(com.google.inject.Provides) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Example 2 with DruidGuiceExtensions

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

the class ComposingEmitterModuleTest method testGetEmitterViaRealGuice.

@Test
public void testGetEmitterViaRealGuice() {
    Injector injector = Guice.createInjector(new DruidGuiceExtensions(), new LifecycleModule(), new Module() {

        @Override
        public void configure(Binder binder) {
            Properties props = new Properties();
            props.put("druid.emitter.composing.emitters", "[\"" + testEmitterType + "\"]");
            binder.bind(Properties.class).toInstance(props);
            binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
            binder.bind(Emitter.class).annotatedWith(Names.named(testEmitterType)).toInstance(emitter);
        }
    }, new ComposingEmitterModule());
    injector.getInstance(Key.get(Emitter.class, Names.named("composing"))).start();
    EasyMock.verify(emitter);
}
Also used : Binder(com.google.inject.Binder) Emitter(org.apache.druid.java.util.emitter.core.Emitter) DruidGuiceExtensions(org.apache.druid.guice.DruidGuiceExtensions) Injector(com.google.inject.Injector) Module(com.google.inject.Module) LifecycleModule(org.apache.druid.guice.LifecycleModule) ComposingEmitterModule(org.apache.druid.server.emitter.ComposingEmitterModule) Properties(java.util.Properties) ComposingEmitterModule(org.apache.druid.server.emitter.ComposingEmitterModule) LifecycleModule(org.apache.druid.guice.LifecycleModule) Test(org.junit.Test)

Example 3 with DruidGuiceExtensions

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

the class SqlModuleTest method makeInjectorWithProperties.

private Injector makeInjectorWithProperties(final Properties props) {
    return Guice.createInjector(ImmutableList.of(new DruidGuiceExtensions(), new LifecycleModule(), new ServerModule(), new JacksonModule(), (Module) binder -> {
        binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
        binder.bind(JsonConfigurator.class).in(LazySingleton.class);
        binder.bind(Properties.class).toInstance(props);
        binder.bind(ExprMacroTable.class).toInstance(ExprMacroTable.nil());
        binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER);
        binder.bind(Escalator.class).toInstance(new NoopEscalator());
        binder.bind(ServiceEmitter.class).toInstance(serviceEmitter);
        binder.bind(RequestLogger.class).toInstance(new NoopRequestLogger());
        binder.bind(new TypeLiteral<Supplier<DefaultQueryConfig>>() {
        }).toInstance(Suppliers.ofInstance(new DefaultQueryConfig(null)));
        binder.bind(FilteredServerInventoryView.class).toInstance(inventoryView);
        binder.bind(TimelineServerView.class).toInstance(timelineServerView);
        binder.bind(DruidLeaderClient.class).annotatedWith(Coordinator.class).toInstance(druidLeaderClient);
        binder.bind(DruidLeaderClient.class).annotatedWith(IndexingService.class).toInstance(druidLeaderClient);
        binder.bind(DruidNodeDiscoveryProvider.class).toInstance(druidNodeDiscoveryProvider);
        binder.bind(GenericQueryMetricsFactory.class).toInstance(genericQueryMetricsFactory);
        binder.bind(QuerySegmentWalker.class).toInstance(querySegmentWalker);
        binder.bind(QueryToolChestWarehouse.class).toInstance(queryToolChestWarehouse);
        binder.bind(LookupExtractorFactoryContainerProvider.class).toInstance(lookupExtractorFactoryContainerProvider);
        binder.bind(JoinableFactory.class).toInstance(joinableFactory);
        binder.bind(SegmentLoader.class).toInstance(segmentLoader);
        binder.bind(QuerySchedulerProvider.class).in(LazySingleton.class);
        binder.bind(QueryScheduler.class).toProvider(QuerySchedulerProvider.class).in(LazySingleton.class);
    }, new SqlModule(props), new TestViewManagerModule()));
}
Also used : ServiceEmitter(org.apache.druid.java.util.emitter.service.ServiceEmitter) DruidGuiceExtensions(org.apache.druid.guice.DruidGuiceExtensions) Properties(java.util.Properties) ExprMacroTable(org.apache.druid.math.expr.ExprMacroTable) JoinableFactory(org.apache.druid.segment.join.JoinableFactory) ServerModule(org.apache.druid.guice.ServerModule) QuerySegmentWalker(org.apache.druid.query.QuerySegmentWalker) NoopEscalator(org.apache.druid.server.security.NoopEscalator) Escalator(org.apache.druid.server.security.Escalator) NoopEscalator(org.apache.druid.server.security.NoopEscalator) TypeLiteral(com.google.inject.TypeLiteral) QuerySchedulerProvider(org.apache.druid.server.QuerySchedulerProvider) IndexingService(org.apache.druid.client.indexing.IndexingService) RequestLogger(org.apache.druid.server.log.RequestLogger) NoopRequestLogger(org.apache.druid.server.log.NoopRequestLogger) JsonConfigurator(org.apache.druid.guice.JsonConfigurator) LookupExtractorFactoryContainerProvider(org.apache.druid.query.lookup.LookupExtractorFactoryContainerProvider) AuthorizerMapper(org.apache.druid.server.security.AuthorizerMapper) DefaultQueryConfig(org.apache.druid.query.DefaultQueryConfig) TimelineServerView(org.apache.druid.client.TimelineServerView) QueryToolChestWarehouse(org.apache.druid.query.QueryToolChestWarehouse) LifecycleModule(org.apache.druid.guice.LifecycleModule) FilteredServerInventoryView(org.apache.druid.client.FilteredServerInventoryView) NoopRequestLogger(org.apache.druid.server.log.NoopRequestLogger) GenericQueryMetricsFactory(org.apache.druid.query.GenericQueryMetricsFactory) Coordinator(org.apache.druid.client.coordinator.Coordinator) JacksonModule(org.apache.druid.jackson.JacksonModule) SegmentLoader(org.apache.druid.segment.loading.SegmentLoader) DruidNodeDiscoveryProvider(org.apache.druid.discovery.DruidNodeDiscoveryProvider) Module(com.google.inject.Module) LifecycleModule(org.apache.druid.guice.LifecycleModule) JacksonModule(org.apache.druid.jackson.JacksonModule) DruidModule(org.apache.druid.initialization.DruidModule) ServerModule(org.apache.druid.guice.ServerModule) Validator(javax.validation.Validator)

Aggregations

Module (com.google.inject.Module)3 DruidGuiceExtensions (org.apache.druid.guice.DruidGuiceExtensions)3 Binder (com.google.inject.Binder)2 Injector (com.google.inject.Injector)2 Properties (java.util.Properties)2 LifecycleModule (org.apache.druid.guice.LifecycleModule)2 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Provides (com.google.inject.Provides)1 TypeLiteral (com.google.inject.TypeLiteral)1 Validator (javax.validation.Validator)1 FilteredServerInventoryView (org.apache.druid.client.FilteredServerInventoryView)1 TimelineServerView (org.apache.druid.client.TimelineServerView)1 Coordinator (org.apache.druid.client.coordinator.Coordinator)1 IndexingService (org.apache.druid.client.indexing.IndexingService)1 DruidNodeDiscoveryProvider (org.apache.druid.discovery.DruidNodeDiscoveryProvider)1 ConfigModule (org.apache.druid.guice.ConfigModule)1 JsonConfigurator (org.apache.druid.guice.JsonConfigurator)1 LazySingleton (org.apache.druid.guice.LazySingleton)1 ServerModule (org.apache.druid.guice.ServerModule)1