Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 1 | /* |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 2 | * Copyright 2015-2016 Open Networking Laboratory |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Jian Li | 6b86a76 | 2016-01-29 09:30:40 -0800 | [diff] [blame] | 16 | package org.onosproject.cpman.impl; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 17 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 18 | import com.google.common.collect.ImmutableMap; |
| 19 | import com.google.common.collect.ImmutableSet; |
| 20 | import com.google.common.collect.Sets; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 21 | import org.onlab.metrics.MetricsService; |
Jian Li | 6b86a76 | 2016-01-29 09:30:40 -0800 | [diff] [blame] | 22 | import org.onosproject.cpman.ControlMetricType; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 23 | import org.onosproject.net.DeviceId; |
| 24 | import org.onosproject.net.device.DeviceService; |
| 25 | |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 26 | import java.util.Map; |
| 27 | import java.util.Optional; |
| 28 | import java.util.Set; |
| 29 | import java.util.concurrent.ConcurrentHashMap; |
| 30 | |
| 31 | /** |
| 32 | * Singleton class to provide various control plane metrics to other components. |
| 33 | */ |
| 34 | public final class ControlMetricsFactory { |
| 35 | private static volatile ControlMetricsFactory uniqueInstance; |
| 36 | |
| 37 | private MetricsService metricsService; |
| 38 | private boolean enableMonitor = false; |
| 39 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 40 | // define a ControlMetricsSystemSpec |
| 41 | private ControlMetricsSystemSpec cmss; |
| 42 | |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 43 | // define a set of MetricsAggregators |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 44 | private MetricsAggregator cpuLoad; |
| 45 | private MetricsAggregator totalCpuTime; |
| 46 | private MetricsAggregator sysCpuTime; |
| 47 | private MetricsAggregator userCpuTime; |
| 48 | private MetricsAggregator cpuIdleTime; |
| 49 | private MetricsAggregator memoryUsed; |
| 50 | private MetricsAggregator memoryFree; |
Jian Li | 7d180c5 | 2016-02-01 21:53:08 -0800 | [diff] [blame^] | 51 | private MetricsAggregator memoryUsedRatio; |
| 52 | private MetricsAggregator memoryFreeRatio; |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 53 | private Map<String, MetricsAggregator> diskReadBytes; |
| 54 | private Map<String, MetricsAggregator> diskWriteBytes; |
| 55 | private Map<String, MetricsAggregator> nwIncomingBytes; |
| 56 | private Map<String, MetricsAggregator> nwOutgoingBytes; |
| 57 | private Map<String, MetricsAggregator> nwIncomingPackets; |
| 58 | private Map<String, MetricsAggregator> nwOutgoingPackets; |
| 59 | |
| 60 | private Map<DeviceId, MetricsAggregator> inboundPacket; |
| 61 | private Map<DeviceId, MetricsAggregator> outboundPacket; |
| 62 | private Map<DeviceId, MetricsAggregator> flowmodPacket; |
| 63 | private Map<DeviceId, MetricsAggregator> flowrmvPacket; |
| 64 | private Map<DeviceId, MetricsAggregator> requestPacket; |
| 65 | private Map<DeviceId, MetricsAggregator> replyPacket; |
| 66 | private Set<DeviceId> deviceIds = Sets.newConcurrentHashSet(); |
| 67 | private Set<String> diskPartitions = Sets.newConcurrentHashSet(); |
| 68 | private Set<String> nwInterfaces = Sets.newConcurrentHashSet(); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 69 | |
| 70 | private ControlMetricsFactory(MetricsService metricsService, DeviceService deviceService) { |
| 71 | this.metricsService = metricsService; |
| 72 | registerMetrics(); |
| 73 | |
| 74 | deviceService.getDevices().forEach(d->deviceIds.add(d.id())); |
| 75 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 76 | addAllControlMessageMetrics(deviceIds); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | public static ControlMetricsFactory getInstance(MetricsService metricsService, |
| 80 | DeviceService deviceService) { |
| 81 | if (uniqueInstance == null) { |
| 82 | synchronized (ControlMetricsFactory.class) { |
| 83 | if (uniqueInstance == null) { |
| 84 | uniqueInstance = new ControlMetricsFactory(metricsService, deviceService); |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | return uniqueInstance; |
| 89 | } |
| 90 | |
| 91 | /** |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 92 | * Sets system specification. |
| 93 | * |
| 94 | * @param cmss ControlMetricsSystemSpec object |
| 95 | */ |
| 96 | public void setSystemSpec(ControlMetricsSystemSpec cmss) { |
| 97 | if (this.cmss == null) { |
| 98 | this.cmss = cmss; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 103 | * Adds control metrics of a new device. |
| 104 | * |
| 105 | * @param deviceId {@link org.onosproject.net.DeviceId} |
| 106 | */ |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 107 | public void addControlMessageMetricsByDeviceId(DeviceId deviceId) { |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 108 | MetricsAggregator inbound = new MetricsAggregator(metricsService, |
| 109 | ControlMetricType.INBOUND_PACKET, Optional.of(deviceId)); |
| 110 | MetricsAggregator outbound = new MetricsAggregator(metricsService, |
| 111 | ControlMetricType.OUTBOUND_PACKET, Optional.of(deviceId)); |
| 112 | MetricsAggregator flowmod = new MetricsAggregator(metricsService, |
| 113 | ControlMetricType.FLOW_MOD_PACKET, Optional.of(deviceId)); |
| 114 | MetricsAggregator flowrmv = new MetricsAggregator(metricsService, |
| 115 | ControlMetricType.FLOW_REMOVED_PACKET, Optional.of(deviceId)); |
| 116 | MetricsAggregator request = new MetricsAggregator(metricsService, |
| 117 | ControlMetricType.REQUEST_PACKET, Optional.of(deviceId)); |
| 118 | MetricsAggregator reply = new MetricsAggregator(metricsService, |
| 119 | ControlMetricType.REPLY_PACKET, Optional.of(deviceId)); |
| 120 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 121 | inboundPacket.putIfAbsent(deviceId, inbound); |
| 122 | outboundPacket.putIfAbsent(deviceId, outbound); |
| 123 | flowmodPacket.putIfAbsent(deviceId, flowmod); |
| 124 | flowrmvPacket.putIfAbsent(deviceId, flowrmv); |
| 125 | requestPacket.putIfAbsent(deviceId, request); |
| 126 | replyPacket.putIfAbsent(deviceId, reply); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 127 | |
| 128 | deviceIds.add(deviceId); |
| 129 | } |
| 130 | |
| 131 | /** |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 132 | * Adds control metrics of a disk. |
| 133 | * |
| 134 | * @param partitionName disk partition name |
| 135 | */ |
| 136 | public void addDiskMetricsByPartition(String partitionName) { |
| 137 | MetricsAggregator readBytes = new MetricsAggregator(metricsService, |
| 138 | ControlMetricType.DISK_READ_BYTES, partitionName); |
| 139 | MetricsAggregator writeBytes = new MetricsAggregator(metricsService, |
| 140 | ControlMetricType.DISK_WRITE_BYTES, partitionName); |
| 141 | |
| 142 | diskReadBytes.putIfAbsent(partitionName, readBytes); |
| 143 | diskWriteBytes.putIfAbsent(partitionName, writeBytes); |
| 144 | |
| 145 | diskPartitions.add(partitionName); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Adds control metrics of a ethernet interface. |
| 150 | * |
| 151 | * @param interfaceName network interface name |
| 152 | */ |
| 153 | public void addNetworkMetricsByInterface(String interfaceName) { |
| 154 | MetricsAggregator incomingBytes = new MetricsAggregator(metricsService, |
| 155 | ControlMetricType.NW_INCOMING_BYTES, interfaceName); |
| 156 | MetricsAggregator outgoingBytes = new MetricsAggregator(metricsService, |
| 157 | ControlMetricType.NW_OUTGOING_BYTES, interfaceName); |
| 158 | MetricsAggregator incomingPackets = new MetricsAggregator(metricsService, |
| 159 | ControlMetricType.NW_INCOMING_PACKETS, interfaceName); |
| 160 | MetricsAggregator outgoingPackets = new MetricsAggregator(metricsService, |
| 161 | ControlMetricType.NW_OUTGOING_PACKETS, interfaceName); |
| 162 | |
| 163 | nwIncomingBytes.putIfAbsent(interfaceName, incomingBytes); |
| 164 | nwOutgoingBytes.putIfAbsent(interfaceName, outgoingBytes); |
| 165 | nwIncomingPackets.putIfAbsent(interfaceName, incomingPackets); |
| 166 | nwOutgoingPackets.putIfAbsent(interfaceName, outgoingPackets); |
| 167 | |
| 168 | nwInterfaces.add(interfaceName); |
| 169 | } |
| 170 | |
| 171 | /** |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 172 | * Removes control metrics of an existing device. |
| 173 | * |
| 174 | * @param deviceId {@link org.onosproject.net.DeviceId} |
| 175 | */ |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 176 | public void removeControlMessageMetricsByDeviceId(DeviceId deviceId) { |
| 177 | inboundPacket.remove(deviceId); |
| 178 | outboundPacket.remove(deviceId); |
| 179 | flowmodPacket.remove(deviceId); |
| 180 | flowrmvPacket.remove(deviceId); |
| 181 | requestPacket.remove(deviceId); |
| 182 | replyPacket.remove(deviceId); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 183 | |
| 184 | deviceIds.remove(deviceId); |
| 185 | } |
| 186 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 187 | /** |
| 188 | * Removes control metrics of a disk. |
| 189 | * |
| 190 | * @param partitionName disk partition name |
| 191 | */ |
| 192 | public void removeDiskMetricsByResourceName(String partitionName) { |
| 193 | diskReadBytes.remove(partitionName); |
| 194 | diskWriteBytes.remove(partitionName); |
| 195 | |
| 196 | diskPartitions.remove(partitionName); |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Removes control metrics of a network interface. |
| 201 | * |
| 202 | * @param interfaceName network interface name |
| 203 | */ |
| 204 | public void removeNetworkInterfacesByResourceName(String interfaceName) { |
| 205 | nwIncomingBytes.remove(interfaceName); |
| 206 | nwOutgoingBytes.remove(interfaceName); |
| 207 | nwIncomingPackets.remove(interfaceName); |
| 208 | nwOutgoingPackets.remove(interfaceName); |
| 209 | |
| 210 | nwInterfaces.remove(interfaceName); |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Returns all device ids. |
| 215 | * |
| 216 | * @return a collection of device id |
| 217 | */ |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 218 | public Set<DeviceId> getDeviceIds() { |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 219 | return ImmutableSet.copyOf(this.deviceIds); |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Returns all disk partition names. |
| 224 | * |
| 225 | * @return a collection of disk partition. |
| 226 | */ |
| 227 | public Set<String> getDiskPartitions() { |
| 228 | return ImmutableSet.copyOf(this.diskPartitions); |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Returns all network interface names. |
| 233 | * |
| 234 | * @return a collection of network interface. |
| 235 | */ |
| 236 | public Set<String> getNetworkInterfaces() { |
| 237 | return ImmutableSet.copyOf(this.nwInterfaces); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Adds control metrics for all devices. |
| 242 | * |
| 243 | * @param deviceIds a set of deviceIds |
| 244 | */ |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 245 | public void addAllControlMessageMetrics(Set<DeviceId> deviceIds) { |
| 246 | deviceIds.forEach(v -> addControlMessageMetricsByDeviceId(v)); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Returns monitoring status. |
| 251 | * |
| 252 | * @return monitoring status |
| 253 | */ |
| 254 | public boolean isMonitor() { |
| 255 | return this.enableMonitor; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Enable control plane monitoring. |
| 260 | */ |
| 261 | protected void startMonitor() { |
| 262 | this.enableMonitor = true; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Disable control plane monitoring. |
| 267 | */ |
| 268 | protected void stopMonitor() { |
| 269 | this.enableMonitor = false; |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * Registers new control metrics. |
| 274 | */ |
| 275 | protected void registerMetrics() { |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 276 | /* CPU */ |
| 277 | cpuLoad = new MetricsAggregator(metricsService, ControlMetricType.CPU_LOAD); |
| 278 | totalCpuTime = new MetricsAggregator(metricsService, ControlMetricType.TOTAL_CPU_TIME); |
| 279 | sysCpuTime = new MetricsAggregator(metricsService, ControlMetricType.SYS_CPU_TIME); |
| 280 | userCpuTime = new MetricsAggregator(metricsService, ControlMetricType.USER_CPU_TIME); |
| 281 | cpuIdleTime = new MetricsAggregator(metricsService, ControlMetricType.CPU_IDLE_TIME); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 282 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 283 | /* Memory */ |
| 284 | memoryFree = new MetricsAggregator(metricsService, ControlMetricType.MEMORY_FREE); |
| 285 | memoryUsed = new MetricsAggregator(metricsService, ControlMetricType.MEMORY_USED); |
Jian Li | 7d180c5 | 2016-02-01 21:53:08 -0800 | [diff] [blame^] | 286 | memoryFreeRatio = new MetricsAggregator(metricsService, |
| 287 | ControlMetricType.MEMORY_FREE_RATIO); |
| 288 | memoryUsedRatio = new MetricsAggregator(metricsService, |
| 289 | ControlMetricType.MEMORY_USED_RATIO); |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 290 | |
| 291 | /* Disk I/O */ |
| 292 | diskReadBytes = new ConcurrentHashMap<>(); |
| 293 | diskWriteBytes = new ConcurrentHashMap<>(); |
| 294 | |
| 295 | /* Network I/O */ |
| 296 | nwIncomingBytes = new ConcurrentHashMap<>(); |
| 297 | nwOutgoingBytes = new ConcurrentHashMap<>(); |
| 298 | nwIncomingPackets = new ConcurrentHashMap<>(); |
| 299 | nwOutgoingPackets = new ConcurrentHashMap<>(); |
| 300 | |
| 301 | /* OpenFlow Messages */ |
| 302 | inboundPacket = new ConcurrentHashMap<>(); |
| 303 | outboundPacket = new ConcurrentHashMap<>(); |
| 304 | flowmodPacket = new ConcurrentHashMap<>(); |
| 305 | flowrmvPacket = new ConcurrentHashMap<>(); |
| 306 | requestPacket = new ConcurrentHashMap<>(); |
| 307 | replyPacket = new ConcurrentHashMap<>(); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Unregisters all control metrics. |
| 312 | */ |
| 313 | protected void unregisterMetrics() { |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 314 | /* Disk I/O */ |
| 315 | diskReadBytes.clear(); |
| 316 | diskWriteBytes.clear(); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 317 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 318 | /* Network I/O */ |
| 319 | nwIncomingBytes.clear(); |
| 320 | nwOutgoingBytes.clear(); |
| 321 | nwIncomingPackets.clear(); |
| 322 | nwOutgoingPackets.clear(); |
| 323 | |
| 324 | /* OpenFlow Message */ |
| 325 | inboundPacket.clear(); |
| 326 | outboundPacket.clear(); |
| 327 | flowmodPacket.clear(); |
| 328 | flowrmvPacket.clear(); |
| 329 | requestPacket.clear(); |
| 330 | replyPacket.clear(); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 331 | } |
| 332 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 333 | public MetricsAggregator cpuLoadMetric() { |
| 334 | return cpuLoad; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 335 | } |
| 336 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 337 | public MetricsAggregator totalCpuTimeMetric() { |
| 338 | return totalCpuTime; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 339 | } |
| 340 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 341 | public MetricsAggregator sysCpuTimeMetric() { |
| 342 | return sysCpuTime; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 343 | } |
| 344 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 345 | public MetricsAggregator userCpuTime() { |
| 346 | return userCpuTime; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 347 | } |
| 348 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 349 | public MetricsAggregator cpuIdleTime() { |
| 350 | return cpuIdleTime; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 351 | } |
| 352 | |
Jian Li | 7d180c5 | 2016-02-01 21:53:08 -0800 | [diff] [blame^] | 353 | public MetricsAggregator memoryFreeRatio() { |
| 354 | return memoryFreeRatio; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 355 | } |
| 356 | |
Jian Li | 7d180c5 | 2016-02-01 21:53:08 -0800 | [diff] [blame^] | 357 | public MetricsAggregator memoryUsedRatio() { |
| 358 | return memoryUsedRatio; |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 359 | } |
| 360 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 361 | public MetricsAggregator diskReadBytes(String partitionName) { |
| 362 | return diskReadBytes.get(partitionName); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 363 | } |
| 364 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 365 | public MetricsAggregator diskWriteBytes(String partitionName) { |
| 366 | return diskWriteBytes.get(partitionName); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 367 | } |
| 368 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 369 | public MetricsAggregator nwIncomingBytes(String interfaceName) { |
| 370 | return nwIncomingBytes.get(interfaceName); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 371 | } |
| 372 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 373 | public MetricsAggregator nwOutgoingBytes(String interfaceName) { |
| 374 | return nwOutgoingBytes.get(interfaceName); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 375 | } |
| 376 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 377 | public MetricsAggregator nwIncomingPackets(String interfaceName) { |
| 378 | return nwIncomingPackets.get(interfaceName); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 379 | } |
| 380 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 381 | public MetricsAggregator nwOutgoingPackets(String interfaceName) { |
| 382 | return nwOutgoingPackets.get(interfaceName); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 383 | } |
| 384 | |
Jian Li | e044d1a | 2016-01-25 09:01:20 -0800 | [diff] [blame] | 385 | public Map<DeviceId, MetricsAggregator> inboundPacket() { |
| 386 | return ImmutableMap.copyOf(inboundPacket); |
| 387 | } |
| 388 | |
| 389 | public Map<DeviceId, MetricsAggregator> outboundPacket() { |
| 390 | return ImmutableMap.copyOf(outboundPacket); |
| 391 | } |
| 392 | |
| 393 | public Map<DeviceId, MetricsAggregator> flowmodPacket() { |
| 394 | return ImmutableMap.copyOf(flowmodPacket); |
| 395 | } |
| 396 | |
| 397 | public Map<DeviceId, MetricsAggregator> flowrmvPacket() { |
| 398 | return ImmutableMap.copyOf(flowrmvPacket); |
| 399 | } |
| 400 | |
| 401 | public Map<DeviceId, MetricsAggregator> requestPacket() { |
| 402 | return ImmutableMap.copyOf(requestPacket); |
| 403 | } |
| 404 | |
| 405 | public Map<DeviceId, MetricsAggregator> replyPacket() { |
| 406 | return ImmutableMap.copyOf(replyPacket); |
| 407 | } |
| 408 | |
| 409 | public MetricsAggregator inboundPacket(DeviceId deviceId) { |
| 410 | return inboundPacket.get(deviceId); |
| 411 | } |
| 412 | |
| 413 | public MetricsAggregator outboundPacket(DeviceId deviceId) { |
| 414 | return outboundPacket.get(deviceId); |
| 415 | } |
| 416 | |
| 417 | public MetricsAggregator flowmodPacket(DeviceId deviceId) { |
| 418 | return flowmodPacket.get(deviceId); |
| 419 | } |
| 420 | |
| 421 | public MetricsAggregator flowrmvPacket(DeviceId deviceId) { |
| 422 | return flowrmvPacket.get(deviceId); |
| 423 | } |
| 424 | |
| 425 | public MetricsAggregator requestPacket(DeviceId deviceId) { |
| 426 | return requestPacket.get(deviceId); |
| 427 | } |
| 428 | |
| 429 | public MetricsAggregator replyPacket(DeviceId deviceId) { |
| 430 | return replyPacket.get(deviceId); |
Jian Li | 6080432 | 2015-12-02 14:46:31 -0800 | [diff] [blame] | 431 | } |
| 432 | } |