use of org.onosproject.cpman.ControlMetricType 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.ControlMetricType 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;
}
use of org.onosproject.cpman.ControlMetricType in project onos by opennetworkinglab.
the class SystemMetricsAggregator method getMeterMap.
private Map<ControlMetricType, Meter> getMeterMap(Set<ControlMetricType> types, MetricsComponent component, MetricsService service) {
Map<ControlMetricType, Meter> meterMap = Maps.newHashMap();
types.forEach(type -> {
MetricsFeature metricsFeature = component.registerFeature(type.toString());
Meter meter = service.createMeter(component, metricsFeature, DEFAULT_METER_SUFFIX);
meterMap.putIfAbsent(type, meter);
});
return meterMap;
}
use of org.onosproject.cpman.ControlMetricType in project onos by opennetworkinglab.
the class SystemMetricsAggregator method addMetrics.
/**
* Adds a set of new monitoring metric types.
*
* @param optResourceName optional resource name, null denotes system metric
* @param resType resource type
*/
public void addMetrics(Optional<String> optResourceName, String resType) {
Set<ControlMetricType> metricTypeSet = Sets.newHashSet();
String resourceName = optResourceName.isPresent() ? optResourceName.get() : DEFAULT_RESOURCE_NAME;
MetricsComponent metricsComponent = metricsService.registerComponent(resourceName);
if (optResourceName.isPresent()) {
if (!diskMap.containsKey(resourceName) && DISK_RESOURCE_TYPE.equals(resType)) {
metricTypeSet.addAll(ControlResource.DISK_METRICS);
diskMap.putIfAbsent(resourceName, getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
} else if (!networkMap.containsKey(resourceName) && NETWORK_RESOURCE_TYPE.equals(resType)) {
metricTypeSet.addAll(ControlResource.NETWORK_METRICS);
networkMap.putIfAbsent(resourceName, getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
} else {
return;
}
} else {
if (systemMap.isEmpty()) {
metricTypeSet.addAll(ControlResource.MEMORY_METRICS);
metricTypeSet.addAll(ControlResource.CPU_METRICS);
systemMap.putAll(getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
}
}
}
Aggregations