alshabib

supporting multipart stats replies: tested upto 15K rules

Change-Id: I36fbd99d012a74c1f5240f37b60d3b58be85626c
1 package org.onlab.onos.cluster; 1 package org.onlab.onos.cluster;
2 2
3 -import org.onlab.onos.net.MastershipRole;
4 import org.onlab.onos.net.provider.Provider; 3 import org.onlab.onos.net.provider.Provider;
5 4
6 /** 5 /**
......
...@@ -150,7 +150,7 @@ public class DefaultFlowRule implements FlowRule { ...@@ -150,7 +150,7 @@ public class DefaultFlowRule implements FlowRule {
150 if (this == obj) { 150 if (this == obj) {
151 return true; 151 return true;
152 } 152 }
153 - if (obj instanceof FlowRule) { 153 + if (obj instanceof DefaultFlowRule) {
154 DefaultFlowRule that = (DefaultFlowRule) obj; 154 DefaultFlowRule that = (DefaultFlowRule) obj;
155 return Objects.equals(deviceId, that.deviceId) && 155 return Objects.equals(deviceId, that.deviceId) &&
156 Objects.equals(id, that.id); 156 Objects.equals(id, that.id);
......
...@@ -138,7 +138,7 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -138,7 +138,7 @@ implements FlowRuleService, FlowRuleProviderRegistry {
138 public void flowMissing(FlowRule flowRule) { 138 public void flowMissing(FlowRule flowRule) {
139 checkNotNull(flowRule, FLOW_RULE_NULL); 139 checkNotNull(flowRule, FLOW_RULE_NULL);
140 checkValidity(); 140 checkValidity();
141 - log.info("Flow {} has not been installed.", flowRule); 141 + log.debug("Flow {} has not been installed.", flowRule);
142 142
143 } 143 }
144 144
...@@ -146,7 +146,7 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -146,7 +146,7 @@ implements FlowRuleService, FlowRuleProviderRegistry {
146 public void extraneousFlow(FlowRule flowRule) { 146 public void extraneousFlow(FlowRule flowRule) {
147 checkNotNull(flowRule, FLOW_RULE_NULL); 147 checkNotNull(flowRule, FLOW_RULE_NULL);
148 checkValidity(); 148 checkValidity();
149 - log.info("Flow {} is on switch but not in store.", flowRule); 149 + log.debug("Flow {} is on switch but not in store.", flowRule);
150 } 150 }
151 151
152 @Override 152 @Override
...@@ -188,8 +188,10 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -188,8 +188,10 @@ implements FlowRuleService, FlowRuleProviderRegistry {
188 } 188 }
189 } 189 }
190 for (FlowRule rule : storedRules) { 190 for (FlowRule rule : storedRules) {
191 +
191 // there are rules in the store that aren't on the switch 192 // there are rules in the store that aren't on the switch
192 flowMissing(rule); 193 flowMissing(rule);
194 +
193 } 195 }
194 } 196 }
195 } 197 }
......
...@@ -79,8 +79,6 @@ public class FlowModBuilder { ...@@ -79,8 +79,6 @@ public class FlowModBuilder {
79 .setActions(actions) 79 .setActions(actions)
80 .setMatch(match) 80 .setMatch(match)
81 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM)) 81 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
82 - .setIdleTimeout(10)
83 - .setHardTimeout(10)
84 .setPriority(priority) 82 .setPriority(priority)
85 .build(); 83 .build();
86 84
...@@ -98,8 +96,6 @@ public class FlowModBuilder { ...@@ -98,8 +96,6 @@ public class FlowModBuilder {
98 .setActions(actions) 96 .setActions(actions)
99 .setMatch(match) 97 .setMatch(match)
100 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM)) 98 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
101 - .setIdleTimeout(10)
102 - .setHardTimeout(10)
103 .setPriority(priority) 99 .setPriority(priority)
104 .build(); 100 .build();
105 101
......
...@@ -2,7 +2,6 @@ package org.onlab.onos.provider.of.flow.impl; ...@@ -2,7 +2,6 @@ package org.onlab.onos.provider.of.flow.impl;
2 2
3 import static org.slf4j.LoggerFactory.getLogger; 3 import static org.slf4j.LoggerFactory.getLogger;
4 4
5 -import java.util.List;
6 import java.util.Map; 5 import java.util.Map;
7 6
8 import org.apache.felix.scr.annotations.Activate; 7 import org.apache.felix.scr.annotations.Activate;
...@@ -29,11 +28,13 @@ import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; ...@@ -29,11 +28,13 @@ import org.projectfloodlight.openflow.protocol.OFFlowStatsReply;
29 import org.projectfloodlight.openflow.protocol.OFMessage; 28 import org.projectfloodlight.openflow.protocol.OFMessage;
30 import org.projectfloodlight.openflow.protocol.OFPortStatus; 29 import org.projectfloodlight.openflow.protocol.OFPortStatus;
31 import org.projectfloodlight.openflow.protocol.OFStatsReply; 30 import org.projectfloodlight.openflow.protocol.OFStatsReply;
31 +import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
32 import org.projectfloodlight.openflow.protocol.OFStatsType; 32 import org.projectfloodlight.openflow.protocol.OFStatsType;
33 import org.slf4j.Logger; 33 import org.slf4j.Logger;
34 34
35 -import com.google.common.collect.Lists; 35 +import com.google.common.collect.ArrayListMultimap;
36 import com.google.common.collect.Maps; 36 import com.google.common.collect.Maps;
37 +import com.google.common.collect.Multimap;
37 38
38 /** 39 /**
39 * Provider which uses an OpenFlow controller to detect network 40 * Provider which uses an OpenFlow controller to detect network
...@@ -114,6 +115,8 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -114,6 +115,8 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
114 implements OpenFlowSwitchListener, OpenFlowEventListener { 115 implements OpenFlowSwitchListener, OpenFlowEventListener {
115 116
116 private final Map<Dpid, FlowStatsCollector> collectors = Maps.newHashMap(); 117 private final Map<Dpid, FlowStatsCollector> collectors = Maps.newHashMap();
118 + private final Multimap<DeviceId, FlowRule> completeEntries =
119 + ArrayListMultimap.create();
117 120
118 @Override 121 @Override
119 public void switchAdded(Dpid dpid) { 122 public void switchAdded(Dpid dpid) {
...@@ -153,17 +156,24 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -153,17 +156,24 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
153 156
154 } 157 }
155 158
156 - private void pushFlowMetrics(Dpid dpid, OFStatsReply stats) { 159 + private synchronized void pushFlowMetrics(Dpid dpid, OFStatsReply stats) {
157 if (stats.getStatsType() != OFStatsType.FLOW) { 160 if (stats.getStatsType() != OFStatsType.FLOW) {
158 return; 161 return;
159 } 162 }
163 + DeviceId did = DeviceId.deviceId(Dpid.uri(dpid));
160 final OFFlowStatsReply replies = (OFFlowStatsReply) stats; 164 final OFFlowStatsReply replies = (OFFlowStatsReply) stats;
161 - final List<FlowRule> entries = Lists.newLinkedList(); 165 + //final List<FlowRule> entries = Lists.newLinkedList();
166 +
162 for (OFFlowStatsEntry reply : replies.getEntries()) { 167 for (OFFlowStatsEntry reply : replies.getEntries()) {
163 - entries.add(new FlowRuleBuilder(dpid, reply).build()); 168 + completeEntries.put(did, new FlowRuleBuilder(dpid, reply).build());
169 + //entries.add(new FlowRuleBuilder(dpid, reply).build());
170 + }
171 +
172 + if (!stats.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
173 + log.debug("sending flowstats to core {}", completeEntries.get(did));
174 + providerService.pushFlowMetrics(did, completeEntries.get(did));
175 + completeEntries.removeAll(did);
164 } 176 }
165 - log.debug("sending flowstats to core {}", entries);
166 - providerService.pushFlowMetrics(DeviceId.deviceId(Dpid.uri(dpid)), entries);
167 } 177 }
168 178
169 } 179 }
......