vpnmanager: use datastore-constrained transactions 82/81682/6
authorStephen Kitt <skitt@redhat.com>
Tue, 16 Apr 2019 09:52:04 +0000 (11:52 +0200)
committerStephen Kitt <skitt@redhat.com>
Wed, 11 Dec 2019 13:02:40 +0000 (14:02 +0100)
Change-Id: I47afadf4bdefb7357ea99a8c3f643e9df32121d8
Signed-off-by: Stephen Kitt <skitt@redhat.com>
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnFootprintService.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceOpListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnManagerImpl.java

index e9452abbc3a0b270f3bf4ac95ac9caab69f515d2..34e26c20074c1f4436e9aa3024ee842ac77a43b6 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -25,8 +28,6 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
@@ -125,8 +126,6 @@ public class VpnFootprintService implements IVpnFootprintService {
         }
     }
 
-    // Allow deprecated TransactionRunner calls for now
-    @SuppressWarnings("ForbidCertainMethod")
     private void createOrUpdateVpnToDpnListForInterfaceName(Uint32 vpnId, String primaryRd, Uint64 dpnId,
             String intfName, String vpnName) {
         AtomicBoolean newDpnOnVpn = new AtomicBoolean(false);
@@ -137,10 +136,10 @@ public class VpnFootprintService implements IVpnFootprintService {
         final ReentrantLock lock = JvmGlobalLocks.getLockForString(vpnName);
         lock.lock();
         try {
-            ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+            ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
                 InstanceIdentifier<VpnToDpnList> id = VpnHelper.getVpnToDpnListIdentifier(primaryRd, dpnId);
                 VpnInterfaces vpnInterface = new VpnInterfacesBuilder().setInterfaceName(intfName).build();
-                Optional<VpnToDpnList> dpnInVpn = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
+                Optional<VpnToDpnList> dpnInVpn = tx.read(id).get();
                 if (dpnInVpn.isPresent()) {
                     VpnToDpnList vpnToDpnList = dpnInVpn.get();
                     List<VpnInterfaces> vpnInterfaces = new ArrayList<>(vpnToDpnList.nonnullVpnInterfaces());
@@ -148,8 +147,7 @@ public class VpnFootprintService implements IVpnFootprintService {
                     VpnToDpnListBuilder vpnToDpnListBuilder = new VpnToDpnListBuilder(vpnToDpnList);
                     vpnToDpnListBuilder.setDpnState(VpnToDpnList.DpnState.Active).setVpnInterfaces(vpnInterfaces);
 
-                    tx.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(),
-                        WriteTransaction.CREATE_MISSING_PARENTS);
+                    tx.put(id, vpnToDpnListBuilder.build(), CREATE_MISSING_PARENTS);
                     /*
                      * If earlier state was inactive, it is considered new DPN coming back to the
                      * same VPN
@@ -165,8 +163,7 @@ public class VpnFootprintService implements IVpnFootprintService {
                     VpnToDpnListBuilder vpnToDpnListBuilder = new VpnToDpnListBuilder().setDpnId(dpnId);
                     vpnToDpnListBuilder.setDpnState(VpnToDpnList.DpnState.Active).setVpnInterfaces(vpnInterfaces);
 
-                    tx.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(),
-                        WriteTransaction.CREATE_MISSING_PARENTS);
+                    tx.put(id, vpnToDpnListBuilder.build(), CREATE_MISSING_PARENTS);
                     newDpnOnVpn.set(true);
                     LOG.debug("createOrUpdateVpnToDpnList: Creating vpn footprint for vpn {} vpnId {} interface {}"
                             + " on dpn {}", vpnName, vpnId, intfName, dpnId);
@@ -198,8 +195,6 @@ public class VpnFootprintService implements IVpnFootprintService {
         }
     }
 
-    // Allow deprecated TransactionRunner calls for now
-    @SuppressWarnings("ForbidCertainMethod")
     private void createOrUpdateVpnToDpnListForIPAddress(Uint32 vpnId, String primaryRd, Uint64 dpnId,
             ImmutablePair<IpAddresses.IpAddressSource, String> ipAddressSourceValuePair, String vpnName) {
         AtomicBoolean newDpnOnVpn = new AtomicBoolean(false);
@@ -210,13 +205,13 @@ public class VpnFootprintService implements IVpnFootprintService {
         final ReentrantLock lock = JvmGlobalLocks.getLockForString(vpnName);
         lock.lock();
         try {
-            ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+            ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
                 InstanceIdentifier<VpnToDpnList> id = VpnHelper.getVpnToDpnListIdentifier(primaryRd, dpnId);
                 IpAddressesBuilder ipAddressesBldr = new IpAddressesBuilder()
                         .setIpAddressSource(ipAddressSourceValuePair.getKey());
                 ipAddressesBldr.withKey(new IpAddressesKey(ipAddressSourceValuePair.getValue()));
                 ipAddressesBldr.setIpAddress(ipAddressSourceValuePair.getValue());
-                Optional<VpnToDpnList> dpnInVpn = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
+                Optional<VpnToDpnList> dpnInVpn = tx.read(id).get();
                 if (dpnInVpn.isPresent()) {
                     VpnToDpnList vpnToDpnList = dpnInVpn.get();
                     List<IpAddresses> ipAddresses = new ArrayList<>(vpnToDpnList.nonnullIpAddresses());
@@ -224,7 +219,7 @@ public class VpnFootprintService implements IVpnFootprintService {
                     VpnToDpnListBuilder vpnToDpnListBuilder = new VpnToDpnListBuilder(vpnToDpnList);
                     vpnToDpnListBuilder.setDpnState(VpnToDpnList.DpnState.Active).setIpAddresses(ipAddresses);
 
-                    tx.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(), true);
+                    tx.put(id, vpnToDpnListBuilder.build(), CREATE_MISSING_PARENTS);
                     /*
                      * If earlier state was inactive, it is considered new DPN coming back to the
                      * same VPN
@@ -237,7 +232,7 @@ public class VpnFootprintService implements IVpnFootprintService {
                     ipAddresses.add(ipAddressesBldr.build());
                     VpnToDpnListBuilder vpnToDpnListBuilder = new VpnToDpnListBuilder().setDpnId(dpnId);
                     vpnToDpnListBuilder.setDpnState(VpnToDpnList.DpnState.Active).setIpAddresses(ipAddresses);
-                    tx.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(), true);
+                    tx.put(id, vpnToDpnListBuilder.build(), CREATE_MISSING_PARENTS);
                     newDpnOnVpn.set(true);
                 }
 
@@ -260,8 +255,6 @@ public class VpnFootprintService implements IVpnFootprintService {
         }
     }
 
-    // Allow deprecated TransactionRunner calls for now
-    @SuppressWarnings("ForbidCertainMethod")
     private void removeOrUpdateVpnToDpnListForInterfaceName(Uint32 vpnId, String rd, Uint64 dpnId, String intfName,
             String vpnName) {
         AtomicBoolean lastDpnOnVpn = new AtomicBoolean(false);
@@ -273,10 +266,9 @@ public class VpnFootprintService implements IVpnFootprintService {
         lock.lock();
         try {
             try {
-                ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+                ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
                     InstanceIdentifier<VpnToDpnList> id = VpnHelper.getVpnToDpnListIdentifier(rd, dpnId);
-                    Optional<VpnToDpnList> dpnInVpnOpt = tx.read(LogicalDatastoreType.OPERATIONAL, id)
-                            .checkedGet();
+                    Optional<VpnToDpnList> dpnInVpnOpt = tx.read(id).get();
                     if (!dpnInVpnOpt.isPresent()) {
                         LOG.error("removeOrUpdateVpnToDpnList: Could not find DpnToVpn map for VPN=[name={}"
                                 + " rd={} id={}] and dpnId={}", vpnName, rd, id, dpnId);
@@ -305,12 +297,10 @@ public class VpnFootprintService implements IVpnFootprintService {
                             }
                             LOG.debug("removeOrUpdateVpnToDpnList: Removing vpn footprint for vpn {} vpnId {} "
                                     + "interface {}, on dpn {}", vpnName, vpnName, intfName, dpnId);
-                            tx.put(LogicalDatastoreType.OPERATIONAL, id, dpnInVpnBuilder.build(),
-                                    WriteTransaction.CREATE_MISSING_PARENTS);
+                            tx.put(id, dpnInVpnBuilder.build(), CREATE_MISSING_PARENTS);
 
                         } else {
-                            tx.delete(LogicalDatastoreType.OPERATIONAL,
-                                    id.child(VpnInterfaces.class, new VpnInterfacesKey(intfName)));
+                            tx.delete(id.child(VpnInterfaces.class, new VpnInterfacesKey(intfName)));
                             LOG.debug("removeOrUpdateVpnToDpnList: Updating vpn footprint for vpn {} vpnId {} "
                                     + "interface {}, on dpn {}", vpnName, vpnName, intfName, dpnId);
                         }
@@ -337,8 +327,6 @@ public class VpnFootprintService implements IVpnFootprintService {
         }
     }
 
-    // Allow deprecated TransactionRunner calls for now
-    @SuppressWarnings("ForbidCertainMethod")
     private void removeOrUpdateVpnToDpnListForIpAddress(Uint32 vpnId, String rd, Uint64 dpnId,
             ImmutablePair<IpAddresses.IpAddressSource, String> ipAddressSourceValuePair, String vpnName) {
         AtomicBoolean lastDpnOnVpn = new AtomicBoolean(false);
@@ -349,11 +337,10 @@ public class VpnFootprintService implements IVpnFootprintService {
         final ReentrantLock lock = JvmGlobalLocks.getLockForString(vpnName);
         lock.lock();
         try {
-            ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+            ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
                 InstanceIdentifier<VpnToDpnList> id = VpnHelper.getVpnToDpnListIdentifier(rd, dpnId);
 
-                Optional<VpnToDpnList> dpnInVpnOpt = tx.read(LogicalDatastoreType.OPERATIONAL, id)
-                        .checkedGet();
+                Optional<VpnToDpnList> dpnInVpnOpt = tx.read(id).get();
                 if (!dpnInVpnOpt.isPresent()) {
                     LOG.error("removeOrUpdateVpnToDpnList: Could not find DpnToVpn map for VPN=[name={} "
                             + "rd={} id={}] and dpnId={}", vpnName, rd, id, dpnId);
@@ -382,11 +369,10 @@ public class VpnFootprintService implements IVpnFootprintService {
                             LOG.warn("ip addresses are empty but vpn interfaces are present for the vpn {} in "
                                     + "dpn {}", vpnName, dpnId);
                         }
-                        tx.put(LogicalDatastoreType.OPERATIONAL, id, dpnInVpnBuilder.build(), true);
+                        tx.put(id, dpnInVpnBuilder.build(), CREATE_MISSING_PARENTS);
 
                     } else {
-                        tx.delete(LogicalDatastoreType.OPERATIONAL, id.child(IpAddresses.class,
-                            new IpAddressesKey(ipAddressSourceValuePair.getValue())));
+                        tx.delete(id.child(IpAddresses.class, new IpAddressesKey(ipAddressSourceValuePair.getValue())));
                     }
                 }
 
index 05b70943fd1bc1d4cae0e077ddfefd89606558a5..98068b0a0b1cf98b3595603ced8c10d063f56c08 100644 (file)
@@ -7,25 +7,31 @@
  */
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
 import com.google.common.base.Optional;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Singleton;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
-import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
+import org.opendaylight.genius.infra.Datastore.Configuration;
+import org.opendaylight.genius.infra.Datastore.Operational;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedReadTransaction;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInterfaceOpData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency;
@@ -88,28 +94,30 @@ public class VpnInterfaceOpListener extends AsyncDataTreeChangeListenerBase<VpnI
 
 
     @Override
-    // Allow deprecated TransactionRunner calls for now
-    @SuppressWarnings("ForbidCertainMethod")
     protected void remove(final InstanceIdentifier<VpnInterfaceOpDataEntry> identifier,
             final VpnInterfaceOpDataEntry del) {
         final VpnInterfaceOpDataEntryKey key = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class);
         final String interfaceName = key.getName();
         jobCoordinator.enqueueJob("VPNINTERFACE-" + interfaceName,
-            () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
-                postProcessVpnInterfaceRemoval(identifier, del, tx);
+            () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
+                postProcessVpnInterfaceRemoval(identifier, del, tx, null);
                 LOG.info("remove: Removed vpn operational data for interface {} on dpn {} vpn {}", del.getName(),
                         del.getDpnId(), del.getVpnInstanceName());
             })));
     }
 
-    // Allow deprecated TransactionRunner calls for now
-    @SuppressWarnings("ForbidCertainMethod")
     private void postProcessVpnInterfaceRemoval(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier,
-            VpnInterfaceOpDataEntry del, ReadWriteTransaction readWriteTxn) {
-        if (readWriteTxn == null) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx ->
-                            postProcessVpnInterfaceRemoval(identifier, del, tx)), LOG,
-                    "Error post-processing VPN interface removal");
+            VpnInterfaceOpDataEntry del, @Nullable TypedReadWriteTransaction<Operational> operTx,
+            @Nullable TypedReadTransaction<Configuration> confTx) throws InterruptedException {
+        if (confTx == null) {
+            txRunner.callWithNewReadOnlyTransactionAndClose(CONFIGURATION,
+                tx -> postProcessVpnInterfaceRemoval(identifier, del, operTx, tx));
+            return;
+        }
+        if (operTx == null) {
+            LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL,
+                tx -> postProcessVpnInterfaceRemoval(identifier, del, tx, confTx)), LOG,
+                "Error post-processing VPN interface removal");
             return;
         }
         final VpnInterfaceOpDataEntryKey key = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class);
@@ -119,8 +127,8 @@ public class VpnInterfaceOpListener extends AsyncDataTreeChangeListenerBase<VpnI
             LOG.info("postProcessVpnInterfaceRemoval: interface name {} vpnName {} dpn {}", interfaceName, vpnName,
                     del.getDpnId());
             //decrement the vpn interface count in Vpn Instance Op Data
-            Optional<VpnInstance> vpnInstance = readWriteTxn.read(LogicalDatastoreType.CONFIGURATION,
-                    VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnName)).checkedGet();
+            Optional<VpnInstance> vpnInstance =
+                confTx.read(VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnName)).get();
 
             if (vpnInstance.isPresent()) {
                 String rd = vpnInstance.get().getVrfId();
@@ -147,18 +155,16 @@ public class VpnInterfaceOpListener extends AsyncDataTreeChangeListenerBase<VpnI
                     List<Prefixes> prefixToInterface = new ArrayList<>();
                     for (Adjacency adjacency : adjs.getAdjacency()) {
                         List<Prefixes> prefixToInterfaceLocal = new ArrayList<>();
-                        Optional<Prefixes> prefix = SingleTransactionDataBroker.syncReadOptional(dataBroker,
-                                LogicalDatastoreType.OPERATIONAL,
-                                VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(),
-                                        VpnUtil.getIpPrefix(adjacency.getIpAddress())));
+                        Optional<Prefixes> prefix = operTx.read(
+                            VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(),
+                                VpnUtil.getIpPrefix(adjacency.getIpAddress()))).get();
                         if (prefix.isPresent()) {
                             prefixToInterfaceLocal.add(prefix.get());
                         }
                         if (prefixToInterfaceLocal.isEmpty() && adjacency.getNextHopIpList() != null) {
                             for (String nh : adjacency.getNextHopIpList()) {
-                                prefix = SingleTransactionDataBroker.syncReadOptional(dataBroker,
-                                        LogicalDatastoreType.OPERATIONAL, VpnUtil.getPrefixToInterfaceIdentifier(
-                                                vpnInstOp.getVpnId(), VpnUtil.getIpPrefix(nh)));
+                                prefix = operTx.read(VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(),
+                                    VpnUtil.getIpPrefix(nh))).get();
                                 if (prefix.isPresent()) {
                                     prefixToInterfaceLocal.add(prefix.get());
                                 }
@@ -182,9 +188,8 @@ public class VpnInterfaceOpListener extends AsyncDataTreeChangeListenerBase<VpnI
                  */
                     for (Prefixes pref : prefixToInterface) {
                         if (VpnUtil.isMatchedPrefixToInterface(pref, del)) {
-                            readWriteTxn.delete(LogicalDatastoreType.OPERATIONAL,
-                                    VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(),
-                                                                                pref.getIpAddress()));
+                            operTx.delete(
+                                VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), pref.getIpAddress()));
                         }
                     }
                 }
@@ -201,7 +206,7 @@ public class VpnInterfaceOpListener extends AsyncDataTreeChangeListenerBase<VpnI
                         del.getDpnId());
             }
             notifyTaskIfRequired(interfaceName);
-        } catch (ReadFailedException e) {
+        } catch (InterruptedException | ExecutionException e) {
             LOG.error("postProcessVpnInterfaceRemoval: Failed to read data store for interface {} vpn {}",
                     interfaceName, vpnName);
         }
index 920547f7f0dc9ab5d5c95d5d150f586577f62c09..cb02dc10577818d5c6418f9c66432276f182a34a 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
 import com.google.common.base.Optional;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
@@ -25,7 +28,6 @@ import javax.inject.Singleton;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
@@ -44,7 +46,7 @@ import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.genius.utils.JvmGlobalLocks;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
 import org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer;
 import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
 import org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput;
@@ -680,10 +682,8 @@ public class VpnManagerImpl implements IVpnManager {
     }
 
     @Override
-    // Allow deprecated TransactionRunner calls for now
-    @SuppressWarnings("ForbidCertainMethod")
     public void updateRouteTargetsToSubnetAssociation(Set<VpnTarget> routeTargets, String cidr, String vpnName) {
-        ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+        LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
             for (VpnTarget rt : routeTargets) {
                 String rtValue = rt.getVrfRTValue();
                 switch (rt.getVrfRTType()) {
@@ -713,10 +713,8 @@ public class VpnManagerImpl implements IVpnManager {
     }
 
     @Override
-    // Allow deprecated TransactionRunner calls for now
-    @SuppressWarnings("ForbidCertainMethod")
     public void removeRouteTargetsToSubnetAssociation(Set<VpnTarget> routeTargets, String cidr, String vpnName) {
-        ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+        LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
             for (VpnTarget rt : routeTargets) {
                 String rtValue = rt.getVrfRTValue();
                 switch (rt.getVrfRTType()) {
@@ -815,13 +813,13 @@ public class VpnManagerImpl implements IVpnManager {
     }
 
     private void addSubnetAssociationOperationToTx(String rt, RouteTarget.RtType rtType, String cidr,
-                                                   String vpnName, ReadWriteTransaction tx,
+                                                   String vpnName, TypedReadWriteTransaction<Operational> tx,
                                                    boolean isAssociationRemoved)
             throws InterruptedException, ExecutionException {
         if (isAssociationRemoved) {
             //Remove RT-Subnet-Vpn Association
-            Optional<AssociatedSubnet> associatedSubnet = tx.read(LogicalDatastoreType.OPERATIONAL,
-                    VpnUtil.getAssociatedSubnetIdentifier(rt, rtType, cidr)).get();
+            Optional<AssociatedSubnet> associatedSubnet =
+                tx.read(VpnUtil.getAssociatedSubnetIdentifier(rt, rtType, cidr)).get();
             boolean deleteParent = false;
             if (associatedSubnet.isPresent()) {
                 List<AssociatedVpn> associatedVpns = new ArrayList<>(associatedSubnet.get().nonnullAssociatedVpn());
@@ -841,32 +839,29 @@ public class VpnManagerImpl implements IVpnManager {
                 }
             }
             if (deleteParent) {
-                deleteParentForSubnetToVpnAssocication(rt, rtType, cidr, tx);
+                deleteParentForSubnetToVpnAssociation(rt, rtType, cidr, tx);
             } else {
                 //Some other VPNs are also part of this rtVal, rtType and subnetCidr combination.
                 //Delete only this AssociatedVpn Object
-                tx.delete(LogicalDatastoreType.OPERATIONAL,
-                        VpnUtil.getAssociatedSubnetAndVpnIdentifier(rt, rtType, cidr, vpnName));
+                tx.delete(VpnUtil.getAssociatedSubnetAndVpnIdentifier(rt, rtType, cidr, vpnName));
                 LOG.debug("addSubnetAssocOperationToTx: Removed vpn {} from association rt {} rtType {} cidr {}",
                         vpnName, rt, rtType, cidr);
             }
         } else {
             //Add RT-Subnet-Vpn Association
-            tx.put(LogicalDatastoreType.OPERATIONAL,
-                    VpnUtil.getAssociatedSubnetAndVpnIdentifier(rt, rtType, cidr, vpnName),
-                    VpnUtil.buildAssociatedSubnetAndVpn(vpnName), true);
+            tx.put(VpnUtil.getAssociatedSubnetAndVpnIdentifier(rt, rtType, cidr, vpnName),
+                    VpnUtil.buildAssociatedSubnetAndVpn(vpnName), CREATE_MISSING_PARENTS);
         }
     }
 
-    private void deleteParentForSubnetToVpnAssocication(String rt, RouteTarget.RtType rtType,
-                                                String cidr, ReadWriteTransaction tx)
+    private void deleteParentForSubnetToVpnAssociation(String rt, RouteTarget.RtType rtType,
+                                                String cidr, TypedReadWriteTransaction<Operational> tx)
             throws InterruptedException, ExecutionException {
         //Check if you need to delete rtVal+rtType or just the subnetCidr
         InstanceIdentifier<RouteTarget> rtIdentifier = InstanceIdentifier
                 .builder(SubnetsAssociatedToRouteTargets.class).child(RouteTarget.class,
                         new RouteTargetKey(rt, rtType)).build();
-        Optional<RouteTarget> rtToSubnetsAssociation = tx.read(LogicalDatastoreType.OPERATIONAL,
-                rtIdentifier).get();
+        Optional<RouteTarget> rtToSubnetsAssociation = tx.read(rtIdentifier).get();
         if (rtToSubnetsAssociation.isPresent()) {
             List<AssociatedSubnet> associatedSubnets = new ArrayList<>(rtToSubnetsAssociation.get()
                     .nonnullAssociatedSubnet());
@@ -880,15 +875,14 @@ public class VpnManagerImpl implements IVpnManager {
                 if (associatedSubnets.isEmpty()) {
                     //The entire rt to subnet association is empty
                     //Delete the RouteTarget object
-                    tx.delete(LogicalDatastoreType.OPERATIONAL, rtIdentifier);
-                    LOG.debug("deleteParentForSubnetToVpnAssocication: Removed rt {} rtType {} from association,",
+                    tx.delete(rtIdentifier);
+                    LOG.debug("deleteParentForSubnetToVpnAssociation: Removed rt {} rtType {} from association,",
                             rt, rtType);
                 } else {
                     //Some other VPNs are also part of this rtVal, rtType combination
                     //Delete only this AssociatedSubnet
-                    tx.delete(LogicalDatastoreType.OPERATIONAL, VpnUtil.getAssociatedSubnetIdentifier(rt, rtType,
-                            cidr));
-                    LOG.debug("deleteParentForSubnetToVpnAssocication: Removed cidr {} from association rt {}"
+                    tx.delete(VpnUtil.getAssociatedSubnetIdentifier(rt, rtType, cidr));
+                    LOG.debug("deleteParentForSubnetToVpnAssociation: Removed cidr {} from association rt {}"
                             + " rtType {}", cidr, rt, rtType);
                 }
             }
@@ -898,9 +892,9 @@ public class VpnManagerImpl implements IVpnManager {
     @Override
     public boolean checkForOverlappingSubnets(Uuid network, List<Subnetmap> subnetmapList, Uuid vpn,
                                        Set<VpnTarget> routeTargets, List<String> failedNwList) {
-        for (int i = 0; i < subnetmapList.size(); i++) {
+        for (Subnetmap subnetmap : subnetmapList) {
             //Check if any other subnet that is already part of a different vpn with same rt, has overlapping CIDR
-            if (checkExistingSubnetWithSameRoutTargets(routeTargets, vpn, subnetmapList.get(i), failedNwList)) {
+            if (checkExistingSubnetWithSameRoutTargets(routeTargets, vpn, subnetmap, failedNwList)) {
                 return true;
             }
         }