BUG-2757 : Adding cookie as a comparison element for flow comparison 42/18442/2
authorAnil Vishnoi <vishnoianil@gmail.com>
Thu, 16 Apr 2015 13:16:47 +0000 (18:46 +0530)
committerAnil Vishnoi <vishnoianil@gmail.com>
Thu, 16 Apr 2015 18:17:19 +0000 (18:17 +0000)
If application installs two flows that are different only by the match extension they use,
second flow will match the first flow, because we don't use match
extensions for flow comparison.To include match extension in flow
comparison require quite a bit work, which can not be done in this
release. I am adding flow cookie also in flow comparison, so that
apps who are using extensions can use that to differentiate two flows
that matches if extension is excluded.If applications don't use it,
 or use same cookie, it won't impact the existing working of statistics manager.

Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/helper/FlowComparator.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/helper/FlowComparatorFactory.java

index ebd89c9b9c87f462d81d4dfbe19f036e98e1623e..489d2f9657d29078d3a23b8b4e27a864d22bb4a1 100644 (file)
@@ -24,6 +24,7 @@ public final class FlowComparator {
         FLOW_COMPARATORS.add(FlowComparatorFactory.createPriority());
         FLOW_COMPARATORS.add(FlowComparatorFactory.createTableId());
         FLOW_COMPARATORS.add(FlowComparatorFactory.createContainerName());
+        FLOW_COMPARATORS.add(FlowComparatorFactory.createCookie());
         FLOW_COMPARATORS.add(FlowComparatorFactory.createMatch());
     }
 
index fda7001cd81e8e490986728d420fe6655dd80527..20c65346651e1a96960eee43edac65bb27691bba 100644 (file)
@@ -91,6 +91,25 @@ public final class FlowComparatorFactory {
         };
     }
 
+    public static SimpleComparator<Flow> createCookie() {
+        return new SimpleComparator<Flow>() {
+            /**
+             * Compares flows by cookie value
+             */
+            @Override
+            public boolean areObjectsEqual(final Flow statsFlow, final Flow storedFlow) {
+                if (statsFlow.getCookie() == null) {
+                    if (storedFlow.getCookie() != null) {
+                        return false;
+                    }
+                } else if (!statsFlow.getCookie().equals(storedFlow.getCookie())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
     public static SimpleComparator<Flow> createMatch() {
         return new SimpleComparator<Flow>() {
             /**