Search in sources :

Example 1 with ControlLoad

use of org.onosproject.cpman.ControlLoad 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);
}
Also used : ControlLoadSnapshot(org.onosproject.cpman.ControlLoadSnapshot) ControlLoad(org.onosproject.cpman.ControlLoad)

Aggregations

ControlLoad (org.onosproject.cpman.ControlLoad)1 ControlLoadSnapshot (org.onosproject.cpman.ControlLoadSnapshot)1