From 14ecd62239cb6a7a750a0a5884af9558d576b837 Mon Sep 17 00:00:00 2001 From: eswanit Date: Fri, 10 Mar 2017 09:34:04 +0530 Subject: [PATCH 1/1] Bug 7864: Specified Id key does not exist in id pool vpnservices 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 --- .../org/opendaylight/genius/idmanager/IdManager.java | 11 ++++++++--- .../genius/idmanager/jobs/UpdateIdEntryJob.java | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/IdManager.java b/idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/IdManager.java index 47e838ad7..e80edbf01 100644 --- a/idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/IdManager.java +++ b/idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/IdManager.java @@ -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 existingId = idUtils.getIdEntry(parentIdPoolInstanceIdentifier, idKey); Optional 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 idValuesList = existingIdEntry.getIdValue(); diff --git a/idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/jobs/UpdateIdEntryJob.java b/idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/jobs/UpdateIdEntryJob.java index c3a291623..2447241e6 100644 --- a/idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/jobs/UpdateIdEntryJob.java +++ b/idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/jobs/UpdateIdEntryJob.java @@ -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>> { + 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>> 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()); -- 2.36.6