Bug 5208 - flows don't get removed on update 63/33963/5
authorTomas Cechvala <tcechval@cisco.com>
Wed, 3 Feb 2016 11:17:53 +0000 (12:17 +0100)
committerTomas Cechvala <tcechval@cisco.com>
Mon, 8 Feb 2016 08:54:24 +0000 (08:54 +0000)
Fixed by ensuring that the current state of flow tables is overriden
only after the DS was updated.

Signed-off-by: Tomas Cechvala <tcechval@cisco.com>
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/PolicyManager.java

index d0277afa8c9e7a4ee520f2fc9fa07a9d826bca9c..ec2e9b589a0eb14004bb3d82eb9024924ba1a89f 100755 (executable)
@@ -78,7 +78,6 @@ public class PolicyManager
     private static final Logger LOG =
             LoggerFactory.getLogger(PolicyManager.class);
 
-    private Map<InstanceIdentifier<Table>, TableBuilder> actualGbpFlows = new HashMap<>();
     private Map<InstanceIdentifier<Table>, TableBuilder> previousGbpFlows  = new HashMap<>();
 
     private short tableOffset;
@@ -349,11 +348,6 @@ public class PolicyManager
     private void scheduleUpdate() {
         if (switchManager != null) {
             LOG.trace("Scheduling flow update task");
-
-            // Mark all existing flows as previous - will be compared with new ones
-            previousGbpFlows = actualGbpFlows;
-            actualGbpFlows = new HashMap<>();
-
             flowUpdateTask.reschedule(FLOW_UPDATE_DELAY, TimeUnit.MILLISECONDS);
         }
     }
@@ -409,7 +403,9 @@ public class PolicyManager
                 ecs.take().get();
                 // Current gbp flow must be independent, find out where this run() ends,
                 // set flows to one field and reset another
+                Map<InstanceIdentifier<Table>, TableBuilder> actualGbpFlows = new HashMap<>();
                 actualGbpFlows.putAll(ofWriter.commitToDataStore(dataBroker, previousGbpFlows));
+                previousGbpFlows = actualGbpFlows;
             } catch (InterruptedException | ExecutionException e) {
                 LOG.error("Failed to update flow tables", e);
             }