Bug 7864: Specified Id key does not exist in id pool vpnservices 16/53116/6
authoreswanit <swati.udhavrao.niture@ericsson.com>
Fri, 10 Mar 2017 04:04:04 +0000 (09:34 +0530)
committereswanit <swati.udhavrao.niture@ericsson.com>
Thu, 16 Mar 2017 11:11:25 +0000 (16:41 +0530)
Id entry was not getting updated after allocation. This is fixed by
increasing latch wait time.

If the releaseId is called twice, then IdManagerException was thrown
since Id was not present. This is fixed by ignoring throwing an exception
if Id doesn't exist when releaseId is called the second time.

Change-Id: I8d8da8963f4509c9771795630662596ad2c528f9
Signed-off-by: eswanit <swati.udhavrao.niture@ericsson.com>
idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/IdManager.java
idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/jobs/UpdateIdEntryJob.java

index 47e838ad7e936d4d60b2015f6a6e370edca5a4a9..e80edbf0132f7def5bbee6a2cc190feba2306488 100644 (file)
@@ -617,9 +617,12 @@ public class IdManager implements IdManagerService, IdManagerMonitor {
     private void releaseIdFromLocalPool(String parentPoolName, String localPoolName, String idKey)
             throws ReadFailedException, IdManagerException {
         String idLatchKey = idUtils.getUniqueKey(parentPoolName, idKey);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Releasing ID {} from pool {}", idKey, localPoolName);
+        }
         java.util.Optional.ofNullable(idUtils.releaseIdLatchMap.get(idLatchKey)).ifPresent(latch -> {
             try {
-                latch.await(5, TimeUnit.SECONDS);
+                latch.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException ignored) {
                 LOG.warn("Thread interrupted while releasing id {} from id pool {}", idKey, parentPoolName);
             } finally {
@@ -637,8 +640,10 @@ public class IdManager implements IdManagerService, IdManagerMonitor {
         InstanceIdentifier<IdEntries> existingId = idUtils.getIdEntry(parentIdPoolInstanceIdentifier, idKey);
         Optional<IdEntries> existingIdEntryObject = singleTxDB.syncReadOptional(CONFIGURATION, existingId);
         if (!existingIdEntryObject.isPresent()) {
-            throw new IdManagerException(
-                    String.format("Specified Id key %s does not exist in id pool %s", idKey, parentPoolName));
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Specified Id key {} does not exist in id pool {}", idKey, parentPoolName);
+            }
+            return;
         }
         IdEntries existingIdEntry = existingIdEntryObject.get();
         List<Long> idValuesList = existingIdEntry.getIdValue();
index c3a2916231f898a36c3c7e1559dd27e0d5289023..2447241e6b10d0ff99acb9341fc428ff80e0e20d 100644 (file)
@@ -20,9 +20,12 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.idmanager.IdUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.id.pool.IdEntries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class UpdateIdEntryJob implements Callable<List<ListenableFuture<Void>>> {
 
+    private static final Logger LOG = LoggerFactory.getLogger(UpdateIdEntryJob.class);
     private final String parentPoolName;
     private final String localPoolName;
     private final String idKey;
@@ -51,6 +54,9 @@ public class UpdateIdEntryJob implements Callable<List<ListenableFuture<Void>>>
             tx.delete(CONFIGURATION, idUtils.getIdEntriesInstanceIdentifier(parentPoolName, idKey));
         }
         tx.submit().checkedGet();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Updated id entry with idValues {}, idKey {}, pool {}", newIdValues, idKey, localPoolName);
+        }
         String uniqueIdKey = idUtils.getUniqueKey(parentPoolName, idKey);
         Optional.ofNullable(idUtils.releaseIdLatchMap.get(uniqueIdKey))
             .ifPresent(latch -> latch.countDown());