Search in sources :

Example 1 with JsonCodec

use of org.onosproject.codec.JsonCodec in project onos by opennetworkinglab.

the class KafkaTelemetryManager method encodeStrings.

private ObjectNode encodeStrings(Set<LinkInfo> infos, CodecContext context, String codecName) {
    ObjectNode root = context.mapper().createObjectNode();
    ArrayNode array = context.mapper().createArrayNode();
    try {
        Class codecClazz = Class.forName(codecName);
        JsonCodec codec = codecService.getCodec(codecClazz);
        infos.forEach(l -> array.add(codec.encode(l, context)));
    } catch (ClassNotFoundException e) {
        log.warn("Failed to send telemetry record due to {}", e);
    }
    root.set(LINK_INFOS, array);
    return root;
}
Also used : JsonCodec(org.onosproject.codec.JsonCodec) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 JsonCodec (org.onosproject.codec.JsonCodec)1