Search in sources :

Example 1 with GuiceInjectableValues

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

the class LoadSpecTest method setUp.

@BeforeClass
public static void setUp() {
    final Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(LocalDataSegmentPuller.class);
        }
    }));
    mapper = new DefaultObjectMapper();
    mapper.registerModule(new SimpleModule("loadSpecTest").registerSubtypes(LocalLoadSpec.class));
    mapper.setInjectableValues(new GuiceInjectableValues(injector));
    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    mapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, mapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, mapper.getDeserializationConfig().getAnnotationIntrospector()));
}
Also used : AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Module(com.google.inject.Module) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceAnnotationIntrospector(org.apache.druid.guice.GuiceAnnotationIntrospector) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceInjectableValues(org.apache.druid.guice.GuiceInjectableValues) BeforeClass(org.junit.BeforeClass)

Example 2 with GuiceInjectableValues

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

the class DeepStorageShuffleClientTest method setUp.

@Before
public void setUp() throws Exception {
    final Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(binder -> binder.bind(LocalDataSegmentPuller.class)));
    mapper = new DefaultObjectMapper();
    mapper.registerModule(new SimpleModule("loadSpecTest").registerSubtypes(LocalLoadSpec.class));
    mapper.setInjectableValues(new GuiceInjectableValues(injector));
    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    mapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, mapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, mapper.getDeserializationConfig().getAnnotationIntrospector()));
    deepStorageShuffleClient = new DeepStorageShuffleClient(mapper);
    File temp = temporaryFolder.newFile();
    segmentFileName = temp.getName();
    try (Writer writer = Files.newBufferedWriter(temp.toPath(), StandardCharsets.UTF_8)) {
        for (int j = 0; j < 10; j++) {
            writer.write(StringUtils.format("let's write some data.\n"));
        }
    }
    segmentFile = new File(temp.getAbsolutePath() + ".zip");
    CompressionUtils.zip(segmentFile.getParentFile(), segmentFile);
}
Also used : Intervals(org.apache.druid.java.util.common.Intervals) CompressionUtils(org.apache.druid.utils.CompressionUtils) AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ImmutableList(com.google.common.collect.ImmutableList) LocalDataSegmentPuller(org.apache.druid.segment.loading.LocalDataSegmentPuller) Before(org.junit.Before) LocalLoadSpec(org.apache.druid.segment.loading.LocalLoadSpec) ImmutableMap(com.google.common.collect.ImmutableMap) Files(java.nio.file.Files) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StringUtils(org.apache.druid.java.util.common.StringUtils) Test(org.junit.Test) IOException(java.io.IOException) GuiceInjectors(org.apache.druid.guice.GuiceInjectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Injector(com.google.inject.Injector) Rule(org.junit.Rule) GuiceAnnotationIntrospector(org.apache.druid.guice.GuiceAnnotationIntrospector) Writer(java.io.Writer) Assert(org.junit.Assert) GuiceInjectableValues(org.apache.druid.guice.GuiceInjectableValues) TemporaryFolder(org.junit.rules.TemporaryFolder) LocalLoadSpec(org.apache.druid.segment.loading.LocalLoadSpec) AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) Injector(com.google.inject.Injector) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) GuiceAnnotationIntrospector(org.apache.druid.guice.GuiceAnnotationIntrospector) File(java.io.File) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceInjectableValues(org.apache.druid.guice.GuiceInjectableValues) Writer(java.io.Writer) Before(org.junit.Before)

Example 3 with GuiceInjectableValues

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

the class IngestSegmentFirehoseFactoryTest method setupInjectablesInObjectMapper.

public static ObjectMapper setupInjectablesInObjectMapper(ObjectMapper objectMapper) {
    objectMapper.registerModule(new SimpleModule("testModule").registerSubtypes(LocalLoadSpec.class));
    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    objectMapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, objectMapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, objectMapper.getDeserializationConfig().getAnnotationIntrospector()));
    objectMapper.setInjectableValues(new GuiceInjectableValues(GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(LocalDataSegmentPuller.class);
            binder.bind(ExprMacroTable.class).toInstance(TestExprMacroTable.INSTANCE);
        }
    }))));
    return objectMapper;
}
Also used : LocalLoadSpec(org.apache.druid.segment.loading.LocalLoadSpec) AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) Binder(com.google.inject.Binder) Module(com.google.inject.Module) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceAnnotationIntrospector(org.apache.druid.guice.GuiceAnnotationIntrospector) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceInjectableValues(org.apache.druid.guice.GuiceInjectableValues) TestExprMacroTable(org.apache.druid.query.expression.TestExprMacroTable) ExprMacroTable(org.apache.druid.math.expr.ExprMacroTable)

Example 4 with GuiceInjectableValues

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

the class UriExtractionNamespaceTest method registerTypes.

public static ObjectMapper registerTypes(final ObjectMapper mapper) {
    mapper.setInjectableValues(new GuiceInjectableValues(Guice.createInjector(ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(ObjectMapper.class).annotatedWith(Json.class).toInstance(mapper);
            binder.bind(ObjectMapper.class).toInstance(mapper);
        }
    })))).registerSubtypes(UriExtractionNamespace.class, UriExtractionNamespace.FlatDataParser.class);
    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    mapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, mapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, mapper.getDeserializationConfig().getAnnotationIntrospector()));
    return mapper;
}
Also used : AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) Binder(com.google.inject.Binder) Module(com.google.inject.Module) GuiceAnnotationIntrospector(org.apache.druid.guice.GuiceAnnotationIntrospector) GuiceInjectableValues(org.apache.druid.guice.GuiceInjectableValues) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper)

Example 5 with GuiceInjectableValues

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

the class CompactionTaskTest method setupInjectablesInObjectMapper.

private static ObjectMapper setupInjectablesInObjectMapper(ObjectMapper objectMapper) {
    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    objectMapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, objectMapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, objectMapper.getDeserializationConfig().getAnnotationIntrospector()));
    GuiceInjectableValues injectableValues = new GuiceInjectableValues(GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(binder -> {
        binder.bind(AuthorizerMapper.class).toInstance(AuthTestUtils.TEST_AUTHORIZER_MAPPER);
        binder.bind(ChatHandlerProvider.class).toInstance(new NoopChatHandlerProvider());
        binder.bind(RowIngestionMetersFactory.class).toInstance(TEST_UTILS.getRowIngestionMetersFactory());
        binder.bind(CoordinatorClient.class).toInstance(COORDINATOR_CLIENT);
        binder.bind(SegmentCacheManagerFactory.class).toInstance(new SegmentCacheManagerFactory(objectMapper));
        binder.bind(AppenderatorsManager.class).toInstance(new TestAppenderatorsManager());
        binder.bind(IndexingServiceClient.class).toInstance(INDEXING_SERVICE_CLIENT);
    })));
    objectMapper.setInjectableValues(injectableValues);
    objectMapper.registerModule(new SimpleModule().registerSubtypes(new NamedType(NumberedShardSpec.class, "NumberedShardSpec")));
    objectMapper.registerModules(new IndexingServiceTuningConfigModule().getJacksonModules());
    return objectMapper;
}
Also used : AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) NoopIndexingServiceClient(org.apache.druid.client.indexing.NoopIndexingServiceClient) IndexingServiceClient(org.apache.druid.client.indexing.IndexingServiceClient) NoopChatHandlerProvider(org.apache.druid.segment.realtime.firehose.NoopChatHandlerProvider) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) SegmentCacheManagerFactory(org.apache.druid.indexing.common.SegmentCacheManagerFactory) ChatHandlerProvider(org.apache.druid.segment.realtime.firehose.ChatHandlerProvider) NoopChatHandlerProvider(org.apache.druid.segment.realtime.firehose.NoopChatHandlerProvider) IndexingServiceTuningConfigModule(org.apache.druid.guice.IndexingServiceTuningConfigModule) AppenderatorsManager(org.apache.druid.segment.realtime.appenderator.AppenderatorsManager) AuthorizerMapper(org.apache.druid.server.security.AuthorizerMapper) CoordinatorClient(org.apache.druid.client.coordinator.CoordinatorClient) GuiceAnnotationIntrospector(org.apache.druid.guice.GuiceAnnotationIntrospector) GuiceInjectableValues(org.apache.druid.guice.GuiceInjectableValues) RowIngestionMetersFactory(org.apache.druid.segment.incremental.RowIngestionMetersFactory) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule)

Aggregations

AnnotationIntrospectorPair (com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair)7 GuiceAnnotationIntrospector (org.apache.druid.guice.GuiceAnnotationIntrospector)7 GuiceInjectableValues (org.apache.druid.guice.GuiceInjectableValues)7 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)5 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Binder (com.google.inject.Binder)3 Injector (com.google.inject.Injector)3 Module (com.google.inject.Module)3 IndexingServiceClient (org.apache.druid.client.indexing.IndexingServiceClient)3 NoopIndexingServiceClient (org.apache.druid.client.indexing.NoopIndexingServiceClient)3 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)2 ImmutableList (com.google.common.collect.ImmutableList)2 File (java.io.File)2 IOException (java.io.IOException)2 StandardCharsets (java.nio.charset.StandardCharsets)2 CoordinatorClient (org.apache.druid.client.coordinator.CoordinatorClient)2 GuiceInjectors (org.apache.druid.guice.GuiceInjectors)2 SegmentCacheManagerFactory (org.apache.druid.indexing.common.SegmentCacheManagerFactory)2 Intervals (org.apache.druid.java.util.common.Intervals)2