Id allocation failing 63/83163/3
authorAmitesh Soni <amitesh.soni@ericsson.com>
Fri, 19 Jul 2019 07:10:49 +0000 (12:40 +0530)
committerHema Gopalakrishnan <hema.gopalkrishnan@ericsson.com>
Thu, 25 Jul 2019 05:37:26 +0000 (05:37 +0000)
Issue
=====
While reading data store if data is not present in the DS,
"ExpectedDataObjectNotFoundException" exception is thrown.
Since this exception is not handled, ID allocation is failing.

Fix
====
Added try-catch block to handle the "ReadFailedException" exception
so that the code execution does not stop if read fails.

https://gerrit.ericsson.se/#/c/4354671/

Change-Id: I00423597e1681085b1fbcd187e11e5f2dd7582cd
Signed-off-by: Amitesh Soni <amitesh.soni@ericsson.com>
idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/IdManager.java

index 2b42fe6f5c359a3c2b8efdf8f637d71fa8f75964..a95b595779c7cfb10867d78e114b0cfd45ff0f88 100644 (file)
@@ -689,19 +689,24 @@ public class IdManager implements IdManagerService, IdManagerMonitor {
     }
 
     private IdLocalPool getOrCreateLocalIdPool(String parentPoolName, String localPoolName)
-        throws IdManagerException, ReadFailedException {
+        throws IdManagerException {
         IdLocalPool localIdPool = localPool.get(parentPoolName);
         if (localIdPool == null) {
             idUtils.lock(lockManager, parentPoolName);
             try {
                 // Check if a previous thread that got the cluster-wide lock
                 // first, has created the localPool
-                InstanceIdentifier<IdPool> childIdPoolInstanceIdentifier = idUtils
-                        .getIdPoolInstance(localPoolName);
-                Optional<IdPool> childIdPoolOpt = singleTxDB.syncReadOptional(LogicalDatastoreType.CONFIGURATION,
-                        childIdPoolInstanceIdentifier);
-                if (childIdPoolOpt.isPresent()) {
-                    updateLocalIdPoolCache(childIdPoolOpt.get(), parentPoolName);
+                try {
+                    InstanceIdentifier<IdPool> childIdPoolInstanceIdentifier = idUtils
+                            .getIdPoolInstance(localPoolName);
+                    Optional<IdPool> childIdPoolOpt = singleTxDB.syncReadOptional(LogicalDatastoreType.CONFIGURATION,
+                            childIdPoolInstanceIdentifier);
+                    if (childIdPoolOpt.isPresent()) {
+                        updateLocalIdPoolCache(childIdPoolOpt.get(), parentPoolName);
+                    }
+                }
+                catch (ReadFailedException ex) {
+                    LOG.debug("Failed to read id pool {} due to {}", localPoolName, ex.getMessage());
                 }
                 if (localPool.get(parentPoolName) == null) {
                     try {