Search in sources :

Example 1 with PacketProcessorEntry

use of org.onosproject.net.packet.PacketProcessorEntry in project onos by opennetworkinglab.

the class PacketProcessorsWebResource method getPacketProcessors.

/**
 * Gets packet processors. Returns array of all packet processors.
 *
 * @onos.rsModel PacketProcessorsGet
 * @return 200 OK with array of all packet processors.
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getPacketProcessors() {
    PacketService service = get(PacketService.class);
    ObjectNode root = mapper().createObjectNode();
    ArrayNode pktProcNode = root.putArray("packet-processors");
    List<PacketProcessorEntry> processors = service.getProcessors();
    ObjectMapper mapper = new ObjectMapper();
    for (PacketProcessorEntry p : processors) {
        pktProcNode.add(mapper.createObjectNode().put("priority", priorityFormat(p.priority())).put("class", p.processor().getClass().getName()).put("packets", p.invocations()).put("avgNanos", p.averageNanos()));
    }
    return ok(root).build();
}
Also used : PacketService(org.onosproject.net.packet.PacketService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PacketProcessorEntry(org.onosproject.net.packet.PacketProcessorEntry) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with PacketProcessorEntry

use of org.onosproject.net.packet.PacketProcessorEntry in project onos by opennetworkinglab.

the class PacketProcessorsListCommand method json.

private JsonNode json(List<PacketProcessorEntry> processors) {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode result = mapper.createArrayNode();
    for (PacketProcessorEntry p : processors) {
        result.add(mapper.createObjectNode().put("priority", priorityFormat(p.priority())).put("class", p.processor().getClass().getName()).put("packets", p.invocations()).put("avgNanos", p.averageNanos()));
    }
    return result;
}
Also used : PacketProcessorEntry(org.onosproject.net.packet.PacketProcessorEntry) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 PacketProcessorEntry (org.onosproject.net.packet.PacketProcessorEntry)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 PacketService (org.onosproject.net.packet.PacketService)1