本文整理汇总了Java中org.onosproject.cpman.ControlLoad类的典型用法代码示例。如果您正苦于以下问题:Java ControlLoad类的具体用法?Java ControlLoad怎么用?Java ControlLoad使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ControlLoad类属于org.onosproject.cpman包,在下文中一共展示了ControlLoad类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMetricsRequest
import org.onosproject.cpman.ControlLoad; //导入依赖的package包/类
/**
* 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);
}
示例2: getLocalLoad
import org.onosproject.cpman.ControlLoad; //导入依赖的package包/类
/**
* Returns local control load.
*
* @param type metric type
* @param deviceId device identifier
* @return control load
*/
private ControlLoad getLocalLoad(ControlMetricType type,
Optional<DeviceId> deviceId) {
if (deviceId.isPresent()) {
// returns control message stats
if (CONTROL_MESSAGE_METRICS.contains(type) &&
availableDeviceIdSet.contains(deviceId.get())) {
return new DefaultControlLoad(controlMessageMap.get(deviceId.get()), type);
}
} else {
// returns controlLoad of CPU metrics
if (CPU_METRICS.contains(type)) {
return new DefaultControlLoad(cpuMetrics, type);
}
// returns memoryLoad of memory metrics
if (MEMORY_METRICS.contains(type)) {
return new DefaultControlLoad(memoryMetrics, type);
}
}
return null;
}
示例3: snapshot
import org.onosproject.cpman.ControlLoad; //导入依赖的package包/类
/**
* Returns a snapshot of control load.
*
* @param cl control load
* @return a snapshot of control load
*/
private ControlLoadSnapshot snapshot(ControlLoad cl) {
if (cl != null) {
return new ControlLoadSnapshot(cl.latest(), cl.average(), cl.time());
}
return null;
}