ONOS dont give QUEUE stats like other stats message (portstats etc.). I modified OpenFlowControllerImpl for this development.
Change-Id: I36b2cd494ea78c1a4ca2ca4426810bfdb4b0d697
diff --git a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
index 21f2c0f..474f824 100644
--- a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
+++ b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
@@ -89,6 +89,9 @@
import static org.onosproject.net.Device.Type.CONTROLLER;
import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED;
import static org.onosproject.openflow.controller.Dpid.dpid;
+import org.projectfloodlight.openflow.protocol.OFQueueStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFQueueStatsReply;
+
@Component(immediate = true)
@Service
@@ -171,6 +174,9 @@
protected Multimap<Dpid, OFPortStatsEntry> fullPortStats =
ArrayListMultimap.create();
+ protected Multimap<Dpid, OFQueueStatsEntry> fullQueueStats =
+ ArrayListMultimap.create();
+
private final Controller ctrl = new Controller();
private InternalDeviceListener listener = new InternalDeviceListener();
@@ -297,12 +303,14 @@
return future;
}
+ // CHECKSTYLE IGNORE MethodLength FOR NEXT 300 LINES
@Override
public void processPacket(Dpid dpid, OFMessage msg) {
Collection<OFFlowStatsEntry> flowStats;
Collection<OFTableStatsEntry> tableStats;
Collection<OFGroupStatsEntry> groupStats;
Collection<OFGroupDescStatsEntry> groupDescStats;
+ Collection<OFQueueStatsEntry> queueStatsEntries;
OpenFlowSwitch sw = this.getSwitch(dpid);
@@ -332,7 +340,7 @@
break;
}
OpenFlowPacketContext pktCtx = DefaultOpenFlowPacketContext
- .packetContextFromPacketIn(sw, (OFPacketIn) msg);
+ .packetContextFromPacketIn(sw, (OFPacketIn) msg);
for (PacketListener p : ofPacketListener.values()) {
p.handlePacket(pktCtx);
}
@@ -350,6 +358,16 @@
case STATS_REPLY:
OFStatsReply reply = (OFStatsReply) msg;
switch (reply.getStatsType()) {
+ case QUEUE:
+ queueStatsEntries = publishQueueStats(dpid, (OFQueueStatsReply) reply);
+ if (queueStatsEntries != null) {
+ OFQueueStatsReply.Builder rep =
+ OFFactories.getFactory(msg.getVersion()).buildQueueStatsReply();
+ rep.setEntries(Lists.newLinkedList(queueStatsEntries));
+ rep.setXid(reply.getXid());
+ executorMsgs.execute(new OFMessageHandler(dpid, rep.build()));
+ }
+ break;
case PORT_DESC:
for (OpenFlowSwitchListener l : ofSwitchListener) {
l.switchChanged(dpid);
@@ -546,6 +564,14 @@
return null;
}
+ private synchronized Collection<OFQueueStatsEntry> publishQueueStats(Dpid dpid, OFQueueStatsReply reply) {
+ fullQueueStats.putAll(dpid, reply.getEntries());
+ if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+ return fullQueueStats.removeAll(dpid);
+ }
+ return null;
+ }
+
@Override
public void setRole(Dpid dpid, RoleState role) {
final OpenFlowSwitch sw = getSwitch(dpid);