Clean code and refine javadocs for control plane manager
Change-Id: Ieaaebde69ce2ab54cb819cfad1baa34ee97a7d66
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsFactory.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsFactory.java
index 2460d6c..4fcf04f 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsFactory.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsFactory.java
@@ -67,6 +67,12 @@
private Set<String> diskPartitions = Sets.newConcurrentHashSet();
private Set<String> nwInterfaces = Sets.newConcurrentHashSet();
+ /**
+ * Constructs a control metrics factory using the given metrics and device services.
+ *
+ * @param metricsService metric service reference
+ * @param deviceService device service reference
+ */
private ControlMetricsFactory(MetricsService metricsService, DeviceService deviceService) {
this.metricsService = metricsService;
registerMetrics();
@@ -76,6 +82,13 @@
addAllControlMessageMetrics(deviceIds);
}
+ /**
+ * Obtains the unique instance of ControlMetricsFactory.
+ *
+ * @param metricsService metric service
+ * @param deviceService device service
+ * @return instance of ControlMetricsFactory
+ */
public static ControlMetricsFactory getInstance(MetricsService metricsService,
DeviceService deviceService) {
if (uniqueInstance == null) {
@@ -102,7 +115,7 @@
/**
* Adds control metrics of a new device.
*
- * @param deviceId {@link org.onosproject.net.DeviceId}
+ * @param deviceId device identifier
*/
public void addControlMessageMetricsByDeviceId(DeviceId deviceId) {
MetricsAggregator inbound = new MetricsAggregator(metricsService,
@@ -171,7 +184,7 @@
/**
* Removes control metrics of an existing device.
*
- * @param deviceId {@link org.onosproject.net.DeviceId}
+ * @param deviceId device identifier
*/
public void removeControlMessageMetricsByDeviceId(DeviceId deviceId) {
inboundPacket.remove(deviceId);
@@ -211,9 +224,9 @@
}
/**
- * Returns all device ids.
+ * Returns all device identifiers.
*
- * @return a collection of device id
+ * @return a collection of device identifiers
*/
public Set<DeviceId> getDeviceIds() {
return ImmutableSet.copyOf(this.deviceIds);
@@ -222,7 +235,7 @@
/**
* Returns all disk partition names.
*
- * @return a collection of disk partition.
+ * @return a collection of disk partitions.
*/
public Set<String> getDiskPartitions() {
return ImmutableSet.copyOf(this.diskPartitions);
@@ -231,7 +244,7 @@
/**
* Returns all network interface names.
*
- * @return a collection of network interface.
+ * @return a collection of network interfaces.
*/
public Set<String> getNetworkInterfaces() {
return ImmutableSet.copyOf(this.nwInterfaces);
@@ -240,7 +253,7 @@
/**
* Adds control metrics for all devices.
*
- * @param deviceIds a set of deviceIds
+ * @param deviceIds a set of device identifiers
*/
public void addAllControlMessageMetrics(Set<DeviceId> deviceIds) {
deviceIds.forEach(v -> addControlMessageMetricsByDeviceId(v));
@@ -330,102 +343,239 @@
replyPacket.clear();
}
+ /**
+ * Returns CPU load metric aggregator.
+ *
+ * @return metric aggregator
+ */
public MetricsAggregator cpuLoadMetric() {
return cpuLoad;
}
+ /**
+ * Returns total CPU time metric aggregator.
+ *
+ * @return metric aggregator
+ */
public MetricsAggregator totalCpuTimeMetric() {
return totalCpuTime;
}
+ /**
+ * Returns system CPU time metric aggregator.
+ *
+ * @return metric aggregator
+ */
public MetricsAggregator sysCpuTimeMetric() {
return sysCpuTime;
}
+ /**
+ * Returns user CPU time metric aggregator.
+ *
+ * @return metric aggregator
+ */
public MetricsAggregator userCpuTime() {
return userCpuTime;
}
+ /**
+ * Returns CPU idle time metric aggregator.
+ *
+ * @return metric aggregator
+ */
public MetricsAggregator cpuIdleTime() {
return cpuIdleTime;
}
+ /**
+ * Returns free memory ratio metric aggregator.
+ *
+ * @return metric aggregator
+ */
public MetricsAggregator memoryFreeRatio() {
return memoryFreeRatio;
}
+ /**
+ * Returns used memory ratio metric aggregator.
+ *
+ * @return metric aggregator
+ */
public MetricsAggregator memoryUsedRatio() {
return memoryUsedRatio;
}
- public MetricsAggregator diskReadBytes(String partitionName) {
- return diskReadBytes.get(partitionName);
+ /**
+ * Returns disk read bytes metric aggregator.
+ *
+ * @param resourceName name of disk resource
+ * @return metric aggregator
+ */
+ public MetricsAggregator diskReadBytes(String resourceName) {
+ return diskReadBytes.get(resourceName);
}
- public MetricsAggregator diskWriteBytes(String partitionName) {
- return diskWriteBytes.get(partitionName);
+ /**
+ * Returns disk write bytes metric aggregator.
+ *
+ * @param resourceName name of disk resource
+ * @return metric aggregator
+ */
+ public MetricsAggregator diskWriteBytes(String resourceName) {
+ return diskWriteBytes.get(resourceName);
}
+ /**
+ * Returns incoming bytes metric aggregator.
+ *
+ * @param interfaceName name of network interface
+ * @return metric aggregator
+ */
public MetricsAggregator nwIncomingBytes(String interfaceName) {
return nwIncomingBytes.get(interfaceName);
}
+ /**
+ * Returns outgoing bytes metric aggregator.
+ *
+ * @param interfaceName name of network interface
+ * @return metric aggregator
+ */
public MetricsAggregator nwOutgoingBytes(String interfaceName) {
return nwOutgoingBytes.get(interfaceName);
}
+ /**
+ * Returns incoming packets metric aggregator.
+ *
+ * @param interfaceName name of network interface
+ * @return metric aggregator
+ */
public MetricsAggregator nwIncomingPackets(String interfaceName) {
return nwIncomingPackets.get(interfaceName);
}
+ /**
+ * Returns outgoing packets metric aggregator.
+ *
+ * @param interfaceName name of network interface
+ * @return metric aggregator
+ */
public MetricsAggregator nwOutgoingPackets(String interfaceName) {
return nwOutgoingPackets.get(interfaceName);
}
+ /**
+ * Returns inbound packet metric aggregator of all devices.
+ *
+ * @return metric aggregator
+ */
public Map<DeviceId, MetricsAggregator> inboundPacket() {
return ImmutableMap.copyOf(inboundPacket);
}
+ /**
+ * Returns outgoing packet metric aggregator of all devices.
+ *
+ * @return metric aggregator
+ */
public Map<DeviceId, MetricsAggregator> outboundPacket() {
return ImmutableMap.copyOf(outboundPacket);
}
+ /**
+ * Returns flow-mod packet metric aggregator of all devices.
+ *
+ * @return metric aggregator
+ */
public Map<DeviceId, MetricsAggregator> flowmodPacket() {
return ImmutableMap.copyOf(flowmodPacket);
}
+ /**
+ * Returns flow-removed packet metric aggregator of all devices.
+ *
+ * @return metric aggregator
+ */
public Map<DeviceId, MetricsAggregator> flowrmvPacket() {
return ImmutableMap.copyOf(flowrmvPacket);
}
+ /**
+ * Returns request packet metric aggregator of all devices.
+ *
+ * @return metric aggregator
+ */
public Map<DeviceId, MetricsAggregator> requestPacket() {
return ImmutableMap.copyOf(requestPacket);
}
+ /**
+ * Returns reply packet metric aggregator of all devices.
+ *
+ * @return metric aggregator
+ */
public Map<DeviceId, MetricsAggregator> replyPacket() {
return ImmutableMap.copyOf(replyPacket);
}
+ /**
+ * Returns inbound packet metric aggregator of a specified device.
+ *
+ * @param deviceId device identifier
+ * @return metric aggregator
+ */
public MetricsAggregator inboundPacket(DeviceId deviceId) {
return inboundPacket.get(deviceId);
}
+ /**
+ * Returns outbound packet metric aggregator of a specified device.
+ *
+ * @param deviceId device identifier
+ * @return metric aggregator
+ */
public MetricsAggregator outboundPacket(DeviceId deviceId) {
return outboundPacket.get(deviceId);
}
+ /**
+ * Returns flow-mod packet metric aggregator of a specified device.
+ *
+ * @param deviceId device identifier
+ * @return metric aggregator
+ */
public MetricsAggregator flowmodPacket(DeviceId deviceId) {
return flowmodPacket.get(deviceId);
}
+ /**
+ * Returns flow-removed packet metric aggregator of a specified device.
+ *
+ * @param deviceId device identifier
+ * @return metric aggregator
+ */
public MetricsAggregator flowrmvPacket(DeviceId deviceId) {
return flowrmvPacket.get(deviceId);
}
+ /**
+ * Returns request packet metric aggregator of a specified device.
+ *
+ * @param deviceId device identifier
+ * @return metric aggregator
+ */
public MetricsAggregator requestPacket(DeviceId deviceId) {
return requestPacket.get(deviceId);
}
+ /**
+ * Returns reply packet metric aggregator of a specified device.
+ *
+ * @param deviceId device identifier
+ * @return metric aggregator
+ */
public MetricsAggregator replyPacket(DeviceId deviceId) {
return replyPacket.get(deviceId);
}
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsObserver.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsObserver.java
index fb0bf8b..771c5cd 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsObserver.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsObserver.java
@@ -28,7 +28,7 @@
* Feeds the extracted value from MetricAggregator to back-end storage.
*
* @param metricsAggregator metric aggregator
- * @param deviceId device id {@link org.onosproject.net.DeviceId}
+ * @param deviceId device identification
*/
void feedMetrics(MetricsAggregator metricsAggregator, Optional<DeviceId> deviceId);
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneMonitor.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneMonitor.java
index 682b3705..66b4a57 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneMonitor.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneMonitor.java
@@ -36,6 +36,7 @@
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static org.onosproject.cpman.ControlMetricType.CPU_IDLE_TIME;
@@ -83,18 +84,18 @@
private static final String DISK = "Disk";
private static final String NETWORK = "Network";
- private static final ImmutableSet<ControlMetricType> CPU_METRICS =
+ private static final Set<ControlMetricType> CPU_METRICS =
ImmutableSet.of(CPU_IDLE_TIME, CPU_LOAD, SYS_CPU_TIME,
USER_CPU_TIME, TOTAL_CPU_TIME);
- private static final ImmutableSet<ControlMetricType> MEMORY_METRICS =
+ private static final Set<ControlMetricType> MEMORY_METRICS =
ImmutableSet.of(MEMORY_FREE, MEMORY_FREE_RATIO, MEMORY_USED,
MEMORY_USED_RATIO);
- private static final ImmutableSet<ControlMetricType> DISK_METRICS =
+ private static final Set<ControlMetricType> DISK_METRICS =
ImmutableSet.of(DISK_READ_BYTES, DISK_WRITE_BYTES);
- private static final ImmutableSet<ControlMetricType> NETWORK_METRICS =
+ private static final Set<ControlMetricType> NETWORK_METRICS =
ImmutableSet.of(NW_INCOMING_BYTES, NW_OUTGOING_BYTES,
NW_INCOMING_PACKETS, NW_OUTGOING_PACKETS);
- private static final ImmutableSet<ControlMetricType> CTRL_MSGS =
+ private static final Set<ControlMetricType> CTRL_MSGS =
ImmutableSet.of(INBOUND_PACKET, OUTBOUND_PACKET, FLOW_MOD_PACKET,
FLOW_REMOVED_PACKET, REQUEST_PACKET, REPLY_PACKET);
private Map<ControlMetricType, Double> cpuBuf;
@@ -134,7 +135,7 @@
}
@Override
- public void updateMetric(ControlMetric cm, Integer updateInterval,
+ public void updateMetric(ControlMetric cm, int updateIntervalInMinutes,
Optional<DeviceId> deviceId) {
if (deviceId.isPresent()) {
@@ -180,7 +181,7 @@
}
@Override
- public void updateMetric(ControlMetric cm, Integer updateInterval,
+ public void updateMetric(ControlMetric cm, int updateIntervalInMinutes,
String resourceName) {
// update disk metrics
if (DISK_METRICS.contains(cm.metricType())) {
@@ -252,7 +253,7 @@
}
private MetricsDatabase genMDbBuilder(String metricName,
- ImmutableSet<ControlMetricType> metricTypes) {
+ Set<ControlMetricType> metricTypes) {
MetricsDatabase.Builder builder = new DefaultMetricsDatabase.Builder();
builder.withMetricName(metricName);
metricTypes.forEach(type -> builder.addMetricType(type.toString()));
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultControlLoad.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultControlLoad.java
index ef32cab..0882bd3 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultControlLoad.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultControlLoad.java
@@ -31,6 +31,13 @@
private final MetricsDatabase mdb;
private final ControlMetricType type;
+ /**
+ * Constructs a control load using the given metrics database and
+ * control metric type.
+ *
+ * @param mdb metrics database
+ * @param type control metric type
+ */
public DefaultControlLoad(MetricsDatabase mdb, ControlMetricType type) {
this.mdb = mdb;
this.type = type;
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultMetricsDatabase.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultMetricsDatabase.java
index f62a0ec..db8be14 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultMetricsDatabase.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultMetricsDatabase.java
@@ -53,6 +53,13 @@
private static final String INSUFFICIENT_DURATION = "Given duration less than one minute.";
private static final String EXCEEDED_DURATION = "Given duration exceeds a day time.";
+ /**
+ * Constructs a metrics database using the given metric name and
+ * round robin database.
+ *
+ * @param metricName metric name
+ * @param rrdDb round robin database
+ */
private DefaultMetricsDatabase(String metricName, RrdDb rrdDb) {
this.metricName = metricName;
this.rrdDb = rrdDb;
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/MetricsAggregator.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/MetricsAggregator.java
index 8426cb7..bdcc56e 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/MetricsAggregator.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/MetricsAggregator.java
@@ -43,13 +43,13 @@
private static final String COUNT_NAME = "count";
/**
- * Constructs a new MetricsAggregator for aggregating a metric.
+ * Constructs a new metrics aggregator for aggregating a metric.
* Instantiates the metrics service
* Initializes all the general metrics for that object
*
- * @param metricsService MetricsService reference
- * @param type Control metric type
- * @param deviceId DeviceId
+ * @param metricsService metric service reference
+ * @param type control metric type
+ * @param deviceId device identification
*/
MetricsAggregator(MetricsService metricsService, ControlMetricType type,
Optional<DeviceId> deviceId) {
@@ -57,12 +57,12 @@
}
/**
- * Constructs a new MetricAggregator for aggregating a metric.
+ * Constructs a new metrics aggregator for aggregating a metric.
* Instantiates the metrics service
* Initializes all the general metrics for that object
*
- * @param metricsService MetricsService reference
- * @param type Control metric type
+ * @param metricsService metric service reference
+ * @param type control metric type
* @param resourceName resource name (e.g., ethernet interface name)
*/
MetricsAggregator(MetricsService metricsService, ControlMetricType type,
@@ -72,12 +72,12 @@
}
/**
- * Constructs a new MetricAggregator for aggregating a metric.
+ * Constructs a new metrics aggregator for aggregating a metric.
* Instantiates the metrics service
* Initializes all the general metrics for that object
*
- * @param metricsService MetricsService reference
- * @param type Control metric type
+ * @param metricsService metrics service reference
+ * @param type control metric type
*/
MetricsAggregator(MetricsService metricsService, ControlMetricType type) {
init(metricsService, type, Optional.ofNullable(null), null);
@@ -86,9 +86,9 @@
/**
* Base method of the constructor of this class.
*
- * @param metricsService MetricsService reference
- * @param type Control metric type
- * @param deviceId DeviceId
+ * @param metricsService metrics service reference
+ * @param type control metric type
+ * @param deviceId device identification
* @param resourceName resource name
*/
private void init(MetricsService metricsService, ControlMetricType type,
@@ -116,14 +116,19 @@
this.countMeter = metricsService.createMeter(metricsComponent, metricsFeature, COUNT_NAME);
}
+ /**
+ * Returns control metrics type.
+ *
+ * @return control metrics type
+ */
public ControlMetricType getMetricsType() {
return metricsType;
}
/**
- * Increments the meter rate by {@code n}, and the meter counter by 1.
+ * Increments the meter rate by n, and the meter counter by 1.
*
- * @param n Increment the meter rate by {@code n}.
+ * @param n increment rate.
*/
public void increment(long n) {
rateMeter.mark(n);
@@ -131,7 +136,7 @@
}
/**
- * Obtains the average load value.
+ * Returns the average load value.
*
* @return load value
*/
@@ -140,7 +145,7 @@
}
/**
- * Obtains the average meter rate within recent 1 minute.
+ * Returns the average meter rate within recent 1 minute.
*
* @return rate value
*/
@@ -149,7 +154,7 @@
}
/**
- * Obtains the average meter count within recent 1 minute.
+ * Returns the average meter count within recent 1 minute.
*
* @return count value
*/