Merge "Bug 5208 - flows don't get removed on update"
authorMartin Sunal <msunal@cisco.com>
Mon, 8 Feb 2016 09:22:36 +0000 (09:22 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 8 Feb 2016 09:22:36 +0000 (09:22 +0000)
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);
             }