Search in sources :

Example 16 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class StatsDEmitterTest method testConvertRange.

@Test
public void testConvertRange() {
    StatsDClient client = createMock(StatsDClient.class);
    StatsDEmitter emitter = new StatsDEmitter(new StatsDEmitterConfig("localhost", 8888, null, null, null, null), new ObjectMapper(), client);
    client.gauge("broker.query.cache.total.hitRate", 54);
    replay(client);
    emitter.emit(new ServiceMetricEvent.Builder().setDimension("dataSource", "data-source").build(new DateTime(), "query/cache/total/hitRate", 0.54).build("broker", "brokerHost1"));
    verify(client);
}
Also used : StatsDClient(com.timgroup.statsd.StatsDClient) StatsDEmitter(io.druid.emitter.statsd.StatsDEmitter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DateTime(org.joda.time.DateTime) StatsDEmitterConfig(io.druid.emitter.statsd.StatsDEmitterConfig) Test(org.junit.Test)

Example 17 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class StatsDEmitterTest method testConfigOptions.

@Test
public void testConfigOptions() {
    StatsDClient client = createMock(StatsDClient.class);
    StatsDEmitter emitter = new StatsDEmitter(new StatsDEmitterConfig("localhost", 8888, null, "#", true, null), new ObjectMapper(), client);
    client.time("brokerHost1#broker#query#time#data-source#groupBy", 10);
    replay(client);
    emitter.emit(new ServiceMetricEvent.Builder().setDimension("dataSource", "data-source").setDimension("type", "groupBy").setDimension("interval", "2013/2015").setDimension("some_random_dim1", "random_dim_value1").setDimension("some_random_dim2", "random_dim_value2").setDimension("hasFilters", "no").setDimension("duration", "P1D").setDimension("remoteAddress", "194.0.90.2").setDimension("id", "ID").setDimension("context", "{context}").build(new DateTime(), "query/time", 10).build("broker", "brokerHost1"));
    verify(client);
}
Also used : StatsDClient(com.timgroup.statsd.StatsDClient) StatsDEmitter(io.druid.emitter.statsd.StatsDEmitter) ServiceMetricEvent(com.metamx.emitter.service.ServiceMetricEvent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DateTime(org.joda.time.DateTime) StatsDEmitterConfig(io.druid.emitter.statsd.StatsDEmitterConfig) Test(org.junit.Test)

Example 18 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class IncrementalIndexStorageAdapterTest method testFilterByNull.

@Test
public void testFilterByNull() throws Exception {
    IncrementalIndex index = indexCreator.createIndex();
    index.add(new MapBasedInputRow(new DateTime().minus(1).getMillis(), Lists.newArrayList("billy"), ImmutableMap.<String, Object>of("billy", "hi")));
    index.add(new MapBasedInputRow(new DateTime().minus(1).getMillis(), Lists.newArrayList("sally"), ImmutableMap.<String, Object>of("sally", "bo")));
    GroupByQueryEngine engine = makeGroupByQueryEngine();
    final Sequence<Row> rows = engine.process(GroupByQuery.builder().setDataSource("test").setGranularity(Granularities.ALL).setInterval(new Interval(0, new DateTime().getMillis())).addDimension("billy").addDimension("sally").addAggregator(new LongSumAggregatorFactory("cnt", "cnt")).setDimFilter(DimFilters.dimEquals("sally", (String) null)).build(), new IncrementalIndexStorageAdapter(index));
    final ArrayList<Row> results = Sequences.toList(rows, Lists.<Row>newArrayList());
    Assert.assertEquals(1, results.size());
    MapBasedRow row = (MapBasedRow) results.get(0);
    Assert.assertEquals(ImmutableMap.of("billy", "hi", "cnt", 1L), row.getEvent());
}
Also used : LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) DateTime(org.joda.time.DateTime) MapBasedRow(io.druid.data.input.MapBasedRow) MapBasedInputRow(io.druid.data.input.MapBasedInputRow) MapBasedInputRow(io.druid.data.input.MapBasedInputRow) Row(io.druid.data.input.Row) MapBasedRow(io.druid.data.input.MapBasedRow) GroupByQueryEngine(io.druid.query.groupby.GroupByQueryEngine) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 19 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class IncrementalIndexStorageAdapterTest method testSingleValueTopN.

@Test
public void testSingleValueTopN() throws IOException {
    IncrementalIndex index = indexCreator.createIndex();
    DateTime t = DateTime.now();
    index.add(new MapBasedInputRow(t.minus(1).getMillis(), Lists.newArrayList("sally"), ImmutableMap.<String, Object>of("sally", "bo")));
    TopNQueryEngine engine = new TopNQueryEngine(new StupidPool<ByteBuffer>("TopNQueryEngine-bufferPool", new Supplier<ByteBuffer>() {

        @Override
        public ByteBuffer get() {
            return ByteBuffer.allocate(50000);
        }
    }));
    final Iterable<Result<TopNResultValue>> results = Sequences.toList(engine.query(new TopNQueryBuilder().dataSource("test").granularity(Granularities.ALL).intervals(Lists.newArrayList(new Interval(0, new DateTime().getMillis()))).dimension("sally").metric("cnt").threshold(10).aggregators(Lists.<AggregatorFactory>newArrayList(new LongSumAggregatorFactory("cnt", "cnt"))).build(), new IncrementalIndexStorageAdapter(index)), Lists.<Result<TopNResultValue>>newLinkedList());
    Assert.assertEquals(1, Iterables.size(results));
    Assert.assertEquals(1, results.iterator().next().getValue().getValue().size());
}
Also used : TopNQueryBuilder(io.druid.query.topn.TopNQueryBuilder) TopNResultValue(io.druid.query.topn.TopNResultValue) LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) AggregatorFactory(io.druid.query.aggregation.AggregatorFactory) CountAggregatorFactory(io.druid.query.aggregation.CountAggregatorFactory) JavaScriptAggregatorFactory(io.druid.query.aggregation.JavaScriptAggregatorFactory) LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) ByteBuffer(java.nio.ByteBuffer) DateTime(org.joda.time.DateTime) TopNQueryEngine(io.druid.query.topn.TopNQueryEngine) Result(io.druid.query.Result) Supplier(com.google.common.base.Supplier) MapBasedInputRow(io.druid.data.input.MapBasedInputRow) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 20 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class IncrementalIndexTest method controlTest.

@Test
public void controlTest() throws IndexSizeExceededException {
    IncrementalIndex index = closer.closeLater(indexCreator.createIndex());
    index.add(new MapBasedInputRow(new DateTime().minus(1).getMillis(), Lists.newArrayList("billy", "joe"), ImmutableMap.<String, Object>of("billy", "A", "joe", "B")));
    index.add(new MapBasedInputRow(new DateTime().minus(1).getMillis(), Lists.newArrayList("billy", "joe"), ImmutableMap.<String, Object>of("billy", "C", "joe", "B")));
    index.add(new MapBasedInputRow(new DateTime().minus(1).getMillis(), Lists.newArrayList("billy", "joe"), ImmutableMap.<String, Object>of("billy", "A", "joe", "B")));
}
Also used : MapBasedInputRow(io.druid.data.input.MapBasedInputRow) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

DateTime (org.joda.time.DateTime)3381 Test (org.junit.Test)1000 Test (org.testng.annotations.Test)499 DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)349 ResponseBody (okhttp3.ResponseBody)332 ArrayList (java.util.ArrayList)299 LocalDate (org.joda.time.LocalDate)256 Date (java.util.Date)239 Interval (org.joda.time.Interval)200 Result (io.druid.query.Result)153 ServiceCall (com.microsoft.rest.ServiceCall)148 HashMap (java.util.HashMap)144 BigDecimal (java.math.BigDecimal)132 List (java.util.List)131 DateTimeZone (org.joda.time.DateTimeZone)127 LocalDateTime (org.joda.time.LocalDateTime)98 UUID (java.util.UUID)93 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)88 IOException (java.io.IOException)85 Map (java.util.Map)85