Examples of DefaultObjectMapper


Examples of com.netflix.suro.jackson.DefaultObjectMapper

        CountResponse response = node.client().prepareCount(index).execute().actionGet();
        assertEquals(response.getCount(), 100);
    }

    private ElasticSearchSink createDefaultESSink(String index) throws JsonProcessingException {
        ObjectMapper jsonMapper = new DefaultObjectMapper();
        ElasticSearchSink sink = new ElasticSearchSink(
                null,
                10,
                1000,
                null,
                true,
                "1s",
                "1s",
                null,
                null,
                0,0,0,0,false,null,
                null,
                jsonMapper,
                node.client()
        );
        sink.open();

        DateTime dt = new DateTime("2014-10-12T12:12:12.000Z");

        Map<String, Object> msg = new ImmutableMap.Builder<String, Object>()
                .put("f1", "v1")
                .put("f2", "v2")
                .put("f3", "v3")
                .put("ts", dt.getMillis())
                .build();

        for (int i = 0; i < 100; ++i) {
            sink.writeTo(new DefaultMessageContainer(new Message(index, jsonMapper.writeValueAsBytes(msg)), jsonMapper));
        }
        sink.close();
        return sink;
    }
View Full Code Here

Examples of com.netflix.suro.jackson.DefaultObjectMapper

        return sink;
    }

    @Test
    public void testIndexInfoBuilder() throws IOException {
        ObjectMapper jsonMapper = new DefaultObjectMapper();
        Properties props = new Properties();
        props.setProperty("dateFormat", "YYYYMMdd");
        ElasticSearchSink sink = new ElasticSearchSink(
                null,
                1,
                1000,
                null,
                true,
                "1s",
                "1s",
                null,
                new DefaultIndexInfoBuilder(
                        null,
                        null,
                        new TimestampField("ts", null),
                        new IndexSuffixFormatter("date", props),
                        null,
                        jsonMapper),
                0,0,0,0,false,null,
                null,
                jsonMapper,
                node.client()
        );
        sink.open();

        DateTime dt = new DateTime("2014-10-12T12:12:12.000Z");

        Map<String, Object> msg = new ImmutableMap.Builder<String, Object>()
                .put("f1", "v1")
                .put("f2", "v2")
                .put("f3", "v3")
                .put("ts", dt.getMillis())
                .build();

        String routingKey = "topic";
        String index = "topic20141012";
        for (int i = 0; i < 100; ++i) {
            sink.writeTo(new DefaultMessageContainer(new Message(routingKey, jsonMapper.writeValueAsBytes(msg)), jsonMapper));
        }
        sink.close();

        node.client().admin().indices().prepareRefresh(index).execute().actionGet();
        CountResponse response = node.client().prepareCount(index).execute().actionGet();
View Full Code Here

Examples of com.netflix.suro.jackson.DefaultObjectMapper

                "            \"idFields\":{\"index\":[\"f1\", \"f2\"]},\n" +
                "            \"timestamp\": {\"field\":\"ts\"},\n" +
                "            \"indexSuffixFormatter\":{\"type\": \"date\", \"properties\":{\"dateFormat\":\"YYYYMMdd\"}}\n" +
                "        }\n" +
                "    }";
        final ObjectMapper jsonMapper = new DefaultObjectMapper();
        jsonMapper.registerSubtypes(new NamedType(ElasticSearchSink.class, "elasticsearch"));
        jsonMapper.setInjectableValues(new InjectableValues() {
            @Override
            public Object findInjectableValue(
                    Object valueId,
                    DeserializationContext ctxt,
                    BeanProperty forProperty,
                    Object beanInstance
            ) {
                if (valueId.equals(ObjectMapper.class.getCanonicalName())) {
                    return jsonMapper;
                } else {
                    return null;
                }
            }
        });

        Sink esSink = jsonMapper.readValue(desc, new TypeReference<Sink>(){});
        assertTrue(esSink instanceof ElasticSearchSink);
    }
View Full Code Here

Examples of com.netflix.suro.jackson.DefaultObjectMapper

        assertTrue(esSink instanceof ElasticSearchSink);
    }

    @Test
    public void testRecover() throws JsonProcessingException {
        ObjectMapper jsonMapper = new DefaultObjectMapper();
        ElasticSearchSink sink = new ElasticSearchSink(
                null,
                10,
                1000,
                null,
                true,
                "1s",
                "1s",
                null,
                null,
                0,0,0,0,false,null,
                null,
                jsonMapper,
                node.client()
        );

        DateTime dt = new DateTime("2014-10-12T12:12:12.000Z");

        Map<String, Object> msg = new ImmutableMap.Builder<String, Object>()
                .put("f1", "v1")
                .put("f2", "v2")
                .put("f3", "v3")
                .put("ts", dt.getMillis())
                .build();
        String routingKey = "topicrecover";
        String index = "topicrecover";
        List<Message> msgList = new ArrayList<Message>();
        int msgCount = 100;
        for (int i = 0; i < msgCount; ++i) {
            msgList.add(new Message(routingKey, jsonMapper.writeValueAsBytes(msg)));
        }

        BulkRequest request = sink.createBulkRequest(msgList);
        for (int i = 0; i < msgCount; ++i) {
            sink.recover(i, request);
View Full Code Here

Examples of com.netflix.suro.jackson.DefaultObjectMapper

        TopicCommand.createTopic(zk.getZkClient(),
                new TopicCommand.TopicCommandOptions(new String[]{
                        "--zookeeper", "dummy", "--create", "--topic", TOPIC_NAME,
                        "--replication-factor", "2", "--partitions", "1"}));

        ObjectMapper jsonMapper = new DefaultObjectMapper();

        sendKafkaMessage(jsonMapper, kafkaServer.getBrokerListStr(), TOPIC_NAME);

        final CountDownLatch latch = new CountDownLatch(2);
View Full Code Here

Examples of io.druid.jackson.DefaultObjectMapper

  @Test
  public void testHashedBucketSelection() {
    List<HadoopyShardSpec> specs = Lists.newArrayList();
    final int partitionCount = 10;
    for (int i = 0; i < partitionCount; i++) {
      specs.add(new HadoopyShardSpec(new HashBasedNumberedShardSpec(i, partitionCount, new DefaultObjectMapper()), i));
    }
    // Backwards compatibility
    DataRollupSpec rollupSpec = new DataRollupSpec();
    rollupSpec.rollupGranularity = QueryGranularity.MINUTE;
View Full Code Here

Examples of io.druid.jackson.DefaultObjectMapper

public class FireDepartmentTest
{
  @Test
  public void testSerde() throws Exception
  {
    ObjectMapper jsonMapper = new DefaultObjectMapper();

    FireDepartment schema = new FireDepartment(
        new DataSchema(
            "foo",
            new StringInputRowParser(
                new JSONParseSpec(
                    new TimestampSpec(
                        "timestamp",
                        "auto"
                    ),
                    new DimensionsSpec(
                        Arrays.asList("dim1", "dim2"),
                        null,
                        null
                    )
                ),
                null, null, null, null
            ),
            new AggregatorFactory[]{
                new CountAggregatorFactory("count")
            },
            new UniformGranularitySpec(Granularity.HOUR, QueryGranularity.MINUTE, null, Granularity.HOUR)
        ),
        new RealtimeIOConfig(
            null,
            new RealtimePlumberSchool(
                null, null, null, null, null, null, null, null, null, null, null, null, null, 0
            )
        ),
        new RealtimeTuningConfig(
            null, null, null, null, null, null, null, null, false, false
        ),
        null, null, null, null
    );

    String json = jsonMapper.writeValueAsString(schema);

    FireDepartment newSchema = jsonMapper.readValue(json, FireDepartment.class);

    Assert.assertEquals(schema.getDataSchema().getDataSource(), newSchema.getDataSchema().getDataSource());
  }
View Full Code Here

Examples of io.druid.jackson.DefaultObjectMapper

  @Test
  public void testSerde() throws Exception
  {
    CardinalityAggregatorFactory factory = new CardinalityAggregatorFactory("billy", ImmutableList.of("b", "a", "c"), true);
    ObjectMapper objectMapper = new DefaultObjectMapper();
    Assert.assertEquals(
        factory,
        objectMapper.readValue(objectMapper.writeValueAsString(factory), AggregatorFactory.class)
    );
  }
View Full Code Here

Examples of io.druid.jackson.DefaultObjectMapper

  private GroupByQueryRunnerFactory factory;

  @Parameterized.Parameters
  public static Collection<?> constructorFeeder() throws IOException
  {
    final ObjectMapper mapper = new DefaultObjectMapper();
    final StupidPool<ByteBuffer> pool = new StupidPool<ByteBuffer>(
        new Supplier<ByteBuffer>()
        {
          @Override
          public ByteBuffer get()
View Full Code Here

Examples of io.druid.jackson.DefaultObjectMapper

                                .compressionProvider(new PotentiallyGzippedCompressionProvider(true))
                                .build();
    cf.start();
    cf.create().creatingParentsIfNeeded().forPath(testBasePath);

    jsonMapper = new DefaultObjectMapper();

    announcer = new Announcer(
        cf,
        MoreExecutors.sameThreadExecutor()
    );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.