Search in sources :

Example 1 with DruidModule

use of org.apache.druid.initialization.DruidModule in project druid by druid-io.

the class LookupSerdeModuleTest method setUp.

@Before
public void setUp() {
    final ImmutableList<DruidModule> modules = ImmutableList.of(new ExpressionModule(), new LookupSerdeModule());
    injector = GuiceInjectors.makeStartupInjectorWithModules(modules);
    objectMapper = injector.getInstance(Key.get(ObjectMapper.class, Json.class));
    objectMapper.setInjectableValues(new InjectableValues.Std().addValue(ExprMacroTable.class, injector.getInstance(ExprMacroTable.class)).addValue(LookupExtractorFactoryContainerProvider.class, injector.getInstance(LookupExtractorFactoryContainerProvider.class)));
    modules.stream().flatMap(module -> module.getJacksonModules().stream()).forEach(objectMapper::registerModule);
}
Also used : ExpressionModule(org.apache.druid.guice.ExpressionModule) InjectableValues(com.fasterxml.jackson.databind.InjectableValues) VirtualColumn(org.apache.druid.segment.VirtualColumn) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Key(com.google.inject.Key) Test(org.junit.Test) Json(org.apache.druid.guice.annotations.Json) GuiceInjectors(org.apache.druid.guice.GuiceInjectors) Injector(com.google.inject.Injector) ExprMacroTable(org.apache.druid.math.expr.ExprMacroTable) ImmutableList(com.google.common.collect.ImmutableList) DimFilter(org.apache.druid.query.filter.DimFilter) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) DimensionSpec(org.apache.druid.query.dimension.DimensionSpec) ColumnType(org.apache.druid.segment.column.ColumnType) ExpressionTransform(org.apache.druid.segment.transform.ExpressionTransform) Assert(org.junit.Assert) ExtractionDimensionSpec(org.apache.druid.query.dimension.ExtractionDimensionSpec) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) DruidModule(org.apache.druid.initialization.DruidModule) Before(org.junit.Before) ExpressionModule(org.apache.druid.guice.ExpressionModule) DruidModule(org.apache.druid.initialization.DruidModule) InjectableValues(com.fasterxml.jackson.databind.InjectableValues) ExprMacroTable(org.apache.druid.math.expr.ExprMacroTable) Before(org.junit.Before)

Example 2 with DruidModule

use of org.apache.druid.initialization.DruidModule in project druid by druid-io.

the class S3InputSourceTest method createS3ObjectMapper.

public static ObjectMapper createS3ObjectMapper() {
    DruidModule baseModule = new TestS3Module();
    final Injector injector = Guice.createInjector(new ObjectMapperModule(), baseModule, new DruidModule() {

        @Provides
        public AWSCredentialsProvider getAWSCredentialsProvider() {
            return AWSCredentialsUtils.defaultAWSCredentialsProviderChain(null);
        }

        @Override
        public List<? extends Module> getJacksonModules() {
            return Collections.emptyList();
        }

        @Override
        public void configure(Binder binder) {
        }
    });
    final ObjectMapper baseMapper = injector.getInstance(ObjectMapper.class);
    baseModule.getJacksonModules().forEach(baseMapper::registerModule);
    return baseMapper;
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) DruidModule(org.apache.druid.initialization.DruidModule) Provides(com.google.inject.Provides) Module(com.fasterxml.jackson.databind.Module) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) DruidModule(org.apache.druid.initialization.DruidModule) ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with DruidModule

use of org.apache.druid.initialization.DruidModule in project druid by druid-io.

the class OssInputSourceTest method createObjectMapper.

public static ObjectMapper createObjectMapper() {
    DruidModule baseModule = new TestOssModule();
    final Injector injector = Guice.createInjector(new ObjectMapperModule(), baseModule);
    final ObjectMapper baseMapper = injector.getInstance(ObjectMapper.class);
    baseModule.getJacksonModules().forEach(baseMapper::registerModule);
    return baseMapper;
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) Injector(com.google.inject.Injector) DruidModule(org.apache.druid.initialization.DruidModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with DruidModule

use of org.apache.druid.initialization.DruidModule in project druid by druid-io.

the class GoogleCloudStorageInputSourceTest method createGoogleObjectMapper.

public static ObjectMapper createGoogleObjectMapper() {
    final DruidModule baseModule = new TestGoogleModule();
    final ObjectMapper baseMapper = new DefaultObjectMapper();
    baseModule.getJacksonModules().forEach(baseMapper::registerModule);
    final Injector injector = Guice.createInjector(new ObjectMapperModule(), baseModule);
    return injector.getInstance(ObjectMapper.class);
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) Injector(com.google.inject.Injector) DruidModule(org.apache.druid.initialization.DruidModule) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper)

Example 5 with DruidModule

use of org.apache.druid.initialization.DruidModule in project druid by druid-io.

the class KinesisIndexTaskSerdeTest method createObjectMapper.

private static ObjectMapper createObjectMapper() {
    DruidModule module = new KinesisIndexingServiceModule();
    Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), Arrays.asList(module, (Module) binder -> {
        binder.bindConstant().annotatedWith(Names.named("serviceName")).to("test");
        binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8000);
        binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(9000);
        binder.bind(ChatHandlerProvider.class).toInstance(new NoopChatHandlerProvider());
        binder.bind(RowIngestionMetersFactory.class).toInstance(new DropwizardRowIngestionMetersFactory());
        binder.bind(AppenderatorsManager.class).toInstance(new TestAppenderatorsManager());
    }));
    ObjectMapper objectMapper = injector.getInstance(ObjectMapper.class);
    module.getJacksonModules().forEach(objectMapper::registerModule);
    return objectMapper;
}
Also used : Injector(com.google.inject.Injector) NoopChatHandlerProvider(org.apache.druid.segment.realtime.firehose.NoopChatHandlerProvider) TestAppenderatorsManager(org.apache.druid.indexing.common.task.TestAppenderatorsManager) AppenderatorsManager(org.apache.druid.segment.realtime.appenderator.AppenderatorsManager) DruidModule(org.apache.druid.initialization.DruidModule) Module(com.google.inject.Module) DruidModule(org.apache.druid.initialization.DruidModule) ChatHandlerProvider(org.apache.druid.segment.realtime.firehose.ChatHandlerProvider) NoopChatHandlerProvider(org.apache.druid.segment.realtime.firehose.NoopChatHandlerProvider) DropwizardRowIngestionMetersFactory(org.apache.druid.indexing.common.stats.DropwizardRowIngestionMetersFactory) RowIngestionMetersFactory(org.apache.druid.segment.incremental.RowIngestionMetersFactory) TestAppenderatorsManager(org.apache.druid.indexing.common.task.TestAppenderatorsManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DropwizardRowIngestionMetersFactory(org.apache.druid.indexing.common.stats.DropwizardRowIngestionMetersFactory)

Aggregations

DruidModule (org.apache.druid.initialization.DruidModule)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Injector (com.google.inject.Injector)5 ObjectMapperModule (com.fasterxml.jackson.module.guice.ObjectMapperModule)3 ImmutableList (com.google.common.collect.ImmutableList)2 Test (org.junit.Test)2 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 InjectableValues (com.fasterxml.jackson.databind.InjectableValues)1 Module (com.fasterxml.jackson.databind.Module)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 Binder (com.google.inject.Binder)1 Key (com.google.inject.Key)1 Module (com.google.inject.Module)1 Provides (com.google.inject.Provides)1 List (java.util.List)1 ExpressionModule (org.apache.druid.guice.ExpressionModule)1 GuiceInjectors (org.apache.druid.guice.GuiceInjectors)1 Json (org.apache.druid.guice.annotations.Json)1 DropwizardRowIngestionMetersFactory (org.apache.druid.indexing.common.stats.DropwizardRowIngestionMetersFactory)1 TestAppenderatorsManager (org.apache.druid.indexing.common.task.TestAppenderatorsManager)1