Using the value in the installedSwView data structure to populate 36/3036/4
authorAsad Ahmed <asaahmed@cisco.com>
Sat, 23 Nov 2013 19:02:46 +0000 (11:02 -0800)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 3 Dec 2013 06:05:02 +0000 (06:05 +0000)
the node flows and group flows data structures

Change-Id: I52261e1e3ca8490f074d5fbed5a5563546b8cd01
Signed-off-by: Asad Ahmed <asaahmed@cisco.com>
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java

index e639d41e8e1ea819fa4c56fb4fbbfbc3c481af28..45fb11a83eda110b96b1588dd43b0c8fd6c7b164 100644 (file)
@@ -847,6 +847,17 @@ public class ForwardingRulesManager implements
         }
 
         if (add) {
+            // there may be an already existing entry.
+            // remove it before adding the new one.
+            // This is necessary since we have observed that in some cases
+            // Infinispan does aggregation for operations (eg:- remove and then put a different value)
+            // related to the same key within the same transaction.
+            // Need this defensive code as the new FlowEntryInstall may be different
+            // than the old one even though the equals method returns true. This is because
+            // the equals method does not take into account the action list.
+            if(nodeIndeces.contains(flowEntries)) {
+                nodeIndeces.remove(flowEntries);
+            }
             nodeIndeces.add(flowEntries);
         } else {
             nodeIndeces.remove(flowEntries);
@@ -881,6 +892,11 @@ public class ForwardingRulesManager implements
         }
 
         if (add) {
+            // same comments in the similar code section in
+            // updateNodeFlowsDB method apply here too
+            if(indices.contains(flowEntries)) {
+                indices.remove(flowEntries);
+            }
             indices.add(flowEntries);
         } else {
             indices.remove(flowEntries);
@@ -1215,7 +1231,7 @@ public class ForwardingRulesManager implements
         if (policyName != null && !policyName.trim().isEmpty()) {
             for (Map.Entry<FlowEntry, FlowEntry> entry : this.originalSwView.entrySet()) {
                 if (policyName.equals(entry.getKey().getGroupName())) {
-                    list.add(entry.getKey().clone());
+                    list.add(entry.getValue().clone());
                 }
             }
         }
@@ -1228,7 +1244,7 @@ public class ForwardingRulesManager implements
         if (policyName != null && !policyName.trim().isEmpty()) {
             for (Map.Entry<FlowEntryInstall, FlowEntryInstall> entry : this.installedSwView.entrySet()) {
                 if (policyName.equals(entry.getKey().getGroupName())) {
-                    list.add(entry.getKey().getInstall().clone());
+                    list.add(entry.getValue().getInstall().clone());
                 }
             }
         }
@@ -2610,7 +2626,7 @@ public class ForwardingRulesManager implements
 
         // replay the installedSwView data structure to populate
         // node flows and group flows
-        for (FlowEntryInstall fei : installedSwView.keySet()) {
+        for (FlowEntryInstall fei : installedSwView.values()) {
             pendingEvents.offer(new UpdateIndexDBs(fei, true));
         }
 
@@ -3031,7 +3047,7 @@ public class ForwardingRulesManager implements
          * Streamline the updates for the per node and per group index databases
          */
         if (cacheName.equals(INSTALLED_SW_VIEW_CACHE)) {
-            pendingEvents.offer(new UpdateIndexDBs((FlowEntryInstall)key, true));
+            pendingEvents.offer(new UpdateIndexDBs((FlowEntryInstall)new_value, true));
         }
 
         if (originLocal) {
@@ -3101,7 +3117,7 @@ public class ForwardingRulesManager implements
         if (node != null) {
             for (Map.Entry<FlowEntry, FlowEntry> entry : this.originalSwView.entrySet()) {
                 if (node.equals(entry.getKey().getNode())) {
-                    list.add(entry.getKey().clone());
+                    list.add(entry.getValue().clone());
                 }
             }
         }
index b8f776fc176d49085487d556dcd4e11a353751cd..2c3cfb8303736229e6c86b618642f6bd72b12aaa 100644 (file)
@@ -483,6 +483,13 @@ public class Match implements Cloneable, Serializable {
 
     @Override
     public String toString() {
-        return "Match[" + fields.values() + "]";
+        StringBuilder builder = new StringBuilder();
+        builder.append("Match [fields=");
+        builder.append(fields);
+        builder.append(", matches=");
+        builder.append(matches);
+        builder.append("]");
+        return builder.toString();
     }
+
 }