Search in sources :

Example 71 with DefaultObjectMapper

use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.

the class MockMemcachedClient method testMonitor.

@Test
public void testMonitor() throws Exception {
    final MemcachedCache cache = MemcachedCache.create(memcachedCacheConfig);
    final Emitter emitter = EasyMock.createNiceMock(Emitter.class);
    final Collection<Event> events = new ArrayList<>();
    final ServiceEmitter serviceEmitter = new ServiceEmitter("service", "host", emitter) {

        @Override
        public void emit(Event event) {
            events.add(event);
        }
    };
    while (events.isEmpty()) {
        Thread.sleep(memcachedCacheConfig.getTimeout());
        cache.doMonitor(serviceEmitter);
    }
    Assert.assertFalse(events.isEmpty());
    ObjectMapper mapper = new DefaultObjectMapper();
    for (Event event : events) {
        log.debug("Found event `%s`", mapper.writeValueAsString(event.toMap()));
    }
}
Also used : ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) Emitter(com.metamx.emitter.core.Emitter) ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) ArrayList(java.util.ArrayList) Event(com.metamx.emitter.core.Event) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 72 with DefaultObjectMapper

use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.

the class IndexSpecTest method testSerdeUncompressed.

@Test
public void testSerdeUncompressed() throws Exception {
    final ObjectMapper objectMapper = new DefaultObjectMapper();
    final String json = "{ \"dimensionCompression\" : \"uncompressed\" }";
    final IndexSpec spec = objectMapper.readValue(json, IndexSpec.class);
    Assert.assertEquals(CompressedObjectStrategy.CompressionStrategy.UNCOMPRESSED, spec.getDimensionCompression());
    Assert.assertEquals(spec, objectMapper.readValue(objectMapper.writeValueAsBytes(spec), IndexSpec.class));
}
Also used : DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 73 with DefaultObjectMapper

use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.

the class MetadataTest method testSerde.

@Test
public void testSerde() throws Exception {
    ObjectMapper jsonMapper = new DefaultObjectMapper();
    Metadata metadata = new Metadata();
    metadata.put("k", "v");
    AggregatorFactory[] aggregators = new AggregatorFactory[] { new LongSumAggregatorFactory("out", "in") };
    metadata.setAggregators(aggregators);
    metadata.setQueryGranularity(Granularities.ALL);
    metadata.setRollup(Boolean.FALSE);
    Metadata other = jsonMapper.readValue(jsonMapper.writeValueAsString(metadata), Metadata.class);
    Assert.assertEquals(metadata, other);
}
Also used : LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) AggregatorFactory(io.druid.query.aggregation.AggregatorFactory) DoubleMaxAggregatorFactory(io.druid.query.aggregation.DoubleMaxAggregatorFactory) LongMaxAggregatorFactory(io.druid.query.aggregation.LongMaxAggregatorFactory) LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Example 74 with DefaultObjectMapper

use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.

the class AzureDataSegmentPusherTest method before.

@Before
public void before() {
    azureStorage = createMock(AzureStorage.class);
    azureAccountConfig = new AzureAccountConfig();
    azureAccountConfig.setAccount("account");
    azureAccountConfig.setContainer("container");
    jsonMapper = new DefaultObjectMapper();
}
Also used : DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Before(org.junit.Before)

Example 75 with DefaultObjectMapper

use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.

the class HadoopDruidConverterConfigTest method simpleSerDe.

@Test
public void simpleSerDe() throws IOException {
    final HadoopDruidConverterConfig config = new HadoopDruidConverterConfig("datasource", Interval.parse("2000/2010"), new IndexSpec(), ImmutableList.<DataSegment>of(), true, URI.create("file:/dev/null"), ImmutableMap.<String, String>of(), "HIGH", temporaryFolder.newFolder().getAbsolutePath());
    final ObjectMapper mapper = new DefaultObjectMapper();
    mapper.registerSubtypes(HadoopDruidConverterConfig.class);
    final byte[] value = mapper.writeValueAsBytes(config);
    final HadoopDruidConverterConfig config2 = mapper.readValue(value, HadoopDruidConverterConfig.class);
    Assert.assertEquals(mapper.writeValueAsString(config), mapper.writeValueAsString(config2));
}
Also used : IndexSpec(io.druid.segment.IndexSpec) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Aggregations

DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)164 Test (org.junit.Test)133 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)112 Interval (org.joda.time.Interval)24 DateTime (org.joda.time.DateTime)17 DataSegment (io.druid.timeline.DataSegment)16 File (java.io.File)16 AggregatorFactory (io.druid.query.aggregation.AggregatorFactory)14 Before (org.junit.Before)13 Map (java.util.Map)11 Period (org.joda.time.Period)11 Query (io.druid.query.Query)9 Result (io.druid.query.Result)9 CountAggregatorFactory (io.druid.query.aggregation.CountAggregatorFactory)9 IOException (java.io.IOException)9 DataSchema (io.druid.segment.indexing.DataSchema)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 Sequence (io.druid.java.util.common.guava.Sequence)7 UniformGranularitySpec (io.druid.segment.indexing.granularity.UniformGranularitySpec)7 List (java.util.List)7