use of org.onosproject.cpman.ControlLoadSnapshot in project onos by opennetworkinglab.
the class ControlMetricsStatsListCommand method printMetricsStats.
/**
* Prints control plane metric statistic information.
*
* @param service monitor service
* @param nodeId node identifier
* @param typeSet control metric type
* @param resName resource name
* @param did device identifier
*/
private void printMetricsStats(ControlPlaneMonitorService service, NodeId nodeId, Set<ControlMetricType> typeSet, String resName, DeviceId did) {
if (resName == null && did == null) {
typeSet.forEach(s -> {
ControlLoadSnapshot cls = service.getLoadSync(nodeId, s, Optional.empty());
printControlLoadSnapshot(s, cls);
});
} else if (resName == null) {
typeSet.forEach(s -> {
ControlLoadSnapshot cls = service.getLoadSync(nodeId, s, Optional.of(did));
printControlLoadSnapshot(s, cls);
});
} else if (did == null) {
typeSet.forEach(s -> {
ControlLoadSnapshot cls = service.getLoadSync(nodeId, s, resName);
printControlLoadSnapshot(s, cls);
});
}
}
use of org.onosproject.cpman.ControlLoadSnapshot in project onos by opennetworkinglab.
the class ControlPlaneMonitor method handleMetricsRequest.
/**
* Handles control metric request from remote node.
*
* @param request control metric request
* @return completable future object of control load snapshot
*/
private CompletableFuture<ControlLoadSnapshot> handleMetricsRequest(ControlMetricsRequest request) {
checkArgument(request.getType() != null, METRIC_TYPE_NULL);
ControlLoad load;
if (request.getResourceName() != null && request.getUnit() != null) {
load = getLocalLoad(request.getType(), request.getResourceName());
} else {
load = getLocalLoad(request.getType(), request.getDeviceId());
}
long average;
if (request.getUnit() != null) {
average = load.average(request.getDuration(), request.getUnit());
} else {
average = load.average();
}
ControlLoadSnapshot resp = new ControlLoadSnapshot(load.latest(), average, load.time());
return CompletableFuture.completedFuture(resp);
}
use of org.onosproject.cpman.ControlLoadSnapshot in project onos by opennetworkinglab.
the class ControlMetricsWebResource method metricsStats.
/**
* Returns a collection of control loads of the given control metric types.
*
* @param service control plane monitoring service
* @param nodeId node identification
* @param typeSet a group of control metric types
* @param name resource name
* @param did device identification
* @return a collection of control loads
*/
private ArrayNode metricsStats(ControlPlaneMonitorService service, NodeId nodeId, Set<ControlMetricType> typeSet, String name, DeviceId did, ObjectNode node) {
ArrayNode metricsNode = node.putArray("metrics");
if (name == null && did == null) {
typeSet.forEach(type -> {
ControlLoadSnapshot cls = service.getLoadSync(nodeId, type, Optional.empty());
processRest(cls, type, metricsNode);
});
} else if (name == null) {
typeSet.forEach(type -> {
ControlLoadSnapshot cls = service.getLoadSync(nodeId, type, Optional.of(did));
processRest(cls, type, metricsNode);
});
} else if (did == null) {
typeSet.forEach(type -> {
ControlLoadSnapshot cls = service.getLoadSync(nodeId, type, name);
processRest(cls, type, metricsNode);
});
}
return metricsNode;
}
Aggregations