Package com.netflix.suro.jackson

Examples of com.netflix.suro.jackson.DefaultObjectMapper.readValue()


                    return null;
                }
            }
        });

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

    @Test
    public void testRecover() throws JsonProcessingException {
View Full Code Here


                "    }\n" +
                "}";

        ObjectMapper jsonMapper = new DefaultObjectMapper();
        TypeReference<Map<String, Object>> type = new TypeReference<Map<String, Object>>(){};
        Map<String, Object> map = jsonMapper.readValue(obj, type);
        assertEquals(map.get("field2"), 3); // just check whether the object is created properly

        JsonSerDe<Map<String, Object>> serde = new JsonSerDe<Map<String, Object>>();
        byte[] bytes = serde.serialize(map);
        Map<String, Object> map2 = jsonMapper.readValue(bytes, type);
View Full Code Here

        Map<String, Object> map = jsonMapper.readValue(obj, type);
        assertEquals(map.get("field2"), 3); // just check whether the object is created properly

        JsonSerDe<Map<String, Object>> serde = new JsonSerDe<Map<String, Object>>();
        byte[] bytes = serde.serialize(map);
        Map<String, Object> map2 = jsonMapper.readValue(bytes, type);
        assertEquals(map, map2);

        map2 = serde.deserialize(bytes);
        assertEquals(map, map2);
View Full Code Here

                "    \"request.required.acks\": 1\n" +
                "}";

        ObjectMapper jsonMapper = new DefaultObjectMapper();
        jsonMapper.registerSubtypes(new NamedType(KafkaSink.class, "kafka"));
        KafkaSink sink = jsonMapper.readValue(description, new TypeReference<Sink>(){});
        sink.open();
        Iterator<Message> msgIterator = new MessageSetReader(createMessageSet(TOPIC_NAME, 2)).iterator();
        while (msgIterator.hasNext()) {
            sink.writeTo(new StringMessage(msgIterator.next()));
        }
View Full Code Here

                "    \"jobQueueSize\": 3\n" +
                "}";

        ObjectMapper jsonMapper = new DefaultObjectMapper();
        jsonMapper.registerSubtypes(new NamedType(KafkaSink.class, "kafka"));
        KafkaSink sink = jsonMapper.readValue(description, new TypeReference<Sink>(){});
        sink.open();
        int msgCount = 10000;
        for (int i = 0; i < msgCount; ++i) {
            Map<String, Object> msgMap = new ImmutableMap.Builder<String, Object>()
                    .put("key", Integer.toString(i))
View Full Code Here

                keyTopicMap + "\n" +
                "}";

        ObjectMapper jsonMapper = new DefaultObjectMapper();
        jsonMapper.registerSubtypes(new NamedType(KafkaSink.class, "kafka"));
        KafkaSink sink = jsonMapper.readValue(description, new TypeReference<Sink>(){});
        sink.open();

        int messageCount = 10;
        for (int i = 0; i < messageCount; ++i) {
            Map<String, Object> msgMap = new ImmutableMap.Builder<String, Object>()
View Full Code Here

        Map<Integer, Set<Map<String, Object>>> resultSet = new HashMap<Integer, Set<Map<String, Object>>>();
        for (int i = 0; i < messageCount; ++i) {
            MessageAndMetadata<byte[], byte[]> msgAndMeta = stream.iterator().next();
            System.out.println(new String(msgAndMeta.message()));

            Map<String, Object> msg = jsonMapper.readValue(new String(msgAndMeta.message()), new TypeReference<Map<String, Object>>() {});
            Set<Map<String, Object>> s = resultSet.get(msgAndMeta.partition());
            if (s == null) {
                s = new HashSet<Map<String, Object>>();
                resultSet.put(msgAndMeta.partition(), s);
            }
View Full Code Here

                "    \"request.required.acks\": 1\n" +
                "}";

        ObjectMapper jsonMapper = new DefaultObjectMapper();
        jsonMapper.registerSubtypes(new NamedType(KafkaSinkV2.class, "kafka"));
        KafkaSinkV2 sink = jsonMapper.readValue(description, new TypeReference<Sink>(){});
        sink.open();
        // create send test messages to Kafka
        Iterator<Message> msgIterator = new MessageSetReader(createMessageSet(TOPIC_NAME, 2)).iterator();
        HashSet<String> sentPayloads = new HashSet<String>(); // track sent messages for comparison later
        while (msgIterator.hasNext()) {
View Full Code Here

                "    \"jobQueueSize\": 3\n" +
                "}";

        ObjectMapper jsonMapper = new DefaultObjectMapper();
        jsonMapper.registerSubtypes(new NamedType(KafkaSinkV2.class, "kafka"));
        KafkaSinkV2 sink = jsonMapper.readValue(description, new TypeReference<Sink>(){});
        sink.open();
        int msgCount = 10000;
        for (int i = 0; i < msgCount; ++i) {
            Map<String, Object> msgMap = new ImmutableMap.Builder<String, Object>()
                    .put("key", Integer.toString(i))
View Full Code Here

                "}";

        // setup sink
        ObjectMapper jsonMapper = new DefaultObjectMapper();
        jsonMapper.registerSubtypes(new NamedType(KafkaSinkV2.class, "kafka"));
        KafkaSinkV2 sink = jsonMapper.readValue(description, new TypeReference<Sink>(){});
        sink.open();

        // create and send 10 test messages to Kafka
        int messageCount = 10;
        for (int i = 0; i < messageCount; ++i) {
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.