Merge "Bug 6745 Improve compression queue locking and handle InterruptedException"
authorJozef Bacigal <jozef.bacigal@pantheon.tech>
Wed, 28 Sep 2016 07:57:51 +0000 (07:57 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 28 Sep 2016 07:57:51 +0000 (07:57 +0000)
1  2 
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 f6301dc4f13bb23679843727597b5858a7878d79,07ce9890e0d25c1997ad0b394202413dbc8069d9..a21592792130187ac8be06bbaca42f0e8c0eab93
@@@ -34,16 -37,21 +37,20 @@@ public class SyncReactorFutureZipDecora
      }
  
      public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                             final SyncupEntry syncupEntry) throws InterruptedException {
+                                             final SyncupEntry syncupEntry) {
+         Semaphore guard = null;
          try {
-             compressionGuard.acquire();
+             guard = semaphoreKeeper.summonGuardAndAcquire(flowcapableNodePath);
+             if (Objects.isNull(guard)) {
+                 return Futures.immediateFuture(Boolean.FALSE);
+             }
              final boolean newTaskNecessary = updateCompressionState(flowcapableNodePath, syncupEntry);
              if (newTaskNecessary) {
 -                return super.syncup(flowcapableNodePath, syncupEntry);
 -            } else {
 -                return Futures.immediateFuture(Boolean.TRUE);
 +                super.syncup(flowcapableNodePath, syncupEntry);
              }
 +            return Futures.immediateFuture(Boolean.TRUE);
          } finally {
-             compressionGuard.release();
+             semaphoreKeeper.releaseGuard(guard);
          }
      }