sangho
Committed by Gerrit Code Review

ONOS-1160: Bug fix for sending groups stats also for non OF1.3 switches.

Change-Id: I5dd75d23aaf2a22f084a8ad7d91b402a869da038
...@@ -54,6 +54,7 @@ import org.projectfloodlight.openflow.protocol.OFMessage; ...@@ -54,6 +54,7 @@ import org.projectfloodlight.openflow.protocol.OFMessage;
54 import org.projectfloodlight.openflow.protocol.OFPortStatus; 54 import org.projectfloodlight.openflow.protocol.OFPortStatus;
55 import org.projectfloodlight.openflow.protocol.OFStatsReply; 55 import org.projectfloodlight.openflow.protocol.OFStatsReply;
56 import org.projectfloodlight.openflow.protocol.OFStatsType; 56 import org.projectfloodlight.openflow.protocol.OFStatsType;
57 +import org.projectfloodlight.openflow.protocol.OFVersion;
57 import org.slf4j.Logger; 58 import org.slf4j.Logger;
58 59
59 import java.util.Collection; 60 import java.util.Collection;
...@@ -106,9 +107,11 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv ...@@ -106,9 +107,11 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
106 controller.addEventListener(listener); 107 controller.addEventListener(listener);
107 108
108 for (OpenFlowSwitch sw : controller.getSwitches()) { 109 for (OpenFlowSwitch sw : controller.getSwitches()) {
109 - GroupStatsCollector gsc = new GroupStatsCollector(sw, POLL_INTERVAL); 110 + if (isGroupSupported(sw)) {
110 - gsc.start(); 111 + GroupStatsCollector gsc = new GroupStatsCollector(sw, POLL_INTERVAL);
111 - collectors.put(new Dpid(sw.getId()), gsc); 112 + gsc.start();
113 + collectors.put(new Dpid(sw.getId()), gsc);
114 + }
112 } 115 }
113 116
114 log.info("Started"); 117 log.info("Started");
...@@ -257,6 +260,16 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv ...@@ -257,6 +260,16 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
257 return XID_COUNTER.getAndAdd(increase); 260 return XID_COUNTER.getAndAdd(increase);
258 } 261 }
259 262
263 + private boolean isGroupSupported(OpenFlowSwitch sw) {
264 + if (sw.factory().getVersion() == OFVersion.OF_10 ||
265 + sw.factory().getVersion() == OFVersion.OF_11 ||
266 + sw.factory().getVersion() == OFVersion.OF_12) {
267 + return false;
268 + }
269 +
270 + return true;
271 + }
272 +
260 private class InternalGroupProvider 273 private class InternalGroupProvider
261 implements OpenFlowSwitchListener, OpenFlowEventListener { 274 implements OpenFlowSwitchListener, OpenFlowEventListener {
262 275
...@@ -303,10 +316,13 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv ...@@ -303,10 +316,13 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
303 316
304 @Override 317 @Override
305 public void switchAdded(Dpid dpid) { 318 public void switchAdded(Dpid dpid) {
306 - GroupStatsCollector gsc = new GroupStatsCollector( 319 + OpenFlowSwitch sw = controller.getSwitch(dpid);
307 - controller.getSwitch(dpid), POLL_INTERVAL); 320 + if (isGroupSupported(sw)) {
308 - gsc.start(); 321 + GroupStatsCollector gsc = new GroupStatsCollector(
309 - collectors.put(dpid, gsc); 322 + controller.getSwitch(dpid), POLL_INTERVAL);
323 + gsc.start();
324 + collectors.put(dpid, gsc);
325 + }
310 } 326 }
311 327
312 @Override 328 @Override
......