BUG 5355: init datastore with blocking transaction to avoid race condition 10/34710/1
authoradetalhouet <adetalhouet@inocybe.com>
Mon, 15 Feb 2016 18:15:07 +0000 (13:15 -0500)
committeradetalhouet <adetalhouet@inocybe.com>
Mon, 15 Feb 2016 18:15:07 +0000 (13:15 -0500)
Change-Id: I0435bfe598baf1acb5614f22a4b9248b8234779e
Signed-off-by: adetalhouet <adetalhouet@inocybe.com>
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrProvider.java

index d239a3e83d8ef7ce681c9e34a70f7799a92a93c7..f886b75640c5752a45e781ce857abaca924d8f25 100755 (executable)
@@ -107,7 +107,7 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
                 final TopologyBuilder tpb = new TopologyBuilder();
                 tpb.setTopologyId(topoId);
                 transaction.put(type, path, tpb.build());
-                transaction.submit();
+                transaction.submit().get();
             } else {
                 transaction.cancel();
             }
@@ -124,7 +124,7 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
             if (!topology.get().isPresent()) {
                 final NetworkTopologyBuilder ntb = new NetworkTopologyBuilder();
                 transaction.put(type,path,ntb.build());
-                transaction.submit();
+                transaction.submit().get();
             } else {
                 transaction.cancel();
             }
@@ -135,7 +135,7 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
 
     @Override
     public boolean addUni(UniAugmentation uniAug) {
-        if (uniAug == null || uniAug.getIpAddress() == null || uniAug.getMacAddress() == null) {
+        if ((uniAug == null) || (uniAug.getIpAddress() == null) || (uniAug.getMacAddress() == null)) {
             return false;
         }
         return UnimgrUtils.createUniNode(dataBroker, uniAug);
@@ -144,8 +144,9 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
     @Override
     public boolean removeUni(IpAddress ipAddress) {
         final InstanceIdentifier<Node> iidUni = UnimgrMapper.getUniIid(dataBroker, ipAddress, LogicalDatastoreType.CONFIGURATION);
-        if (iidUni == null)
+        if (iidUni == null) {
             return false;
+        }
 
         return UnimgrUtils.deleteNode(dataBroker, iidUni, LogicalDatastoreType.CONFIGURATION);
     }
@@ -169,10 +170,11 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
 
     @Override
     public boolean addEvc(EvcAugmentation evc) {
-        if(evc == null || evc.getUniDest().isEmpty() || evc.getUniSource().isEmpty())
+        if((evc == null) || evc.getUniDest().isEmpty() || evc.getUniSource().isEmpty()) {
             return false;
-        else
+        } else {
             return UnimgrUtils.createEvc(dataBroker, evc);
+        }
     }
 
     @Override