use of org.onosproject.net.device.PortStatistics in project onos by opennetworkinglab.
the class StatisticsWebResource method getPortStatisticsByDeviceId.
/**
* Gets port statistics of a specified devices.
* @onos.rsModel StatisticsPorts
* @param deviceId device ID
* @return 200 OK with JSON encoded array of port statistics
*/
@GET
@Path("ports/{deviceId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getPortStatisticsByDeviceId(@PathParam("deviceId") String deviceId) {
final DeviceService service = get(DeviceService.class);
final Iterable<PortStatistics> portStatsEntries = service.getPortStatistics(DeviceId.deviceId(deviceId));
final ObjectNode root = mapper().createObjectNode();
final ArrayNode rootArrayNode = root.putArray("statistics");
final ObjectNode deviceStatsNode = mapper().createObjectNode();
deviceStatsNode.put("device", deviceId);
final ArrayNode statisticsNode = deviceStatsNode.putArray("ports");
if (portStatsEntries != null) {
for (final PortStatistics entry : portStatsEntries) {
statisticsNode.add(codec(PortStatistics.class).encode(entry, this));
}
}
rootArrayNode.add(deviceStatsNode);
return ok(root).build();
}
use of org.onosproject.net.device.PortStatistics in project onos by opennetworkinglab.
the class StatisticsWebResource method getPortDeltaStatisticsByDeviceId.
/**
* Gets port delta statistics of a specified devices.
* @onos.rsModel StatisticsPorts
* @param deviceId device ID
* @return 200 OK with JSON encoded array of port delta statistics
*/
@GET
@Path("delta/ports/{deviceId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getPortDeltaStatisticsByDeviceId(@PathParam("deviceId") String deviceId) {
final DeviceService service = get(DeviceService.class);
final Iterable<PortStatistics> portStatsEntries = service.getPortDeltaStatistics(DeviceId.deviceId(deviceId));
final ObjectNode root = mapper().createObjectNode();
final ArrayNode rootArrayNode = root.putArray("statistics");
final ObjectNode deviceStatsNode = mapper().createObjectNode();
deviceStatsNode.put("device", deviceId);
final ArrayNode statisticsNode = deviceStatsNode.putArray("ports");
if (portStatsEntries != null) {
for (final PortStatistics entry : portStatsEntries) {
statisticsNode.add(codec(PortStatistics.class).encode(entry, this));
}
}
rootArrayNode.add(deviceStatsNode);
return ok(root).build();
}
Aggregations