Fixing OF device provider to accrue all port stat multi-part messages before pus…
…hing update to the core. Change-Id: Ib5792ffbf4be2e50e30ab6ed14149337b7e545d6
Showing
1 changed file
with
16 additions
and
5 deletions
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | package org.onosproject.provider.of.device.impl; | 16 | package org.onosproject.provider.of.device.impl; |
| 17 | 17 | ||
| 18 | import com.google.common.base.Strings; | 18 | import com.google.common.base.Strings; |
| 19 | +import com.google.common.collect.Lists; | ||
| 19 | import com.google.common.collect.Maps; | 20 | import com.google.common.collect.Maps; |
| 20 | import com.google.common.collect.Sets; | 21 | import com.google.common.collect.Sets; |
| 21 | import org.apache.felix.scr.annotations.Activate; | 22 | import org.apache.felix.scr.annotations.Activate; |
| ... | @@ -63,6 +64,7 @@ import org.projectfloodlight.openflow.protocol.OFPortStatsEntry; | ... | @@ -63,6 +64,7 @@ import org.projectfloodlight.openflow.protocol.OFPortStatsEntry; |
| 63 | import org.projectfloodlight.openflow.protocol.OFPortStatsReply; | 64 | import org.projectfloodlight.openflow.protocol.OFPortStatsReply; |
| 64 | import org.projectfloodlight.openflow.protocol.OFPortStatus; | 65 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
| 65 | import org.projectfloodlight.openflow.protocol.OFStatsReply; | 66 | import org.projectfloodlight.openflow.protocol.OFStatsReply; |
| 67 | +import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags; | ||
| 66 | import org.projectfloodlight.openflow.protocol.OFStatsType; | 68 | import org.projectfloodlight.openflow.protocol.OFStatsType; |
| 67 | import org.projectfloodlight.openflow.protocol.OFVersion; | 69 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 68 | import org.projectfloodlight.openflow.types.PortSpeed; | 70 | import org.projectfloodlight.openflow.types.PortSpeed; |
| ... | @@ -200,16 +202,17 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -200,16 +202,17 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 200 | LOG.info("Accepting mastership role change for device {}", deviceId); | 202 | LOG.info("Accepting mastership role change for device {}", deviceId); |
| 201 | } | 203 | } |
| 202 | 204 | ||
| 203 | - private void pushPortMetrics(Dpid dpid, OFPortStatsReply msg) { | 205 | + private void pushPortMetrics(Dpid dpid, List<OFPortStatsEntry> portStatsEntries) { |
| 204 | DeviceId deviceId = DeviceId.deviceId(dpid.uri(dpid)); | 206 | DeviceId deviceId = DeviceId.deviceId(dpid.uri(dpid)); |
| 205 | - Collection<PortStatistics> stats = buildPortStatistics(deviceId, msg); | 207 | + Collection<PortStatistics> stats = buildPortStatistics(deviceId, portStatsEntries); |
| 206 | providerService.updatePortStatistics(deviceId, stats); | 208 | providerService.updatePortStatistics(deviceId, stats); |
| 207 | } | 209 | } |
| 208 | 210 | ||
| 209 | - private Collection<PortStatistics> buildPortStatistics(DeviceId deviceId, OFPortStatsReply msg) { | 211 | + private Collection<PortStatistics> buildPortStatistics(DeviceId deviceId, |
| 212 | + List<OFPortStatsEntry> entries) { | ||
| 210 | HashSet<PortStatistics> stats = Sets.newHashSet(); | 213 | HashSet<PortStatistics> stats = Sets.newHashSet(); |
| 211 | 214 | ||
| 212 | - for (OFPortStatsEntry entry: msg.getEntries()) { | 215 | + for (OFPortStatsEntry entry : entries) { |
| 213 | try { | 216 | try { |
| 214 | if (entry.getPortNo().getPortNumber() < 0) { | 217 | if (entry.getPortNo().getPortNumber() < 0) { |
| 215 | continue; | 218 | continue; |
| ... | @@ -240,6 +243,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -240,6 +243,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 240 | } | 243 | } |
| 241 | 244 | ||
| 242 | private class InternalDeviceProvider implements OpenFlowSwitchListener, OpenFlowEventListener { | 245 | private class InternalDeviceProvider implements OpenFlowSwitchListener, OpenFlowEventListener { |
| 246 | + | ||
| 247 | + private List<OFPortStatsEntry> portStatsReplies = Lists.newArrayList(); | ||
| 248 | + | ||
| 243 | @Override | 249 | @Override |
| 244 | public void switchAdded(Dpid dpid) { | 250 | public void switchAdded(Dpid dpid) { |
| 245 | if (providerService == null) { | 251 | if (providerService == null) { |
| ... | @@ -442,7 +448,12 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -442,7 +448,12 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 442 | switch (msg.getType()) { | 448 | switch (msg.getType()) { |
| 443 | case STATS_REPLY: | 449 | case STATS_REPLY: |
| 444 | if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) { | 450 | if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) { |
| 445 | - pushPortMetrics(dpid, (OFPortStatsReply) msg); | 451 | + OFPortStatsReply portStatsReply = (OFPortStatsReply) msg; |
| 452 | + portStatsReplies.addAll(portStatsReply.getEntries()); | ||
| 453 | + if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) { | ||
| 454 | + pushPortMetrics(dpid, portStatsReplies); | ||
| 455 | + portStatsReplies.clear(); | ||
| 456 | + } | ||
| 446 | } | 457 | } |
| 447 | break; | 458 | break; |
| 448 | default: | 459 | default: | ... | ... |
-
Please register or login to post a comment