Search in sources :

Example 11 with DruidProcessingConfig

use of org.apache.druid.query.DruidProcessingConfig in project druid by druid-io.

the class BrokerProcessingModuleTest method testMemoryCheckThrowsException.

@Test(expected = ProvisionException.class)
public void testMemoryCheckThrowsException() {
    // so this test only validates functionality for Java 8.
    try {
        JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
    } catch (UnsupportedOperationException e) {
        Assume.assumeNoException(e);
    }
    BrokerProcessingModule module = new BrokerProcessingModule();
    module.getMergeBufferPool(new DruidProcessingConfig() {

        @Override
        public String getFormatString() {
            return "test";
        }

        @Override
        public int intermediateComputeSizeBytes() {
            return Integer.MAX_VALUE;
        }
    });
}
Also used : DruidProcessingConfig(org.apache.druid.query.DruidProcessingConfig) Test(org.junit.Test)

Example 12 with DruidProcessingConfig

use of org.apache.druid.query.DruidProcessingConfig in project druid by druid-io.

the class DruidProcessingModuleTest method testMemoryCheckThrowsException.

@Test(expected = ProvisionException.class)
public void testMemoryCheckThrowsException() {
    // so this test only validates functionality for Java 8.
    try {
        JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
    } catch (UnsupportedOperationException e) {
        Assume.assumeNoException(e);
    }
    DruidProcessingModule module = new DruidProcessingModule();
    module.getIntermediateResultsPool(new DruidProcessingConfig() {

        @Override
        public String getFormatString() {
            return "test";
        }

        @Override
        public int intermediateComputeSizeBytes() {
            return Integer.MAX_VALUE;
        }
    });
}
Also used : DruidProcessingConfig(org.apache.druid.query.DruidProcessingConfig) Test(org.junit.Test)

Example 13 with DruidProcessingConfig

use of org.apache.druid.query.DruidProcessingConfig in project druid by druid-io.

the class DruidProcessingModuleTest method testMemoryCheckIsChillByDefaultIfNothingSet.

@Test
public void testMemoryCheckIsChillByDefaultIfNothingSet() {
    DruidProcessingConfig config = new DruidProcessingConfig() {

        @Override
        public String getFormatString() {
            return "processing-test-%s";
        }
    };
    DruidProcessingModule module = new DruidProcessingModule();
    config.getNumInitalBuffersForIntermediatePool();
    module.getIntermediateResultsPool(config);
}
Also used : DruidProcessingConfig(org.apache.druid.query.DruidProcessingConfig) Test(org.junit.Test)

Example 14 with DruidProcessingConfig

use of org.apache.druid.query.DruidProcessingConfig in project druid by druid-io.

the class DefaultOfflineAppenderatorFactoryTest method testBuild.

@Test
public void testBuild() throws IOException, SegmentNotWritableException {
    Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.<Module>of(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/tool");
            binder.bindConstant().annotatedWith(Names.named("servicePort")).to(9999);
            binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
            binder.bind(DruidProcessingConfig.class).toInstance(new DruidProcessingConfig() {

                @Override
                public String getFormatString() {
                    return "processing-%s";
                }

                @Override
                public int intermediateComputeSizeBytes() {
                    return 100 * 1024 * 1024;
                }

                @Override
                public int getNumThreads() {
                    return 1;
                }

                @Override
                public int columnCacheSizeBytes() {
                    return 25 * 1024 * 1024;
                }
            });
            binder.bind(ColumnConfig.class).to(DruidProcessingConfig.class);
        }
    }));
    ObjectMapper objectMapper = injector.getInstance(ObjectMapper.class);
    AppenderatorFactory defaultOfflineAppenderatorFactory = objectMapper.readerFor(AppenderatorFactory.class).readValue("{\"type\":\"offline\"}");
    final Map<String, Object> parserMap = objectMapper.convertValue(new MapInputRowParser(new JSONParseSpec(new TimestampSpec("ts", "auto", null), DimensionsSpec.EMPTY, null, null, null)), Map.class);
    DataSchema schema = new DataSchema("dataSourceName", parserMap, new AggregatorFactory[] { new CountAggregatorFactory("count"), new LongSumAggregatorFactory("met", "met") }, new UniformGranularitySpec(Granularities.MINUTE, Granularities.NONE, null), null, objectMapper);
    RealtimeTuningConfig tuningConfig = new RealtimeTuningConfig(null, 75000, null, null, null, null, temporaryFolder.newFolder(), null, null, null, null, null, null, 0, 0, null, null, null, null, null);
    Appenderator appenderator = defaultOfflineAppenderatorFactory.build(schema, tuningConfig, new FireDepartmentMetrics());
    try {
        Assert.assertEquals("dataSourceName", appenderator.getDataSource());
        Assert.assertEquals(null, appenderator.startJob());
        SegmentIdWithShardSpec identifier = new SegmentIdWithShardSpec("dataSourceName", Intervals.of("2000/2001"), "A", new LinearShardSpec(0));
        Assert.assertEquals(0, ((AppenderatorImpl) appenderator).getRowsInMemory());
        appenderator.add(identifier, StreamAppenderatorTest.ir("2000", "bar", 1), null);
        Assert.assertEquals(1, ((AppenderatorImpl) appenderator).getRowsInMemory());
        appenderator.add(identifier, StreamAppenderatorTest.ir("2000", "baz", 1), null);
        Assert.assertEquals(2, ((AppenderatorImpl) appenderator).getRowsInMemory());
        appenderator.close();
        Assert.assertEquals(0, ((AppenderatorImpl) appenderator).getRowsInMemory());
    } finally {
        appenderator.close();
    }
}
Also used : ColumnConfig(org.apache.druid.segment.column.ColumnConfig) MapInputRowParser(org.apache.druid.data.input.impl.MapInputRowParser) LinearShardSpec(org.apache.druid.timeline.partition.LinearShardSpec) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory) RealtimeTuningConfig(org.apache.druid.segment.indexing.RealtimeTuningConfig) DataSchema(org.apache.druid.segment.indexing.DataSchema) Binder(com.google.inject.Binder) UniformGranularitySpec(org.apache.druid.segment.indexing.granularity.UniformGranularitySpec) FireDepartmentMetrics(org.apache.druid.segment.realtime.FireDepartmentMetrics) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) Injector(com.google.inject.Injector) TimestampSpec(org.apache.druid.data.input.impl.TimestampSpec) Module(com.google.inject.Module) DruidProcessingConfig(org.apache.druid.query.DruidProcessingConfig) JSONParseSpec(org.apache.druid.data.input.impl.JSONParseSpec) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

DruidProcessingConfig (org.apache.druid.query.DruidProcessingConfig)14 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)7 GroupByStrategySelector (org.apache.druid.query.groupby.strategy.GroupByStrategySelector)7 GroupByStrategyV2 (org.apache.druid.query.groupby.strategy.GroupByStrategyV2)7 SmileFactory (com.fasterxml.jackson.dataformat.smile.SmileFactory)6 ByteBuffer (java.nio.ByteBuffer)6 GroupByStrategyV1 (org.apache.druid.query.groupby.strategy.GroupByStrategyV1)6 Test (org.junit.Test)6 StupidPool (org.apache.druid.collections.StupidPool)5 DefaultBlockingPool (org.apache.druid.collections.DefaultBlockingPool)4 GroupByQueryConfig (org.apache.druid.query.groupby.GroupByQueryConfig)4 GroupByQueryQueryToolChest (org.apache.druid.query.groupby.GroupByQueryQueryToolChest)4 GroupByQueryRunnerFactory (org.apache.druid.query.groupby.GroupByQueryRunnerFactory)4 CloseableDefaultBlockingPool (org.apache.druid.collections.CloseableDefaultBlockingPool)3 CloseableStupidPool (org.apache.druid.collections.CloseableStupidPool)3 CachingClusteredClient (org.apache.druid.client.CachingClusteredClient)2 CacheConfig (org.apache.druid.client.cache.CacheConfig)2 CachePopulatorStats (org.apache.druid.client.cache.CachePopulatorStats)2 ForegroundCachePopulator (org.apache.druid.client.cache.ForegroundCachePopulator)2