Implement updateMetric and getLoad methods of ControlPlaneMonitor
- Add rrd4j jar, and wrap it as a bundle for karaf
- Implement updateMetric and getLoad methods
- Add unit test for two methods
- Revise the DefaultMetricDatabase to make it generate unique in
memory storage space
- Revise the ControlPlaneMonitor interface
- Rename percentage to ratio, due to long string unsupport
issue in RRD
Change-Id: Ia9d56f8e4f4bcd7ef7a29732668caa9c6a885ecf
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java
index f7a60dc..f547866 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java
@@ -122,20 +122,20 @@
ControlMetric cm;
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
- JsonNode memUsedPerc = jsonTree.get("memoryUsedPercentage");
- JsonNode memFreePerc = jsonTree.get("memoryFreePercentage");
+ JsonNode memUsedRatio = jsonTree.get("memoryUsedRatio");
+ JsonNode memFreeRatio = jsonTree.get("memoryFreeRatio");
JsonNode memUsed = jsonTree.get("memoryUsed");
JsonNode memFree = jsonTree.get("memoryFree");
- if (memUsedPerc != null) {
- cm = new ControlMetric(ControlMetricType.MEMORY_USED_PERCENTAGE,
- new MetricValue.Builder().load(memUsedPerc.asLong()).add());
+ if (memUsedRatio != null) {
+ cm = new ControlMetric(ControlMetricType.MEMORY_USED_RATIO,
+ new MetricValue.Builder().load(memUsedRatio.asLong()).add());
service.updateMetric(cm, UPDATE_INTERVAL, Optional.ofNullable(null));
}
- if (memFreePerc != null) {
- cm = new ControlMetric(ControlMetricType.MEMORY_FREE_PERCENTAGE,
- new MetricValue.Builder().load(memFreePerc.asLong()).add());
+ if (memFreeRatio != null) {
+ cm = new ControlMetric(ControlMetricType.MEMORY_FREE_RATIO,
+ new MetricValue.Builder().load(memFreeRatio.asLong()).add());
service.updateMetric(cm, UPDATE_INTERVAL, Optional.ofNullable(null));
}