Brian O'Connor
Committed by Gerrit Code Review

ONOS-3023 Changing flowTable sets to map so that we can compare

stored vs. new rule when adding and removing

Change-Id: Ibd885023d550af3b2220056fbdf44ad8ec7fefda
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.net.flow; 16 package org.onosproject.net.flow;
17 17
18 +import com.google.common.annotations.Beta;
18 import org.onosproject.core.ApplicationId; 19 import org.onosproject.core.ApplicationId;
19 import org.onosproject.core.DefaultGroupId; 20 import org.onosproject.core.DefaultGroupId;
20 import org.onosproject.core.GroupId; 21 import org.onosproject.core.GroupId;
...@@ -284,6 +285,11 @@ public class DefaultFlowRule implements FlowRule { ...@@ -284,6 +285,11 @@ public class DefaultFlowRule implements FlowRule {
284 return tableId; 285 return tableId;
285 } 286 }
286 287
288 + @Beta
289 + public long created() {
290 + return created;
291 + }
292 +
287 public static Builder builder() { 293 public static Builder builder() {
288 return new Builder(); 294 return new Builder();
289 } 295 }
......
...@@ -220,6 +220,7 @@ public class SimpleFlowRuleStore ...@@ -220,6 +220,7 @@ public class SimpleFlowRuleStore
220 for (StoredFlowEntry stored : entries) { 220 for (StoredFlowEntry stored : entries) {
221 if (stored.equals(rule)) { 221 if (stored.equals(rule)) {
222 synchronized (stored) { 222 synchronized (stored) {
223 + //FIXME modification of "stored" flow entry outside of flow table
223 stored.setBytes(rule.bytes()); 224 stored.setBytes(rule.bytes());
224 stored.setLife(rule.life()); 225 stored.setLife(rule.life());
225 stored.setPackets(rule.packets()); 226 stored.setPackets(rule.packets());
......
...@@ -311,6 +311,7 @@ public class FlowRuleManager ...@@ -311,6 +311,7 @@ public class FlowRuleManager
311 } catch (UnsupportedOperationException e) { 311 } catch (UnsupportedOperationException e) {
312 log.warn(e.getMessage()); 312 log.warn(e.getMessage());
313 if (flowRule instanceof DefaultFlowEntry) { 313 if (flowRule instanceof DefaultFlowEntry) {
314 + //FIXME modification of "stored" flow entry outside of store
314 ((DefaultFlowEntry) flowRule).setState(FlowEntry.FlowEntryState.FAILED); 315 ((DefaultFlowEntry) flowRule).setState(FlowEntry.FlowEntryState.FAILED);
315 } 316 }
316 } 317 }
...@@ -323,10 +324,8 @@ public class FlowRuleManager ...@@ -323,10 +324,8 @@ public class FlowRuleManager
323 log.debug("Flow {} removed", flowRule); 324 log.debug("Flow {} removed", flowRule);
324 post(event); 325 post(event);
325 } 326 }
326 -
327 } 327 }
328 328
329 -
330 private void extraneousFlow(FlowRule flowRule) { 329 private void extraneousFlow(FlowRule flowRule) {
331 checkNotNull(flowRule, FLOW_RULE_NULL); 330 checkNotNull(flowRule, FLOW_RULE_NULL);
332 checkValidity(); 331 checkValidity();
...@@ -335,13 +334,11 @@ public class FlowRuleManager ...@@ -335,13 +334,11 @@ public class FlowRuleManager
335 log.debug("Flow {} is on switch but not in store.", flowRule); 334 log.debug("Flow {} is on switch but not in store.", flowRule);
336 } 335 }
337 336
338 -
339 private void flowAdded(FlowEntry flowEntry) { 337 private void flowAdded(FlowEntry flowEntry) {
340 checkNotNull(flowEntry, FLOW_RULE_NULL); 338 checkNotNull(flowEntry, FLOW_RULE_NULL);
341 checkValidity(); 339 checkValidity();
342 340
343 if (checkRuleLiveness(flowEntry, store.getFlowEntry(flowEntry))) { 341 if (checkRuleLiveness(flowEntry, store.getFlowEntry(flowEntry))) {
344 -
345 FlowRuleEvent event = store.addOrUpdateFlowRule(flowEntry); 342 FlowRuleEvent event = store.addOrUpdateFlowRule(flowEntry);
346 if (event == null) { 343 if (event == null) {
347 log.debug("No flow store event generated."); 344 log.debug("No flow store event generated.");
...@@ -353,7 +350,6 @@ public class FlowRuleManager ...@@ -353,7 +350,6 @@ public class FlowRuleManager
353 log.debug("Removing flow rules...."); 350 log.debug("Removing flow rules....");
354 removeFlowRules(flowEntry); 351 removeFlowRules(flowEntry);
355 } 352 }
356 -
357 } 353 }
358 354
359 private boolean checkRuleLiveness(FlowEntry swRule, FlowEntry storedRule) { 355 private boolean checkRuleLiveness(FlowEntry swRule, FlowEntry storedRule) {
......
...@@ -269,23 +269,19 @@ public class FlowRuleManagerTest { ...@@ -269,23 +269,19 @@ public class FlowRuleManagerTest {
269 269
270 @Test 270 @Test
271 public void flowRemoved() { 271 public void flowRemoved() {
272 -
273 FlowRule f1 = addFlowRule(1); 272 FlowRule f1 = addFlowRule(1);
274 FlowRule f2 = addFlowRule(2); 273 FlowRule f2 = addFlowRule(2);
275 StoredFlowEntry fe1 = new DefaultFlowEntry(f1); 274 StoredFlowEntry fe1 = new DefaultFlowEntry(f1);
276 FlowEntry fe2 = new DefaultFlowEntry(f2); 275 FlowEntry fe2 = new DefaultFlowEntry(f2);
277 276
278 -
279 providerService.pushFlowMetrics(DID, ImmutableList.of(fe1, fe2)); 277 providerService.pushFlowMetrics(DID, ImmutableList.of(fe1, fe2));
280 service.removeFlowRules(f1); 278 service.removeFlowRules(f1);
281 279
280 + //FIXME modification of "stored" flow entry outside of store
282 fe1.setState(FlowEntryState.REMOVED); 281 fe1.setState(FlowEntryState.REMOVED);
283 282
284 -
285 -
286 providerService.flowRemoved(fe1); 283 providerService.flowRemoved(fe1);
287 284
288 -
289 validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, 285 validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED,
290 RULE_ADDED, RULE_REMOVE_REQUESTED, RULE_REMOVED); 286 RULE_ADDED, RULE_REMOVE_REQUESTED, RULE_REMOVED);
291 287
...@@ -301,7 +297,6 @@ public class FlowRuleManagerTest { ...@@ -301,7 +297,6 @@ public class FlowRuleManagerTest {
301 297
302 providerService.flowRemoved(fe3); 298 providerService.flowRemoved(fe3);
303 validateEvents(); 299 validateEvents();
304 -
305 } 300 }
306 301
307 @Test 302 @Test
......
...@@ -416,6 +416,7 @@ public class NewAdaptiveFlowStatsCollector { ...@@ -416,6 +416,7 @@ public class NewAdaptiveFlowStatsCollector {
416 + " AdaptiveStats collection thread for {}", 416 + " AdaptiveStats collection thread for {}",
417 sw.getStringId()); 417 sw.getStringId());
418 418
419 + //FIXME modification of "stored" flow entry outside of store
419 stored.setLastSeen(); 420 stored.setLastSeen();
420 continue; 421 continue;
421 } else if (fe.life() < stored.life()) { 422 } else if (fe.life() < stored.life()) {
...@@ -428,11 +429,13 @@ public class NewAdaptiveFlowStatsCollector { ...@@ -428,11 +429,13 @@ public class NewAdaptiveFlowStatsCollector {
428 ", new life=" + fe.life() + ", old life=" + stored.life() + 429 ", new life=" + fe.life() + ", old life=" + stored.life() +
429 ", new lastSeen=" + fe.lastSeen() + ", old lastSeen=" + stored.lastSeen()); 430 ", new lastSeen=" + fe.lastSeen() + ", old lastSeen=" + stored.lastSeen());
430 // go next 431 // go next
432 + //FIXME modification of "stored" flow entry outside of store
431 stored.setLastSeen(); 433 stored.setLastSeen();
432 continue; 434 continue;
433 } 435 }
434 436
435 // update now 437 // update now
438 + //FIXME modification of "stored" flow entry outside of store
436 stored.setLife(fe.life()); 439 stored.setLife(fe.life());
437 stored.setPackets(fe.packets()); 440 stored.setPackets(fe.packets());
438 stored.setBytes(fe.bytes()); 441 stored.setBytes(fe.bytes());
......