Bug 6745 Fix replacing in compression queue 68/46168/3
authorAndrej Leitner <andrej.leitner@pantheon.tech>
Mon, 26 Sep 2016 08:29:26 +0000 (10:29 +0200)
committerAndrej Leitner <andrej.leitner@pantheon.tech>
Mon, 26 Sep 2016 12:00:30 +0000 (14:00 +0200)
 When there were more changes in a row on startup it could happend
 that the first syncup entry (config-operational) was not updated
 but replaced with following config-config changes. Therefore we need
 to update syncup entry in compression queue everytime when new config
 diff is comming (not only if config-config entry resides there).

Change-Id: I9d73fb348f5e1ace1b138052bcd2a5614946efa9
Signed-off-by: Andrej Leitner <andrej.leitner@pantheon.tech>
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecorator.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java

index d06697a896abafa95f181742cd4bceffe0ed6871..5dd431aeab461cfbaa34f6f652fe956cc227744d 100644 (file)
@@ -41,8 +41,8 @@ public class SyncReactorFutureZipDecorator extends SyncReactorFutureDecorator {
                                             final SyncupEntry syncupEntry) throws InterruptedException {
         try {
             compressionGuard.acquire();
-            final boolean newFutureNecessary = updateCompressionState(flowcapableNodePath, syncupEntry);
-            if (newFutureNecessary) {
+            final boolean newTaskNecessary = updateCompressionState(flowcapableNodePath, syncupEntry);
+            if (newTaskNecessary) {
                 super.syncup(flowcapableNodePath, syncupEntry);
             }
             return Futures.immediateFuture(true);
@@ -62,14 +62,14 @@ public class SyncReactorFutureZipDecorator extends SyncReactorFutureDecorator {
     }
 
     /**
-     * If there is config delta in compression queue for the device and new configuration is coming,
-     * update its zip queue entry. Create/replace zip queue entry for the device with operational delta otherwise.
+     * If a syncup entry for corresponding the device is present in compression queue and new configuration diff is
+     * coming - update the entry in compression queue (zip). Create new (no entry in queue for device) or replace
+     * entry (config vs. operational is coming) in queue otherwise.
      */
     private boolean updateCompressionState(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
                                            final SyncupEntry syncupEntry) {
         final SyncupEntry previousEntry = compressionQueue.get(flowcapableNodePath);
-
-        if (previousEntry != null && syncupEntry.isOptimizedConfigDelta() && previousEntry.isOptimizedConfigDelta()) {
+        if (previousEntry != null && syncupEntry.isOptimizedConfigDelta()) {
             updateOptimizedConfigDelta(flowcapableNodePath, syncupEntry, previousEntry);
         } else {
             compressionQueue.put(flowcapableNodePath, syncupEntry);
index 9180e62b87e06813a6a25c5d923526ae3537f463..e8b9157de928c24ff290fb9bb35ff31cb90ecf30 100644 (file)
@@ -82,7 +82,7 @@ public class SyncReactorFutureZipDecoratorTest {
         final CountDownLatch latchForFirst = new CountDownLatch(1);
         final CountDownLatch latchForNext = new CountDownLatch(1);
 
-        final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, configDS);
+        final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, operationalDS);
         final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
         final SyncupEntry third = new SyncupEntry(null, configDS, dataAfter, configDS);
         final SyncupEntry fourth = new SyncupEntry(dataAfter2, configDS, null, configDS);