Datastore-constrained txes: vpnmanager 20/74020/5
authorStephen Kitt <skitt@redhat.com>
Fri, 13 Jul 2018 09:25:53 +0000 (11:25 +0200)
committerSam Hague <shague@redhat.com>
Mon, 17 Sep 2018 00:24:01 +0000 (00:24 +0000)
Change-Id: I4d0c66ddb953e7c90f2c9e064c34a1a0feedcd04
JIRA: NETVIRT-1346
Signed-off-by: Stephen Kitt <skitt@redhat.com>
29 files changed:
fibmanager/api/src/main/java/org/opendaylight/netvirt/fibmanager/api/IFibManager.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/FibManagerImpl.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/FibUtil.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/AbstractSnatService.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NatEvpnUtil.java
vpnmanager/api/src/main/java/org/opendaylight/netvirt/vpnmanager/api/IVpnManager.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/CentralizedSwitchChangeListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/DpnInVpnChangeListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/FibEntriesListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/InterfaceStateChangeListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/TunnelEndPointChangeListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/TunnelInterfaceStateListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnElanInterfaceChangeListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInstanceListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnManagerImpl.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnNodeListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnRpcServiceImpl.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnServiceElanDpnInterfacesListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnUtil.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/intervpnlink/IVpnLinkServiceImpl.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/intervpnlink/InterVpnLinkListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/intervpnlink/InterVpnLinkNodeAddTask.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/intervpnlink/tasks/InterVpnLinkCreatorTask.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/intervpnlink/tasks/InterVpnLinkRemoverTask.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/populator/impl/L3vpnOverMplsGrePopulator.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/populator/impl/L3vpnOverVxlanPopulator.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/populator/impl/L3vpnPopulator.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/populator/intfc/VpnPopulator.java

index 7d83f0fded330197cc01446ebf9c878a70c57019..c1511fc1aaad69b2dbd36cfed78247dd4cdb2dd5 100644 (file)
@@ -14,7 +14,7 @@ import java.math.BigInteger;
 import java.util.List;
 
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.genius.infra.Datastore;
+import org.opendaylight.genius.infra.Datastore.Configuration;
 import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface;
@@ -55,22 +55,24 @@ public interface IFibManager {
 
     void addOrUpdateFibEntry(String rd, String macAddress, String prefix, List<String> nextHopList,
                              VrfEntry.EncapType encapType, long label, long l3vni, String gwMacAddress,
-                             String parentVpnRd, RouteOrigin origin, WriteTransaction writeConfigTxn);
+                             String parentVpnRd, RouteOrigin origin,
+                             TypedWriteTransaction<Configuration> writeConfigTxn);
 
     void addFibEntryForRouterInterface(String rd, String prefix,
-                                       RouterInterface routerInterface, long label, WriteTransaction writeConfigTxn);
+                                       RouterInterface routerInterface, long label,
+                                       TypedWriteTransaction<Configuration> writeConfigTxn);
 
     void removeOrUpdateFibEntry(String rd, String prefix, String nextHopToRemove,
-                                WriteTransaction writeConfigTxn);
+                                TypedWriteTransaction<Configuration> writeConfigTxn);
 
-    void removeFibEntry(String rd, String prefix, WriteTransaction writeConfigTxn);
+    void removeFibEntry(String rd, String prefix, TypedWriteTransaction<Configuration> writeConfigTxn);
 
     void updateRoutePathForFibEntry(String rd, String prefix, String nextHop,
                                     long label, boolean nextHopAdd, WriteTransaction writeConfigTxn);
 
     void addVrfTable(String rd, WriteTransaction writeConfigTxn);
 
-    void removeVrfTable(String rd, TypedWriteTransaction<Datastore.Configuration> writeConfigTxn);
+    void removeVrfTable(String rd, TypedWriteTransaction<Configuration> writeConfigTxn);
 
     void removeInterVPNLinkRouteFlows(String interVpnLinkName,
                                       boolean isVpnFirstEndPoint,
index f5ae62effbc2b71bb8b74c702ef3e79adfb19e08..0d1515cc149011272bdc5c89b5f6a3eca31631bc 100755 (executable)
@@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.genius.infra.Datastore;
+import org.opendaylight.genius.infra.Datastore.Configuration;
 import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
 import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
@@ -138,7 +138,7 @@ public class FibManagerImpl implements IFibManager {
     public void addOrUpdateFibEntry(String rd, String macAddress, String prefix,
             List<String> nextHopList, VrfEntry.EncapType encapType, long label,
             long l3vni, String gwMacAddress, String parentVpnRd, RouteOrigin origin,
-            WriteTransaction writeConfigTxn) {
+            TypedWriteTransaction<Configuration> writeConfigTxn) {
         fibUtil.addOrUpdateFibEntry(rd, macAddress, prefix, nextHopList , encapType, label, l3vni, gwMacAddress,
                 parentVpnRd, origin, writeConfigTxn);
     }
@@ -146,18 +146,18 @@ public class FibManagerImpl implements IFibManager {
     @Override
     public void addFibEntryForRouterInterface(String rd, String prefix,
             RouterInterface routerInterface, long label,
-            WriteTransaction writeConfigTxn) {
+            TypedWriteTransaction<Configuration> writeConfigTxn) {
         fibUtil.addFibEntryForRouterInterface(rd, prefix, routerInterface, label, writeConfigTxn);
     }
 
     @Override
     public void removeOrUpdateFibEntry(String rd, String prefix,
-            String nextHopToRemove, WriteTransaction writeConfigTxn) {
+            String nextHopToRemove, TypedWriteTransaction<Configuration> writeConfigTxn) {
         fibUtil.removeOrUpdateFibEntry(rd, prefix, nextHopToRemove, writeConfigTxn);
     }
 
     @Override
-    public void removeFibEntry(String rd, String prefix, WriteTransaction writeConfigTxn) {
+    public void removeFibEntry(String rd, String prefix, TypedWriteTransaction<Configuration> writeConfigTxn) {
         fibUtil.removeFibEntry(rd, prefix, writeConfigTxn);
     }
 
@@ -168,7 +168,7 @@ public class FibManagerImpl implements IFibManager {
     }
 
     @Override
-    public void removeVrfTable(String rd, TypedWriteTransaction<Datastore.Configuration> writeConfigTxn) {
+    public void removeVrfTable(String rd, TypedWriteTransaction<Configuration> writeConfigTxn) {
         fibUtil.removeVrfTable(rd, writeConfigTxn);
     }
 
index 37415ea4da5a62d23b0d33525c1a34a8429dac99..393cd9e40480bb86db741475a7f2054c5a026554 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.netvirt.fibmanager;
 
 import static java.util.stream.Collectors.joining;
 import static java.util.stream.Collectors.toList;
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
@@ -301,7 +302,7 @@ public class FibUtil {
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void addOrUpdateFibEntry(String rd, String macAddress, String prefix, List<String> nextHopList,
             VrfEntry.EncapType encapType, long label, long l3vni, String gwMacAddress, String parentVpnRd,
-            RouteOrigin origin, WriteTransaction writeConfigTxn) {
+            RouteOrigin origin, TypedWriteTransaction<Configuration> writeConfigTxn) {
         if (rd == null || rd.isEmpty()) {
             LOG.error("Prefix {} not associated with vpn", prefix);
             return;
@@ -329,14 +330,14 @@ public class FibUtil {
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void writeFibEntryToDs(InstanceIdentifier<VrfEntry> vrfEntryId, String prefix, List<String> nextHopList,
             long label, Long l3vni, VrfEntry.EncapType encapType, RouteOrigin origin, String macAddress,
-            String gatewayMacAddress, String parentVpnRd, WriteTransaction writeConfigTxn) {
+            String gatewayMacAddress, String parentVpnRd, TypedWriteTransaction<Configuration> writeConfigTxn) {
         VrfEntryBuilder vrfEntryBuilder = new VrfEntryBuilder().setDestPrefix(prefix).setOrigin(origin.getValue());
         if (parentVpnRd != null) {
             vrfEntryBuilder.setParentVpnRd(parentVpnRd);
         }
         buildVpnEncapSpecificInfo(vrfEntryBuilder, encapType, label, l3vni, macAddress, gatewayMacAddress, nextHopList);
         if (writeConfigTxn != null) {
-            writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntryBuilder.build(), true);
+            writeConfigTxn.merge(vrfEntryId, vrfEntryBuilder.build(), CREATE_MISSING_PARENTS);
         } else {
             MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntryBuilder.build());
         }
@@ -344,7 +345,7 @@ public class FibUtil {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void addFibEntryForRouterInterface(String rd, String prefix, RouterInterface routerInterface, long label,
-            WriteTransaction writeConfigTxn) {
+            TypedWriteTransaction<Configuration> writeConfigTxn) {
         if (rd == null || rd.isEmpty()) {
             LOG.error("Prefix {} not associated with vpn", prefix);
             return;
@@ -362,7 +363,7 @@ public class FibUtil {
                 .addAugmentation(RouterInterface.class, routerInterface).build();
 
             if (writeConfigTxn != null) {
-                writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry, true);
+                writeConfigTxn.merge(vrfEntryId, vrfEntry, CREATE_MISSING_PARENTS);
             } else {
                 MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
             }
@@ -393,7 +394,7 @@ public class FibUtil {
         builder.setRoutePaths(routePaths);
     }
 
-    public void removeFibEntry(String rd, String prefix, WriteTransaction writeConfigTxn) {
+    public void removeFibEntry(String rd, String prefix, TypedWriteTransaction<Configuration> writeConfigTxn) {
 
         if (rd == null || rd.isEmpty()) {
             LOG.error("Prefix {} not associated with vpn", prefix);
@@ -407,7 +408,7 @@ public class FibUtil {
                 .child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix));
         InstanceIdentifier<VrfEntry> vrfEntryId = idBuilder.build();
         if (writeConfigTxn != null) {
-            writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+            writeConfigTxn.delete(vrfEntryId);
         } else {
             MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
         }
@@ -423,7 +424,7 @@ public class FibUtil {
      *                        If null or empty, then the whole VrfEntry is removed
      */
     public void removeOrUpdateFibEntry(String rd, String prefix, String nextHopToRemove,
-            WriteTransaction writeConfigTxn) {
+            TypedWriteTransaction<Configuration> writeConfigTxn) {
 
         LOG.debug("Removing fib entry with destination prefix {} from vrf table for rd {} nextHop {}", prefix, rd,
                 nextHopToRemove);
@@ -451,7 +452,7 @@ public class FibUtil {
             if (routePaths.size() == 1) {
                 // Remove the whole entry
                 if (writeConfigTxn != null) {
-                    writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+                    writeConfigTxn.delete(vrfEntryId);
                 } else {
                     MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
                 }
@@ -485,7 +486,7 @@ public class FibUtil {
                 RoutePaths routePaths = FibHelper.buildRoutePath(nextHop, label);
                 if (writeConfigTxn != null) {
                     writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, routePathId, routePaths,
-                            WriteTransaction.CREATE_MISSING_PARENTS);
+                            CREATE_MISSING_PARENTS);
                 } else {
                     MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routePathId, routePaths);
                 }
index 6358b140342e71a94d0703eb04d8d2e3ef38a9d6..a1d1de1215d4af1e7ac608a1e09db07d1e0be894 100644 (file)
@@ -26,7 +26,6 @@ import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackReg
 import org.opendaylight.genius.infra.Datastore.Configuration;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
-import org.opendaylight.genius.infra.TransactionAdapter;
 import org.opendaylight.genius.infra.TypedReadWriteTransaction;
 import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
@@ -330,7 +329,7 @@ public abstract class AbstractSnatService implements SnatServiceListener {
         removeFlow(confTx, dpnId, NwConstants.L3_FIB_TABLE, flowRef);
         String rd = NatUtil.getVpnRd(dataBroker, subNetId);
         String ipPrefix = externalIp + "/32";
-        fibManager.removeFibEntry(rd, ipPrefix, TransactionAdapter.toWriteTransaction(confTx));
+        fibManager.removeFibEntry(rd, ipPrefix, confTx);
         NatUtil.deletePrefixToInterface(dataBroker, NatUtil.getVpnId(dataBroker, subNetId), ipPrefix);
     }
 
index 0044863561a457f7c65232e03ef5c4dd96b2170f..e5e236f6815f99b6fe733b570102893df839b01d 100644 (file)
@@ -18,7 +18,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
 import org.opendaylight.genius.infra.Datastore.Configuration;
-import org.opendaylight.genius.infra.TransactionAdapter;
 import org.opendaylight.genius.infra.TypedReadWriteTransaction;
 import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.interfacemanager.globals.IfmConstants;
@@ -186,7 +185,7 @@ public final class NatEvpnUtil {
 
             fibManager.addOrUpdateFibEntry(rd, null /*macAddress*/, prefix,
                     Collections.singletonList(nextHopIp), VrfEntry.EncapType.Vxlan, NatConstants.DEFAULT_LABEL_VALUE,
-                l3Vni, gwMacAddress, null /* parent-vpn-rd */, origin, TransactionAdapter.toWriteTransaction(writeTx));
+                l3Vni, gwMacAddress, null /* parent-vpn-rd */, origin, writeTx);
             /* Publish to Bgp only if its an INTERNET VPN */
             if (rd != null && !rd.equalsIgnoreCase(vpnName)) {
                 bgpManager.advertisePrefix(rd, null /*macAddress*/, prefix, Collections.singletonList(nextHopIp),
index 52a6815e86e437a080809f1860e59fc339fdd3ea..268c0f5da0a8a8912213ea9f1a79e6e368a0ffd2 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Set;
 
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.genius.infra.Datastore.Configuration;
 import org.opendaylight.genius.infra.Datastore.Operational;
 import org.opendaylight.genius.infra.TypedReadTransaction;
@@ -32,70 +31,37 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev15060
 
 
 public interface IVpnManager {
-    @Deprecated
-    void addExtraRoute(String vpnName, String destination, String nextHop, String rd, String routerID,
-            Long l3vni, RouteOrigin origin, String intfName, Adjacency operationalAdj,
-            VrfEntry.EncapType encapType, WriteTransaction writeConfigTxn);
-
     void addExtraRoute(String vpnName, String destination, String nextHop, String rd, String routerID,
         Long l3vni, RouteOrigin origin, String intfName, Adjacency operationalAdj,
         VrfEntry.EncapType encapType, TypedWriteTransaction<Configuration> confTx);
 
-    @Deprecated
-    void delExtraRoute(String vpnName, String destination, String nextHop, String rd, String routerID,
-            String intfName, WriteTransaction writeConfigTxn, WriteTransaction writeOperTx);
-
     void delExtraRoute(String vpnName, String destination, String nextHop, String rd, String routerID,
         String intfName, TypedWriteTransaction<Configuration> confTx, TypedWriteTransaction<Operational> operTx);
 
-    @Deprecated
-    void removePrefixFromBGP(String vpnName, String primaryRd, String extraRouteRd, String vpnInterfaceName,
-        String prefix, String nextHop, String nextHopTunnelIp, BigInteger dpnId, WriteTransaction writeConfigTxn,
-        WriteTransaction writeOperTx);
-
     void removePrefixFromBGP(String vpnName, String primaryRd, String extraRouteRd, String vpnInterfaceName,
-        String prefix, String nextHop, String nextHopTunnelIp, BigInteger dpnId,
-        TypedWriteTransaction<Configuration> confTx, TypedWriteTransaction<Operational> operTx);
+                                    String prefix, String nextHop, String nextHopTunnelIp, BigInteger dpnId,
+                                    TypedWriteTransaction<Configuration> confTx,
+                                    TypedWriteTransaction<Operational> operTx);
 
     boolean isVPNConfigured();
 
     String getPrimaryRdFromVpnInstance(VpnInstance vpnInstance);
 
-    @Deprecated
-    void addSubnetMacIntoVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
-            BigInteger dpnId, WriteTransaction tx) throws ExecutionException, InterruptedException;
-
     void addSubnetMacIntoVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
         BigInteger dpnId, TypedWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException;
 
-    @Deprecated
-    void removeSubnetMacFromVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
-            BigInteger dpnId, WriteTransaction tx) throws ExecutionException, InterruptedException;
-
     void removeSubnetMacFromVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
         BigInteger dpnId, TypedReadWriteTransaction<Configuration> confTx)
         throws ExecutionException, InterruptedException;
 
-    @Deprecated
-    void addRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
-            String subnetVpnName, WriteTransaction writeTx) throws ExecutionException, InterruptedException;
-
     void addRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
         String subnetVpnName, TypedWriteTransaction<Configuration> confTx)
         throws ExecutionException, InterruptedException;
 
-    @Deprecated
-    void removeRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
-            String subnetVpnName, WriteTransaction writeTx) throws ExecutionException, InterruptedException;
-
     void removeRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
         String subnetVpnName, TypedReadWriteTransaction<Configuration> confTx)
         throws ExecutionException, InterruptedException;
 
-    @Deprecated
-    void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress,
-            BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx);
-
     void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress,
         BigInteger dpnId, Uuid extNetworkId);
 
index c8367f09a1fec60e339e176c9a108bc6406baebb..d48e933e133ce50118703ad6465a7a3a62c7dc61 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import java.math.BigInteger;
 import java.util.List;
 import java.util.Objects;
@@ -16,11 +18,12 @@ import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.genius.infra.Datastore.Configuration;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
 import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
 import org.opendaylight.netvirt.vpnmanager.api.IVpnManager;
@@ -80,9 +83,9 @@ public class CentralizedSwitchChangeListener
     @Override
     protected void remove(InstanceIdentifier<RouterToNaptSwitch> key, RouterToNaptSwitch routerToNaptSwitch) {
         LOG.debug("Removing {}", routerToNaptSwitch);
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-                        setupRouterGwFlows(routerToNaptSwitch, tx, NwConstants.DEL_FLOW)), LOG,
-                "Error processing switch removal for {}", routerToNaptSwitch);
+        ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx ->
+                                            setupRouterGwFlows(routerToNaptSwitch, tx, NwConstants.DEL_FLOW)), LOG,
+                                                "Error processing switch removal for {}", routerToNaptSwitch);
     }
 
     @Override
@@ -91,7 +94,7 @@ public class CentralizedSwitchChangeListener
         LOG.debug("Updating old {} new {}", origRouterToNaptSwitch, updatedRouterToNaptSwitch);
         if (!Objects.equals(updatedRouterToNaptSwitch.getPrimarySwitchId(),
                 origRouterToNaptSwitch.getPrimarySwitchId())) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+            ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
                 setupRouterGwFlows(origRouterToNaptSwitch, tx, NwConstants.DEL_FLOW);
                 setupRouterGwFlows(updatedRouterToNaptSwitch, tx, NwConstants.ADD_FLOW);
             }), LOG, "Error updating switch {} to {}", origRouterToNaptSwitch, updatedRouterToNaptSwitch);
@@ -101,7 +104,7 @@ public class CentralizedSwitchChangeListener
     @Override
     protected void add(InstanceIdentifier<RouterToNaptSwitch> key, RouterToNaptSwitch routerToNaptSwitch) {
         LOG.debug("Adding {}", routerToNaptSwitch);
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
+        ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx ->
                         setupRouterGwFlows(routerToNaptSwitch, tx, NwConstants.ADD_FLOW)), LOG,
                 "Error processing switch addition for {}", routerToNaptSwitch);
     }
@@ -111,8 +114,9 @@ public class CentralizedSwitchChangeListener
         return this;
     }
 
-    private void setupRouterGwFlows(RouterToNaptSwitch routerToNaptSwitch, WriteTransaction writeTx, int addOrRemove)
-            throws ExecutionException, InterruptedException {
+    private void setupRouterGwFlows(RouterToNaptSwitch routerToNaptSwitch,
+            TypedReadWriteTransaction<Configuration> confTx, int addOrRemove)
+                                    throws ExecutionException, InterruptedException {
         Routers router = null;
         if (addOrRemove == NwConstants.ADD_FLOW) {
             router = vpnUtil.getExternalRouter(routerToNaptSwitch.getRouterName());
@@ -139,11 +143,11 @@ public class CentralizedSwitchChangeListener
             Uuid subnetVpnName = extIp.getSubnetId();
             if (addOrRemove == NwConstants.ADD_FLOW) {
                 vpnManager.addRouterGwMacFlow(routerName, extGwMacAddress, primarySwitchId, extNetworkId,
-                        subnetVpnName.getValue(), writeTx);
+                        subnetVpnName.getValue(), confTx);
                 externalRouterDataUtil.addtoRouterMap(router);
             } else {
                 vpnManager.removeRouterGwMacFlow(routerName, extGwMacAddress, primarySwitchId, extNetworkId,
-                        subnetVpnName.getValue(), writeTx);
+                        subnetVpnName.getValue(), confTx);
                 externalRouterDataUtil.removeFromRouterMap(router);
             }
         }
@@ -151,7 +155,7 @@ public class CentralizedSwitchChangeListener
         if (addOrRemove == NwConstants.ADD_FLOW) {
             vpnManager.addArpResponderFlowsToExternalNetworkIps(routerName,
                     VpnUtil.getIpsListFromExternalIps(router.getExternalIps()),
-                    extGwMacAddress, primarySwitchId, extNetworkId, writeTx);
+                    extGwMacAddress, primarySwitchId, extNetworkId);
         } else {
             vpnManager.removeArpResponderFlowsToExternalNetworkIps(routerName,
                     VpnUtil.getIpsListFromExternalIps(router.getExternalIps()),
index 097a9bd1c7a8e671021b2c2fb21650f6ee58a9f7..7ec5354617e69fb5076a3747bfa9ebdeadc851f7 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
 import com.google.common.base.Optional;
 import java.math.BigInteger;
 import java.util.Collection;
@@ -15,12 +17,13 @@ import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 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;
+import org.opendaylight.genius.infra.Datastore.Operational;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.netvirt.vpnmanager.api.VpnHelper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AddDpnEvent;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AddInterfaceToDpnOnVpnEvent;
@@ -77,8 +80,8 @@ public class DpnInVpnChangeListener implements OdlL3vpnListener {
                     }
                     if (flushDpnsOnVpn) {
                         try {
-                            txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> deleteDpn(vpnToDpnList, rd, tx))
-                                    .get();
+                            txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL,
+                                tx -> deleteDpn(vpnToDpnList, rd, tx)).get();
                         } catch (InterruptedException | ExecutionException e) {
                             LOG.error("Error removing dpnToVpnList for vpn {} ", vpnName);
                             throw new RuntimeException(e.getMessage(), e);
@@ -91,10 +94,10 @@ public class DpnInVpnChangeListener implements OdlL3vpnListener {
         }
     }
 
-    protected void deleteDpn(Collection<VpnToDpnList> vpnToDpnList, String rd, WriteTransaction writeTxn) {
+    protected void deleteDpn(Collection<VpnToDpnList> vpnToDpnList, String rd, TypedWriteTransaction<Operational> tx) {
         for (final VpnToDpnList curDpn : vpnToDpnList) {
             InstanceIdentifier<VpnToDpnList> vpnToDpnId = VpnHelper.getVpnToDpnListIdentifier(rd, curDpn.getDpnId());
-            writeTxn.delete(LogicalDatastoreType.OPERATIONAL, vpnToDpnId);
+            tx.delete(vpnToDpnId);
         }
     }
 
index f378896dbf1022972f6ce9296021e37d4805298a..e4d375ccf7425324d7793de0f8451a947548b12b 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -110,9 +112,8 @@ public class FibEntriesListener extends AsyncDataTreeChangeListenerBase<VrfEntry
                     routeIds.add(label);
                 }
             });
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-                            tx.put(LogicalDatastoreType.OPERATIONAL,
-                                    VpnUtil.getVpnInstanceOpDataIdentifier(rd),
+            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx ->
+                            tx.put(VpnUtil.getVpnInstanceOpDataIdentifier(rd),
                                     new VpnInstanceOpDataEntryBuilder(vpnInstanceOpData).setRouteEntryId(routeIds)
                                             .build())),
                     LOG, "Error adding label to VPN instance");
@@ -132,9 +133,8 @@ public class FibEntriesListener extends AsyncDataTreeChangeListenerBase<VrfEntry
             } else {
                 LOG.debug("Removing label from vpn info - {}", labels);
                 routeIds.removeAll(labels);
-                ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-                                tx.put(LogicalDatastoreType.OPERATIONAL,
-                                        VpnUtil.getVpnInstanceOpDataIdentifier(rd),
+                ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx ->
+                                tx.put(VpnUtil.getVpnInstanceOpDataIdentifier(rd),
                                         new VpnInstanceOpDataEntryBuilder(vpnInstanceOpData).setRouteEntryId(routeIds)
                                                 .build())),
                         LOG, "Error removing label from VPN instance");
index e38cef52f02b8f3a0e9c3c3c3857eff25e0de4d7..1516de6e91e73eeee64d57327efb06dbd05dec3e 100644 (file)
@@ -7,6 +7,9 @@
  */
 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 com.google.common.collect.HashBasedTable;
 import com.google.common.collect.Table;
@@ -111,11 +114,11 @@ public class InterfaceStateChangeListener
                                 intrf.getName());
                 jobCoordinator.enqueueJob("VPNINTERFACE-" + intrf.getName(), () -> {
                     List<ListenableFuture<Void>> futures = new ArrayList<>(3);
-                    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
+                    futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, writeInvTxn -> {
                         ListenableFuture<Void> configFuture
-                            = txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
+                            = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, writeConfigTxn -> {
                                 ListenableFuture<Void> operFuture
-                                    = txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> {
+                                    = txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeOperTxn -> {
                                         final String interfaceName = intrf.getName();
                                         LOG.info("Detected interface add event for interface {}", interfaceName);
                                         final VpnInterface vpnIf = vpnUtil.getConfiguredVpnInterface(interfaceName);
@@ -190,38 +193,39 @@ public class InterfaceStateChangeListener
                 final BigInteger inputDpId = dpId;
                 jobCoordinator.enqueueJob("VPNINTERFACE-" + ifName, () -> {
                     List<ListenableFuture<Void>> futures = new ArrayList<>(3);
-                    ListenableFuture<Void> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                        writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                            writeOperTxn -> futures.add(
-                                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
+                    ListenableFuture<Void> configFuture =
+                        txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                            writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL,
+                                writeOperTxn -> futures.add(
+                                    txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, writeInvTxn -> {
                                         VpnInterface cfgVpnInterface =
-                                                vpnUtil.getConfiguredVpnInterface(ifName);
+                                            vpnUtil.getConfiguredVpnInterface(ifName);
                                         if (cfgVpnInterface == null) {
                                             LOG.debug("Interface {} is not a vpninterface, ignoring.", ifName);
                                             return;
                                         }
                                         for (VpnInstanceNames vpnInterfaceVpnInstance :
-                                                cfgVpnInterface.getVpnInstanceNames()) {
+                                            cfgVpnInterface.getVpnInstanceNames()) {
                                             String vpnName = vpnInterfaceVpnInstance.getVpnName();
                                             Optional<VpnInterfaceOpDataEntry> optVpnInterface =
-                                                    vpnUtil.getVpnInterfaceOpDataEntry(ifName, vpnName);
+                                                vpnUtil.getVpnInterfaceOpDataEntry(ifName, vpnName);
                                             if (!optVpnInterface.isPresent()) {
                                                 LOG.debug("Interface {} vpn {} is not a vpninterface, or deletion"
-                                                        + " triggered by northbound agent. ignoring.", ifName, vpnName);
+                                                    + " triggered by northbound agent. ignoring.", ifName, vpnName);
                                                 continue;
                                             }
                                             final VpnInterfaceOpDataEntry vpnInterface = optVpnInterface.get();
                                             String gwMac = intrf.getPhysAddress() != null ? intrf.getPhysAddress()
-                                                    .getValue() : vpnInterface.getGatewayMacAddress();
+                                                .getValue() : vpnInterface.getGatewayMacAddress();
                                             BigInteger dpnId = inputDpId;
                                             if (dpnId == null || dpnId.equals(BigInteger.ZERO)) {
                                                 dpnId = vpnInterface.getDpnId();
                                             }
                                             final int ifIndex = intrf.getIfIndex();
                                             LOG.info("VPN Interface remove event - intfName {} onto vpnName {}"
-                                                    + " running oper-driver", vpnInterface.getName(), vpnName);
+                                                + " running oper-driver", vpnInterface.getName(), vpnName);
                                             vpnInterfaceManager.processVpnInterfaceDown(dpnId, ifName, ifIndex, gwMac,
-                                                    vpnInterface, false, writeConfigTxn, writeOperTxn, writeInvTxn);
+                                                vpnInterface, false, writeConfigTxn, writeOperTxn, writeInvTxn);
                                         }
                                     })))));
                     futures.add(configFuture);
@@ -250,73 +254,78 @@ public class InterfaceStateChangeListener
                         update.getName());
                 jobCoordinator.enqueueJob("VPNINTERFACE-" + ifName, () -> {
                     List<ListenableFuture<Void>> futures = new ArrayList<>(3);
-                    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> futures.add(
-                            txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> futures.add(
-                                txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
-                                    final VpnInterface vpnIf =
+                    futures.add(
+                        txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeOperTxn -> futures.add(
+                            txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                                writeConfigTxn -> futures.add(
+                                    txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, writeInvTxn -> {
+                                        final VpnInterface vpnIf =
                                             vpnUtil.getConfiguredVpnInterface(ifName);
-                                    if (vpnIf != null) {
-                                        final int ifIndex = update.getIfIndex();
-                                        BigInteger dpnId = BigInteger.ZERO;
-                                        try {
-                                            dpnId = InterfaceUtils.getDpIdFromInterface(update);
-                                        } catch (Exception e) {
-                                            LOG.error("remove: Unable to retrieve dpnId for interface {}", ifName, e);
-                                            return;
-                                        }
-                                        IntfTransitionState state = getTransitionState(original.getOperStatus(),
+                                        if (vpnIf != null) {
+                                            final int ifIndex = update.getIfIndex();
+                                            BigInteger dpnId;
+                                            try {
+                                                dpnId = InterfaceUtils.getDpIdFromInterface(update);
+                                            } catch (Exception e) {
+                                                LOG.error("remove: Unable to retrieve dpnId for interface {}", ifName,
+                                                    e);
+                                                return;
+                                            }
+                                            IntfTransitionState state = getTransitionState(original.getOperStatus(),
                                                 update.getOperStatus());
-                                        if (state.equals(IntfTransitionState.STATE_IGNORE)) {
-                                            LOG.info("InterfaceStateChangeListener: Interface {} state original {}"
-                                                    + "updated {} not handled", ifName, original.getOperStatus(),
+                                            if (state.equals(IntfTransitionState.STATE_IGNORE)) {
+                                                LOG.info("InterfaceStateChangeListener: Interface {} state original {}"
+                                                        + "updated {} not handled", ifName, original.getOperStatus(),
                                                     update.getOperStatus());
-                                            return;
-                                        }
-                                        if (state.equals(IntfTransitionState.STATE_UP)) {
-                                            for (VpnInstanceNames vpnInterfaceVpnInstance :
+                                                return;
+                                            }
+                                            if (state.equals(IntfTransitionState.STATE_UP)) {
+                                                for (VpnInstanceNames vpnInterfaceVpnInstance :
                                                     vpnIf.getVpnInstanceNames()) {
-                                                String vpnName = vpnInterfaceVpnInstance.getVpnName();
-                                                String primaryRd = vpnUtil.getPrimaryRd(vpnName);
-                                                if (!vpnInterfaceManager.isVpnInstanceReady(vpnName)) {
-                                                    LOG.error(
+                                                    String vpnName = vpnInterfaceVpnInstance.getVpnName();
+                                                    String primaryRd = vpnUtil.getPrimaryRd(vpnName);
+                                                    if (!vpnInterfaceManager.isVpnInstanceReady(vpnName)) {
+                                                        LOG.error(
                                                             "VPN Interface update event - intfName {} onto vpnName {} "
-                                                                    + "running oper-driven UP, VpnInstance not ready,"
-                                                            + " holding on", vpnIf.getName(), vpnName);
-                                                } else if (vpnUtil.isVpnPendingDelete(primaryRd)) {
-                                                    LOG.error("update: Ignoring UP event for vpnInterface {}, as "
+                                                                + "running oper-driven UP, VpnInstance not ready,"
+                                                                + " holding on", vpnIf.getName(), vpnName);
+                                                    } else if (vpnUtil.isVpnPendingDelete(primaryRd)) {
+                                                        LOG.error("update: Ignoring UP event for vpnInterface {}, as "
                                                             + "vpnInstance {} with primaryRd {} is already marked for"
                                                             + " deletion", vpnIf.getName(), vpnName, primaryRd);
-                                                } else {
-                                                    vpnInterfaceManager.processVpnInterfaceUp(dpnId, vpnIf, primaryRd,
+                                                    } else {
+                                                        vpnInterfaceManager.processVpnInterfaceUp(dpnId, vpnIf,
+                                                            primaryRd,
                                                             ifIndex, true, writeConfigTxn, writeOperTxn, writeInvTxn,
                                                             update, vpnName);
+                                                    }
                                                 }
-                                            }
-                                        } else if (state.equals(IntfTransitionState.STATE_DOWN)) {
-                                            for (VpnInstanceNames vpnInterfaceVpnInstance :
+                                            } else if (state.equals(IntfTransitionState.STATE_DOWN)) {
+                                                for (VpnInstanceNames vpnInterfaceVpnInstance :
                                                     vpnIf.getVpnInstanceNames()) {
-                                                String vpnName = vpnInterfaceVpnInstance.getVpnName();
-                                                LOG.info("VPN Interface update event - intfName {} onto vpnName {}"
-                                                       + " running oper-driven DOWN", vpnIf.getName(), vpnName);
-                                                Optional<VpnInterfaceOpDataEntry> optVpnInterface =
-                                                     vpnUtil.getVpnInterfaceOpDataEntry(vpnIf.getName(), vpnName);
-                                                if (optVpnInterface.isPresent()) {
-                                                    VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
-                                                    vpnInterfaceManager.processVpnInterfaceDown(dpnId, vpnIf.getName(),
+                                                    String vpnName = vpnInterfaceVpnInstance.getVpnName();
+                                                    LOG.info("VPN Interface update event - intfName {} onto vpnName {}"
+                                                        + " running oper-driven DOWN", vpnIf.getName(), vpnName);
+                                                    Optional<VpnInterfaceOpDataEntry> optVpnInterface =
+                                                        vpnUtil.getVpnInterfaceOpDataEntry(vpnIf.getName(), vpnName);
+                                                    if (optVpnInterface.isPresent()) {
+                                                        VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
+                                                        vpnInterfaceManager.processVpnInterfaceDown(dpnId,
+                                                            vpnIf.getName(),
                                                             ifIndex, update.getPhysAddress().getValue(), vpnOpInterface,
                                                             true, writeConfigTxn, writeOperTxn, writeInvTxn);
-                                                } else {
-                                                    LOG.error(
+                                                    } else {
+                                                        LOG.error(
                                                             "InterfaceStateChangeListener Update DOWN - vpnInterface {}"
-                                                            + " not available, ignoring event", vpnIf.getName());
-                                                    continue;
+                                                                + " not available, ignoring event", vpnIf.getName());
+                                                        continue;
+                                                    }
                                                 }
                                             }
+                                        } else {
+                                            LOG.debug("Interface {} is not a vpninterface, ignoring.", ifName);
                                         }
-                                    } else {
-                                        LOG.debug("Interface {} is not a vpninterface, ignoring.", ifName);
-                                    }
-                                }))))));
+                                    }))))));
                     return futures;
                 });
             }
index 7f85a77fc653abbb1a486b59ef7803951175a87a..ddebe88c4c9fc1b68cb106dfcc7e17a08ceb417d 100644 (file)
@@ -8,6 +8,9 @@
 
 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.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -113,12 +116,15 @@ public class TunnelEndPointChangeListener
                                 }
                                 final int lPortTag = interfaceState.getIfIndex();
                                 List<ListenableFuture<Void>> futures = new ArrayList<>();
-                                futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                                    writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                                        writeOperTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                                            writeInvTxn -> vpnInterfaceManager.processVpnInterfaceAdjacencies(
-                                                    dpnId, lPortTag, vpnName, primaryRd, vpnInterfaceName, vpnId,
-                                                    writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState)))))));
+                                futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                                    writeConfigTxn -> futures.add(
+                                        txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL,
+                                            writeOperTxn -> futures.add(
+                                                txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
+                                                    writeInvTxn -> vpnInterfaceManager.processVpnInterfaceAdjacencies(
+                                                        dpnId, lPortTag, vpnName, primaryRd, vpnInterfaceName, vpnId,
+                                                        writeConfigTxn, writeOperTxn, writeInvTxn,
+                                                        interfaceState)))))));
                                 LOG.trace("add: Handled TEP {} add for VPN instance {} VPN interface {}",
                                         tep.getInterfaceName(), vpnName, vpnInterfaceName);
                                 return futures;
index 6bc22a80eba1b6da6e86b13def642e756df85adc..7eab70efeb2e312d230bab47b7f08b208426745f 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import static java.util.stream.Collectors.toList;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Strings;
@@ -36,7 +38,6 @@ import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
 import org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils;
 import org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper;
@@ -182,34 +183,32 @@ public class TunnelInterfaceStateListener extends AsyncDataTreeChangeListenerBas
             LOG.trace("update: No vpnInstanceOpdata present");
             return;
         }
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx ->
-                vpnInstanceOpData.stream()
-                        .filter(opData -> opData.getVpnToDpnList() != null
-                                && opData.getVpnToDpnList().stream().anyMatch(
-                                    vpnToDpn -> vpnToDpn.getDpnId().equals(srcDpnId)))
-                        .forEach(opData -> {
-                            List<DestPrefixes> prefixes = VpnExtraRouteHelper.getExtraRouteDestPrefixes(dataBroker,
-                                    opData.getVpnId());
-                            prefixes.forEach(destPrefix -> {
-                                VrfEntry vrfEntry = vpnUtil.getVrfEntry(opData.getVrfId(),
-                                        destPrefix.getDestPrefix());
-                                if (vrfEntry == null || vrfEntry.getRoutePaths() == null) {
-                                    return;
+        vpnInstanceOpData.stream()
+                .filter(opData -> opData.getVpnToDpnList() != null
+                        && opData.getVpnToDpnList().stream().anyMatch(
+                            vpnToDpn -> vpnToDpn.getDpnId().equals(srcDpnId)))
+                .forEach(opData -> {
+                    List<DestPrefixes> prefixes = VpnExtraRouteHelper.getExtraRouteDestPrefixes(dataBroker,
+                            opData.getVpnId());
+                    prefixes.forEach(destPrefix -> {
+                        VrfEntry vrfEntry = vpnUtil.getVrfEntry(opData.getVrfId(),
+                                destPrefix.getDestPrefix());
+                        if (vrfEntry == null || vrfEntry.getRoutePaths() == null) {
+                            return;
+                        }
+                        List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
+                        routePaths.forEach(routePath -> {
+                            if (routePath.getNexthopAddress().equals(srcTepIp)) {
+                                String prefix = destPrefix.getDestPrefix();
+                                String vpnPrefixKey = VpnUtil.getVpnNamePrefixKey(opData.getVpnInstanceName(),
+                                        prefix);
+                                synchronized (vpnPrefixKey.intern()) {
+                                    fibManager.refreshVrfEntry(opData.getVrfId(), prefix);
                                 }
-                                List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
-                                routePaths.forEach(routePath -> {
-                                    if (routePath.getNexthopAddress().equals(srcTepIp)) {
-                                        String prefix = destPrefix.getDestPrefix();
-                                        String vpnPrefixKey = VpnUtil.getVpnNamePrefixKey(opData.getVpnInstanceName(),
-                                                prefix);
-                                        synchronized (vpnPrefixKey.intern()) {
-                                            fibManager.refreshVrfEntry(opData.getVrfId(), prefix);
-                                        }
-                                    }
-                                });
-                            });
-                        })
-        ), LOG, "Error updating route paths for FIB entries");
+                            }
+                        });
+                    });
+                });
     }
 
     @Override
@@ -530,18 +529,17 @@ public class TunnelInterfaceStateListener extends AsyncDataTreeChangeListenerBas
         @Override
         public List<ListenableFuture<Void>> call() {
             List<ListenableFuture<Void>> futures = new ArrayList<>(2);
-            futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx ->
-                    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(operTx -> {
-                        if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
-                            vpnInterfaceManager.updateVpnInterfaceOnTepAdd(vpnInterface, stateTunnelList, confTx,
-                                    operTx);
-                        }
+            futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx ->
+                futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx -> {
+                    if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
+                        vpnInterfaceManager.updateVpnInterfaceOnTepAdd(vpnInterface, stateTunnelList, confTx, operTx);
+                    }
 
-                        if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && isTepDeletedOnDpn) {
-                            vpnInterfaceManager.updateVpnInterfaceOnTepDelete(vpnInterface, stateTunnelList, confTx,
-                                    operTx);
-                        }
-                    }))));
+                    if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && isTepDeletedOnDpn) {
+                        vpnInterfaceManager.updateVpnInterfaceOnTepDelete(vpnInterface, stateTunnelList, confTx,
+                            operTx);
+                    }
+                }))));
             return futures;
         }
     }
@@ -580,7 +578,7 @@ public class TunnelInterfaceStateListener extends AsyncDataTreeChangeListenerBas
         DcGatewayIpList dcGatewayIpListConfig =
                 MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, dcGatewayIpListid).orNull();
         if (dcGatewayIpListConfig == null) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
         return dcGatewayIpListConfig.getDcGatewayIp()
                 .stream()
index 3a097ce272b6d97693c9c43ebad4d4cc4ea42560..1f2140fd2004cc8a1ec5feb5b4c0bb15ad289407 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -80,9 +82,8 @@ public class VpnElanInterfaceChangeListener
         }
 
         InstanceIdentifier<VpnInterface> vpnInterfaceIdentifier = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-            tx.delete(LogicalDatastoreType.CONFIGURATION, vpnInterfaceIdentifier)), LOG,
-                "Error removing VPN interface {}", vpnInterfaceIdentifier);
+        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+            tx.delete(vpnInterfaceIdentifier)), LOG, "Error removing VPN interface {}", vpnInterfaceIdentifier);
         LOG.info("remove: Removed VPN interface {}", interfaceName);
     }
 
index 0ef94c5ce53029ef79c803d329df3c8fd5841155..caafeb9b9258f968400c5280ff3aaf97265b43e4 100644 (file)
@@ -7,6 +7,10 @@
  */
 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.CONFIGURATION;
+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;
@@ -22,13 +26,15 @@ import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 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.TypedWriteTransaction;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
@@ -135,12 +141,12 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
             return;
         } else {
             jobCoordinator.enqueueJob("VPN-" + vpnName, () ->
-                Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+                Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
                     VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder().setVrfId(primaryRd)
                             .setVpnState(VpnInstanceOpDataEntry.VpnState.PendingDelete);
                     InstanceIdentifier<VpnInstanceOpDataEntry> id =
                             VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd);
-                    tx.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build());
+                    tx.merge(id, builder.build());
 
                     LOG.info("{} call: Operational status set to PENDING_DELETE for vpn {} with rd {}",
                             LOGGING_PREFIX_DELETE, vpnName, primaryRd);
@@ -180,8 +186,8 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
             // If another renderer(for eg : CSS) needs to be supported, check can be performed here
             // to call the respective helpers.
             List<ListenableFuture<Void>> futures = new ArrayList<>(2);
-            futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
-                ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(operTx ->
+            futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
+                ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx ->
                         addVpnInstance(vpnInstance, confTx, operTx));
                 ListenableFutures.addErrorLogging(future, LOG, "{} call: error creating VPN {}", LOGGING_PREFIX_ADD,
                         vpnInstance.getVpnInstanceName());
@@ -196,15 +202,15 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
 
     // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
-    private void addVpnInstance(VpnInstance value, WriteTransaction writeConfigTxn,
-        WriteTransaction writeOperTxn) {
+    private void addVpnInstance(VpnInstance value, TypedWriteTransaction<Configuration> writeConfigTxn,
+            TypedWriteTransaction<Operational> writeOperTxn) {
         if (writeConfigTxn == null) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
+            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
                 addVpnInstance(value, tx, writeOperTxn)), LOG, "Error adding VPN instance {}", value);
             return;
         }
         if (writeOperTxn == null) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
+            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx ->
                 addVpnInstance(value, writeConfigTxn, tx)), LOG, "Error adding VPN instance {}", value);
             return;
         }
@@ -223,16 +229,13 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
         org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance
             vpnInstanceToVpnId = VpnUtil.getVpnInstanceToVpnId(vpnInstanceName, vpnId, primaryRd);
 
-        writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION,
-            VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnInstanceName),
-            vpnInstanceToVpnId, WriteTransaction.CREATE_MISSING_PARENTS);
+        writeConfigTxn.put(VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnInstanceName),
+            vpnInstanceToVpnId, CREATE_MISSING_PARENTS);
 
         VpnIds vpnIdToVpnInstance = VpnUtil.getVpnIdToVpnInstance(vpnId, value.getVpnInstanceName(),
             primaryRd, VpnUtil.isBgpVpn(vpnInstanceName, primaryRd));
 
-        writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION,
-            VpnUtil.getVpnIdToVpnInstanceIdentifier(vpnId),
-            vpnIdToVpnInstance, WriteTransaction.CREATE_MISSING_PARENTS);
+        writeConfigTxn.put(VpnUtil.getVpnIdToVpnInstanceIdentifier(vpnId), vpnIdToVpnInstance, CREATE_MISSING_PARENTS);
 
         try {
             String cachedTransType = fibManager.getConfTransType();
@@ -290,9 +293,7 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
         } else {
             builder.setBgpvpnType(VpnInstanceOpDataEntry.BgpvpnType.VPN);
         }
-        writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL,
-            VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd),
-            builder.build(), true);
+        writeOperTxn.merge(VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd), builder.build(), CREATE_MISSING_PARENTS);
         LOG.info("{} addVpnInstance: VpnInstanceOpData populated successfully for vpn {} rd {}", LOGGING_PREFIX_ADD,
                 vpnInstanceName, primaryRd);
     }
index 22b42d4f9794a9f5ddab2cade443fcc06b452ff0..0a101f91c4f36ce2039c245b974647dbab545c50 100755 (executable)
@@ -7,6 +7,10 @@
  */
 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.CONFIGURATION;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Iterators;
@@ -24,6 +28,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutionException;
 import java.util.function.Consumer;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
@@ -32,14 +37,18 @@ import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 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.TransactionAdapter;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.NWUtil;
 import org.opendaylight.genius.mdsalutil.NwConstants;
@@ -270,75 +279,77 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                         // TODO Deal with sequencing â€” the config tx must only submitted if the oper tx goes in
                         // (the inventory tx goes in last)
                         List<ListenableFuture<Void>> futures = new ArrayList<>();
-                        ListenableFuture<Void> confFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                            confTx -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                                operTx -> futures.add(
-                                        txRunner.callWithNewWriteOnlyTransactionAndSubmit(invTx -> {
+                        ListenableFuture<Void> confFuture =
+                            txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                                confTx -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL,
+                                    operTx -> futures.add(
+                                        txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, invTx -> {
                                             LOG.info(
-                                                    "addVpnInterface: VPN Interface add event - intfName {} vpnName {}"
+                                                "addVpnInterface: VPN Interface add event - intfName {} vpnName {}"
                                                     + " on dpn {}",
-                                                    vpnInterface.getName(), vpnName, vpnInterface.getDpnId());
+                                                vpnInterface.getName(), vpnName, vpnInterface.getDpnId());
                                             processVpnInterfaceUp(dpnId, vpnInterface, primaryRd, ifIndex, false,
-                                                    confTx, operTx, invTx, interfaceState, vpnName);
+                                                confTx, operTx, invTx, interfaceState, vpnName);
                                             if (oldAdjs != null && !oldAdjs.equals(newAdjs)) {
                                                 LOG.info("addVpnInterface: Adjacency changed upon VPNInterface {}"
-                                                        + " Update for swapping VPN {} case.", interfaceName, vpnName);
+                                                    + " Update for swapping VPN {} case.", interfaceName, vpnName);
                                                 if (newAdjs != null) {
                                                     for (Adjacency adj : newAdjs) {
                                                         if (oldAdjs.contains(adj)) {
                                                             oldAdjs.remove(adj);
                                                         } else {
                                                             if (!isBgpVpnInternetVpn
-                                                                    || vpnUtil.isAdjacencyEligibleToVpnInternet(adj)) {
+                                                                || vpnUtil.isAdjacencyEligibleToVpnInternet(adj)) {
                                                                 addNewAdjToVpnInterface(vpnInterfaceOpIdentifier,
-                                                                        primaryRd, adj, dpnId, operTx, confTx);
+                                                                    primaryRd, adj, dpnId, operTx, confTx);
                                                             }
                                                         }
                                                     }
                                                 }
                                                 for (Adjacency adj : oldAdjs) {
                                                     if (!isBgpVpnInternetVpn
-                                                            || vpnUtil.isAdjacencyEligibleToVpnInternet(adj)) {
+                                                        || vpnUtil.isAdjacencyEligibleToVpnInternet(adj)) {
                                                         delAdjFromVpnInterface(vpnInterfaceOpIdentifier, adj, dpnId,
-                                                                operTx, confTx);
+                                                            operTx, confTx);
                                                     }
                                                 }
                                             }
                                         })))));
                         futures.add(confFuture);
                         Futures.addCallback(confFuture, new PostVpnInterfaceWorker(interfaceName, true, "Config"),
-                                MoreExecutors.directExecutor());
+                            MoreExecutors.directExecutor());
                         LOG.info("addVpnInterface: Addition of interface {} in VPN {} on dpn {}"
-                                + " processed successfully", interfaceName, vpnName, dpnId);
+                            + " processed successfully", interfaceName, vpnName, dpnId);
                         return futures;
                     });
                 } catch (NumberFormatException | IllegalStateException e) {
                     LOG.error("addVpnInterface: Unable to retrieve dpnId from interface operational data store for "
-                                    + "interface {}. Interface addition on vpn {} failed", interfaceName,
-                                    vpnName, e);
+                            + "interface {}. Interface addition on vpn {} failed", interfaceName,
+                        vpnName, e);
                     return;
                 }
             } else if (Boolean.TRUE.equals(vpnInterface.isRouterInterface())) {
                 jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterface.getName(),
                     () -> {
-                        ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
-                            createFibEntryForRouterInterface(primaryRd, vpnInterface, interfaceName,
+                        ListenableFuture<Void> future =
+                            txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
+                                createFibEntryForRouterInterface(primaryRd, vpnInterface, interfaceName,
                                     confTx, vpnName);
-                            LOG.info("addVpnInterface: Router interface {} for vpn {} on dpn {}", interfaceName,
+                                LOG.info("addVpnInterface: Router interface {} for vpn {} on dpn {}", interfaceName,
                                     vpnName, vpnInterface.getDpnId());
-                        });
+                            });
                         ListenableFutures.addErrorLogging(future, LOG,
-                                "Error creating FIB entry for interface {} on VPN {}", vpnInterface.getName(), vpnName);
+                            "Error creating FIB entry for interface {} on VPN {}", vpnInterface.getName(), vpnName);
                         return Collections.singletonList(future);
                     });
             } else {
                 LOG.info("addVpnInterface: Handling addition of VPN interface {} on vpn {} skipped as interfaceState"
-                        + " is not available", interfaceName, vpnName);
+                    + " is not available", interfaceName, vpnName);
             }
         } else {
             LOG.error("addVpnInterface: Handling addition of VPN interface {} on vpn {} dpn {} skipped"
-                      + " as vpn is pending delete", interfaceName, vpnName,
-                    vpnInterface.getDpnId());
+                    + " as vpn is pending delete", interfaceName, vpnName,
+                vpnInterface.getDpnId());
         }
     }
 
@@ -347,11 +358,11 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     @SuppressFBWarnings({"UW_UNCOND_WAIT", "WA_NOT_IN_LOOP"})
     protected void processVpnInterfaceUp(final BigInteger dpId, VpnInterface vpnInterface, final String primaryRd,
             final int lportTag, boolean isInterfaceUp,
-            WriteTransaction writeConfigTxn,
-            WriteTransaction writeOperTxn,
-            WriteTransaction writeInvTxn,
+            TypedWriteTransaction<Configuration> writeConfigTxn,
+            TypedWriteTransaction<Operational> writeOperTxn,
+            TypedReadWriteTransaction<Configuration> writeInvTxn,
             Interface interfaceState,
-            final String vpnName) {
+            final String vpnName) throws ExecutionException, InterruptedException {
         final String interfaceName = vpnInterface.getName();
         Optional<VpnInterfaceOpDataEntry> optOpVpnInterface = vpnUtil.getVpnInterfaceOpDataEntry(interfaceName,
                 vpnName);
@@ -637,8 +648,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
     private void withdrawAdjacenciesForVpnFromBgp(final InstanceIdentifier<VpnInterfaceOpDataEntry> identifier,
-                        String vpnName, String interfaceName, WriteTransaction writeConfigTxn,
-                        WriteTransaction writeOperTx) {
+                        String vpnName, String interfaceName, TypedWriteTransaction<Configuration> writeConfigTxn,
+                        TypedWriteTransaction<Operational> writeOperTx) {
         //Read NextHops
         InstanceIdentifier<AdjacenciesOp> path = identifier.augmentation(AdjacenciesOp.class);
         String rd = vpnUtil.getVpnRd(interfaceName);
@@ -701,10 +712,11 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     @SuppressWarnings("checkstyle:IllegalCatch")
     protected void processVpnInterfaceAdjacencies(BigInteger dpnId, final int lportTag, String vpnName,
                                                   String primaryRd, String interfaceName, final long vpnId,
-                                                  WriteTransaction writeConfigTxn,
-                                                  WriteTransaction writeOperTxn,
-                                                  final WriteTransaction writeInvTxn,
-                                                  Interface interfaceState) {
+                                                  TypedWriteTransaction<Configuration> writeConfigTxn,
+                                                  TypedWriteTransaction<Operational> writeOperTxn,
+                                                  TypedReadWriteTransaction<Configuration> writeInvTxn,
+                                                  Interface interfaceState)
+            throws ExecutionException, InterruptedException {
         InstanceIdentifier<VpnInterface> identifier = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
         // Read NextHops
         Optional<VpnInterface> vpnInteface = Optional.absent();
@@ -775,9 +787,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                     ? VpnUtil.getPrefixToInterface(dpnId, interfaceName, prefix, intfnetworkUuid ,networkType,
                             segmentationId, prefixCue) :
                     VpnUtil.getPrefixToInterface(dpnId, interfaceName, prefix, prefixCue);
-                writeOperTxn.merge(
-                    LogicalDatastoreType.OPERATIONAL,
-                    VpnUtil.getPrefixToInterfaceIdentifier(
+                writeOperTxn.merge(VpnUtil.getPrefixToInterfaceIdentifier(
                         vpnUtil.getVpnId(vpnName), prefix), prefixes, true);
                 final Uuid subnetId = nextHop.getSubnetId();
 
@@ -890,13 +900,13 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     private void addVpnInterfaceToOperational(String vpnName, String interfaceName, BigInteger dpnId, AdjacenciesOp aug,
-                                              long lportTag, String gwMac, WriteTransaction writeOperTxn) {
+                                              long lportTag, String gwMac,
+                                              TypedWriteTransaction<Operational> writeOperTxn) {
         VpnInterfaceOpDataEntry opInterface =
               VpnUtil.getVpnInterfaceOpDataEntry(interfaceName, vpnName, aug, dpnId, lportTag, gwMac);
         InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil
             .getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
-        writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface,
-                WriteTransaction.CREATE_MISSING_PARENTS);
+        writeOperTxn.put(interfaceId, opInterface, CREATE_MISSING_PARENTS);
         LOG.info("addVpnInterfaceToOperational: Added VPN Interface {} on dpn {} vpn {} to operational datastore",
                 interfaceName, dpnId, vpnName);
     }
@@ -905,8 +915,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void updateVpnInterfaceOnTepAdd(VpnInterfaceOpDataEntry vpnInterface,
                                            StateTunnelList stateTunnelList,
-                                           WriteTransaction writeConfigTxn,
-                                           WriteTransaction writeOperTxn) {
+                                           TypedWriteTransaction<Configuration> writeConfigTxn,
+                                           TypedWriteTransaction<Operational> writeOperTxn) {
 
         String srcTepIp = stateTunnelList.getSrcInfo().getTepIp().stringValue();
         BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
@@ -964,7 +974,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                         vpnInterface.getVpnInstanceName(), vpnId, rd, vpnInterface.getName());
                 // Update the VRF entry with nextHop
                 fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp,
-                        label, true, writeConfigTxn);
+                        label, true, TransactionAdapter.toWriteTransaction(writeConfigTxn));
 
                 //Get the list of VPN's importing this route(prefix) .
                 // Then update the VRF entry with nhList
@@ -973,7 +983,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                     String vpnRd = vpn.getVrfId();
                     if (vpnRd != null) {
                         fibManager.updateRoutePathForFibEntry(vpnRd, prefix,
-                                srcTepIp, label, true, writeConfigTxn);
+                            srcTepIp, label, true, TransactionAdapter.toWriteTransaction(writeConfigTxn));
                         LOG.info("updateVpnInterfaceOnTepAdd: Exported route with rd {} prefix {} nhList {} label {}"
                                 + " interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix, nhList, label,
                             vpnInterface.getName(), srcDpnId, vpnName,
@@ -1004,8 +1014,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                 .addAugmentation(AdjacenciesOp.class, aug).build();
         InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
                 VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
-        writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface,
-                WriteTransaction.CREATE_MISSING_PARENTS);
+        writeOperTxn.put(interfaceId, opInterface, CREATE_MISSING_PARENTS);
         LOG.info("updateVpnInterfaceOnTepAdd: interface {} updated successully on tep add on dpn {} vpn {}",
                 vpnInterface.getName(), srcDpnId, vpnName);
 
@@ -1015,8 +1024,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void updateVpnInterfaceOnTepDelete(VpnInterfaceOpDataEntry vpnInterface,
                                               StateTunnelList stateTunnelList,
-                                              WriteTransaction writeConfigTxn,
-                                              WriteTransaction writeOperTxn) {
+                                              TypedWriteTransaction<Configuration> writeConfigTxn,
+                                              TypedWriteTransaction<Operational> writeOperTxn) {
 
         AdjacenciesOp adjacencies = vpnInterface.augmentation(AdjacenciesOp.class);
         List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : new ArrayList<>();
@@ -1068,7 +1077,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                             vpnId, rd, vpnInterface.getName());
                     // Update the VRF entry with removed nextHop
                     fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp,
-                            label, false, writeConfigTxn);
+                            label, false, TransactionAdapter.toWriteTransaction(writeConfigTxn));
 
                     //Get the list of VPN's importing this route(prefix) .
                     // Then update the VRF entry with nhList
@@ -1077,7 +1086,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                         String vpnRd = vpn.getVrfId();
                         if (vpnRd != null) {
                             fibManager.updateRoutePathForFibEntry(vpnRd, prefix,
-                                    srcTepIp, label, false, writeConfigTxn);
+                                srcTepIp, label, false, TransactionAdapter.toWriteTransaction(writeConfigTxn));
                             LOG.info("updateVpnInterfaceOnTepDelete: Exported route with rd {} prefix {} nhList {}"
                                     + " label {} interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix,
                                     nhList, label, vpnInterface.getName(), srcDpnId,
@@ -1108,8 +1117,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                     .addAugmentation(AdjacenciesOp.class, aug).build();
             InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
                     VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
-            writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface,
-                    WriteTransaction.CREATE_MISSING_PARENTS);
+            writeOperTxn.put(interfaceId, opInterface, CREATE_MISSING_PARENTS);
             LOG.info("updateVpnInterfaceOnTepDelete: interface {} updated successully on tep delete on dpn {} vpn {}",
                          vpnInterface.getName(), srcDpnId, vpnName);
         }
@@ -1155,46 +1163,48 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
         for (VpnInstanceOpDataEntry vpn : vpnsToExportRoute) {
             List<VrfEntry> vrfEntries = vpnUtil.getAllVrfEntries(vpn.getVrfId());
             if (vrfEntries != null) {
-                ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
-                    for (VrfEntry vrfEntry : vrfEntries) {
-                        try {
-                            if (!FibHelper.isControllerManagedNonInterVpnLinkRoute(
+                ListenableFutures.addErrorLogging(
+                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
+                        for (VrfEntry vrfEntry : vrfEntries) {
+                            try {
+                                if (!FibHelper.isControllerManagedNonInterVpnLinkRoute(
                                     RouteOrigin.value(vrfEntry.getOrigin()))) {
-                                LOG.info("handleVpnsExportingRoutes: vrfEntry with rd {} prefix {}"
-                                                + " is not a controller managed non intervpn link route. Ignoring.",
+                                    LOG.info("handleVpnsExportingRoutes: vrfEntry with rd {} prefix {}"
+                                            + " is not a controller managed non intervpn link route. Ignoring.",
                                         vpn.getVrfId(), vrfEntry.getDestPrefix());
-                                continue;
-                            }
-                            String prefix = vrfEntry.getDestPrefix();
-                            String gwMac = vrfEntry.getGatewayMacAddress();
-                            vrfEntry.getRoutePaths().forEach(routePath -> {
-                                String nh = routePath.getNexthopAddress();
-                                int label = routePath.getLabel().intValue();
-                                if (FibHelper.isControllerManagedVpnInterfaceRoute(RouteOrigin.value(
+                                    continue;
+                                }
+                                String prefix = vrfEntry.getDestPrefix();
+                                String gwMac = vrfEntry.getGatewayMacAddress();
+                                vrfEntry.getRoutePaths().forEach(routePath -> {
+                                    String nh = routePath.getNexthopAddress();
+                                    int label = routePath.getLabel().intValue();
+                                    if (FibHelper.isControllerManagedVpnInterfaceRoute(RouteOrigin.value(
                                         vrfEntry.getOrigin()))) {
-                                    LOG.info("handleVpnsExportingRoutesImporting: Importing fib entry rd {} prefix {}"
-                                                    + " nexthop {} label {} to vpn {} vpnRd {}",
+                                        LOG.info(
+                                            "handleVpnsExportingRoutesImporting: Importing fib entry rd {} prefix {}"
+                                                + " nexthop {} label {} to vpn {} vpnRd {}",
                                             vpn.getVrfId(), prefix, nh, label, vpnName, vpnRd);
-                                    fibManager.addOrUpdateFibEntry(vpnRd, null /*macAddress*/, prefix,
+                                        fibManager.addOrUpdateFibEntry(vpnRd, null /*macAddress*/, prefix,
                                             Collections.singletonList(nh), VrfEntry.EncapType.Mplsgre, label,
-                                            0 /*l3vni*/, gwMac,  vpn.getVrfId(), RouteOrigin.SELF_IMPORTED,
+                                            0 /*l3vni*/, gwMac, vpn.getVrfId(), RouteOrigin.SELF_IMPORTED,
                                             confTx);
-                                } else {
-                                    LOG.info("handleVpnsExportingRoutes: Importing subnet route fib entry rd {} "
-                                                    + "prefix {} nexthop {} label {} to vpn {} vpnRd {}",
+                                    } else {
+                                        LOG.info("handleVpnsExportingRoutes: Importing subnet route fib entry rd {} "
+                                                + "prefix {} nexthop {} label {} to vpn {} vpnRd {}",
                                             vpn.getVrfId(), prefix, nh, label, vpnName, vpnRd);
-                                    SubnetRoute route = vrfEntry.augmentation(SubnetRoute.class);
-                                    importSubnetRouteForNewVpn(vpnRd, prefix, nh, label, route, vpn.getVrfId(),
+                                        SubnetRoute route = vrfEntry.augmentation(SubnetRoute.class);
+                                        importSubnetRouteForNewVpn(vpnRd, prefix, nh, label, route, vpn.getVrfId(),
                                             confTx);
-                                }
-                            });
-                        } catch (RuntimeException e) {
-                            LOG.error("getNextHopAddressList: Exception occurred while importing route with rd {}"
-                                            + " prefix {} routePaths {} to vpn {} vpnRd {}", vpn.getVrfId(),
+                                    }
+                                });
+                            } catch (RuntimeException e) {
+                                LOG.error("getNextHopAddressList: Exception occurred while importing route with rd {}"
+                                        + " prefix {} routePaths {} to vpn {} vpnRd {}", vpn.getVrfId(),
                                     vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), vpnName, vpnRd);
+                            }
                         }
-                    }
-                }), LOG, "Error handing VPN exporting routes");
+                    }), LOG, "Error handing VPN exporting routes");
             } else {
                 LOG.info("getNextHopAddressList: No vrf entries to import from vpn {} with rd {} to vpn {} with rd {}",
                         vpn.getVpnInstanceName(), vpn.getVrfId(), vpnName, vpnRd);
@@ -1217,85 +1227,86 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                 final String interfaceName) {
         if (Boolean.TRUE.equals(vpnInterface.isRouterInterface())) {
             jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterface.getName(), () -> {
-                ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
-                    deleteFibEntryForRouterInterface(vpnInterface, confTx, vpnName);
-                    LOG.info("remove: Router interface {} for vpn {}", interfaceName, vpnName);
-                });
+                ListenableFuture<Void> future =
+                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
+                        deleteFibEntryForRouterInterface(vpnInterface, confTx, vpnName);
+                        LOG.info("remove: Router interface {} for vpn {}", interfaceName, vpnName);
+                    });
                 ListenableFutures.addErrorLogging(future, LOG, "Error removing call for interface {} on VPN {}",
                         vpnInterface.getName(), vpnName);
                 return Collections.singletonList(future);
             }, DJC_MAX_RETRIES);
         } else {
-            removeVpnInterfaceFromVpn(identifier, vpnInterface, vpnName, interfaceName);
+            Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
+            removeVpnInterfaceFromVpn(identifier, vpnInterface, vpnName, interfaceName, interfaceState);
         }
     }
 
     @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
     private void removeVpnInterfaceFromVpn(final InstanceIdentifier<VpnInterface> identifier,
-                                final VpnInterface vpnInterface, final String vpnName,
-                                final String interfaceName) {
+                                           final VpnInterface vpnInterface, final String vpnName,
+                                           final String interfaceName, final Interface interfaceState) {
         LOG.info("remove: VPN Interface remove event - intfName {} vpn {} dpn {}" ,vpnInterface.getName(),
                 vpnName, vpnInterface.getDpnId());
         removeInterfaceFromUnprocessedList(identifier, vpnInterface);
         jobCoordinator.enqueueJob("VPNINTERFACE-" + interfaceName,
             () -> {
                 List<ListenableFuture<Void>> futures = new ArrayList<>(3);
-                ListenableFuture<Void> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                    writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                        writeOperTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
-                            LOG.info("remove: - intfName {} onto vpnName {} running config-driven",
-                                    interfaceName, vpnName);
-                            BigInteger dpId = BigInteger.ZERO;
-                            int ifIndex = 0;
-                            String gwMacAddress = null;
-                            InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
-                                    VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
-                            Optional<VpnInterfaceOpDataEntry> optVpnInterface = Optional.absent();
-                            try {
-                                optVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker,
-                                        LogicalDatastoreType.OPERATIONAL, interfaceId);
-                            } catch (ReadFailedException e) {
-                                LOG.error("remove: Failed to read data store for interface {} vpn {}", interfaceName,
-                                        vpnName);
-                                return;
-                            }
-                            Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker,
-                                    interfaceName);
-                            if (interfaceState != null) {
+                ListenableFuture<Void> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                    writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL,
+                        writeOperTxn -> futures.add(
+                            txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, writeInvTxn -> {
+                                LOG.info("remove: - intfName {} onto vpnName {} running config-driven",
+                                        interfaceName, vpnName);
+                                BigInteger dpId = BigInteger.ZERO;
+                                int ifIndex = 0;
+                                String gwMacAddress = null;
+                                InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
+                                        VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
+                                Optional<VpnInterfaceOpDataEntry> optVpnInterface = Optional.absent();
                                 try {
-                                    dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
-                                } catch (NumberFormatException | IllegalStateException e) {
-                                    LOG.error("remove: Unable to retrieve dpnId from interface operational"
-                                            + " data store for interface {} on dpn {} for vpn {} Fetching"
-                                                    + " from vpn interface op data store. ", interfaceName,
-                                            vpnInterface.getDpnId(), vpnName, e);
-                                    dpId = BigInteger.ZERO;
+                                    optVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+                                            LogicalDatastoreType.OPERATIONAL, interfaceId);
+                                } catch (ReadFailedException e) {
+                                    LOG.error("remove: Failed to read data store for interface {} vpn {}",
+                                            interfaceName, vpnName);
+                                    return;
                                 }
-                                ifIndex = interfaceState.getIfIndex();
-                                gwMacAddress = interfaceState.getPhysAddress().getValue();
-                            } else {
-                                LOG.info("remove: Interface state not available for {}. Trying to fetch data"
-                                        + " from vpn interface op.", interfaceName);
-                                if (optVpnInterface.isPresent()) {
-                                    VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
-                                    dpId = vpnOpInterface.getDpnId();
-                                    ifIndex = vpnOpInterface.getLportTag().intValue();
-                                    gwMacAddress = vpnOpInterface.getGatewayMacAddress();
+                                if (interfaceState != null) {
+                                    try {
+                                        dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
+                                    } catch (NumberFormatException | IllegalStateException e) {
+                                        LOG.error("remove: Unable to retrieve dpnId from interface operational"
+                                                        + " data store for interface {} on dpn {} for vpn {} Fetching"
+                                                        + " from vpn interface op data store. ", interfaceName,
+                                                vpnInterface.getDpnId(), vpnName, e);
+                                        dpId = BigInteger.ZERO;
+                                    }
+                                    ifIndex = interfaceState.getIfIndex();
+                                    gwMacAddress = interfaceState.getPhysAddress().getValue();
                                 } else {
-                                    LOG.error("remove: Handling removal of VPN interface {} for vpn {} skipped"
-                                                    + " as interfaceState and vpn interface op is not"
-                                            + " available", interfaceName, vpnName);
-                                    return;
+                                    LOG.info("remove: Interface state not available for {}. Trying to fetch data"
+                                            + " from vpn interface op.", interfaceName);
+                                    if (optVpnInterface.isPresent()) {
+                                        VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
+                                        dpId = vpnOpInterface.getDpnId();
+                                        ifIndex = vpnOpInterface.getLportTag().intValue();
+                                        gwMacAddress = vpnOpInterface.getGatewayMacAddress();
+                                    } else {
+                                        LOG.error("remove: Handling removal of VPN interface {} for vpn {} skipped"
+                                                + " as interfaceState and vpn interface op is not"
+                                                + " available", interfaceName, vpnName);
+                                        return;
+                                    }
                                 }
-                            }
-                            processVpnInterfaceDown(dpId, interfaceName, ifIndex, gwMacAddress,
-                                    optVpnInterface.isPresent() ? optVpnInterface.get() : null, false,
-                                    writeConfigTxn, writeOperTxn, writeInvTxn);
-                            LOG.info(
-                                    "remove: Removal of vpn interface {} on dpn {} for vpn {} processed "
-                                            + "successfully",
-                                    interfaceName, vpnInterface.getDpnId(), vpnName);
-                        })))));
+                                processVpnInterfaceDown(dpId, interfaceName, ifIndex, gwMacAddress,
+                                        optVpnInterface.isPresent() ? optVpnInterface.get() : null, false,
+                                        writeConfigTxn, writeOperTxn, writeInvTxn);
+                                LOG.info(
+                                        "remove: Removal of vpn interface {} on dpn {} for vpn {} processed "
+                                                + "successfully",
+                                        interfaceName, vpnInterface.getDpnId(), vpnName);
+                            })))));
                 futures.add(configFuture);
                 Futures.addCallback(configFuture, new PostVpnInterfaceWorker(interfaceName, false, "Config"));
                 return futures;
@@ -1308,9 +1319,10 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                            String gwMac,
                                            VpnInterfaceOpDataEntry vpnOpInterface,
                                            boolean isInterfaceStateDown,
-                                           WriteTransaction writeConfigTxn,
-                                           WriteTransaction writeOperTxn,
-                                           WriteTransaction writeInvTxn) {
+                                           TypedWriteTransaction<Configuration> writeConfigTxn,
+                                           TypedWriteTransaction<Operational> writeOperTxn,
+                                           TypedReadWriteTransaction<Configuration> writeInvTxn)
+            throws ExecutionException, InterruptedException {
         if (vpnOpInterface == null) {
             LOG.error("processVpnInterfaceDown: Unable to process delete/down for interface {} on dpn {}"
                     + " as it is not available in operational data store", interfaceName, dpId);
@@ -1343,8 +1355,10 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
 
     private void removeAdjacenciesFromVpn(final BigInteger dpnId, final int lportTag, final String interfaceName,
                                           final String vpnName, final long vpnId, String gwMac,
-                                          WriteTransaction writeConfigTxn, final WriteTransaction writeOperTxn,
-                                          final WriteTransaction writeInvTxn) {
+                                          TypedWriteTransaction<Configuration> writeConfigTxn,
+                                          TypedWriteTransaction<Operational> writeOperTxn,
+                                          TypedReadWriteTransaction<Configuration> writeInvTxn)
+            throws ExecutionException, InterruptedException {
         //Read NextHops
         try {
             InstanceIdentifier<VpnInterfaceOpDataEntry> identifier = VpnUtil
@@ -1415,7 +1429,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                 // this vpn interface has no more adjacency left, so clean up the vpn interface from Operational DS
                 LOG.info("removeAdjacenciesFromVpn: Vpn Interface {} on vpn {} dpn {} has no adjacencies."
                         + " Removing it.", interfaceName, vpnName, dpnId);
-                writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL, identifier);
+                writeOperTxn.delete(identifier);
             }
         } catch (ReadFailedException e) {
             LOG.error("removeAdjacenciesFromVpn: Failed to read data store for interface {} dpn {} vpn {}",
@@ -1423,9 +1437,10 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
         }
     }
 
-    private Consumer<String> removeAdjacencyFromInternalVpn(Adjacency nextHop, String vpnName, String interfaceName,
-                                                            BigInteger dpnId, WriteTransaction writeConfigTxn,
-                                                            WriteTransaction writeOperTx) {
+    private Consumer<String> removeAdjacencyFromInternalVpn(Adjacency nextHop, String vpnName,
+                                                            String interfaceName, BigInteger dpnId,
+                                                            TypedWriteTransaction<Configuration> writeConfigTxn,
+                                                            TypedWriteTransaction<Operational> writeOperTx) {
         return (nh) -> {
             String primaryRd = vpnUtil.getVpnRd(vpnName);
             String prefix = nextHop.getIpAddress();
@@ -1451,7 +1466,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
 
     private void removeAdjacencyFromBgpvpn(Adjacency nextHop, List<String> nhList, String vpnName, String primaryRd,
                                            BigInteger dpnId, String rd, String interfaceName,
-                                           WriteTransaction writeConfigTxn, WriteTransaction writeOperTx) {
+                                           TypedWriteTransaction<Configuration> writeConfigTxn,
+                                           TypedWriteTransaction<Operational> writeOperTx) {
         List<VpnInstanceOpDataEntry> vpnsToImportRoute =
                 vpnUtil.getVpnsImportingMyRoute(vpnName);
         nhList.forEach((nh) -> {
@@ -1474,7 +1490,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
 
     private void removeGwMacAndArpResponderFlows(Adjacency nextHop, long vpnId, BigInteger dpnId,
                                                  int lportTag, String gwMac, String interfaceName,
-                                                 WriteTransaction writeInvTxn) {
+                                                 TypedReadWriteTransaction<Configuration> writeInvTxn)
+            throws ExecutionException, InterruptedException {
         final Uuid subnetId = nextHop.getSubnetId();
         if (nextHop.getSubnetGatewayMacAddress() == null) {
             // A valid mac-address was not available for this subnet-gateway-ip
@@ -1549,8 +1566,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                 String primaryRd = vpnUtil.getPrimaryRd(newVpnName);
                 if (!vpnUtil.isVpnPendingDelete(primaryRd)) {
                     // TODO Deal with sequencing â€” the config tx must only submitted if the oper tx goes in
-                    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
-                        futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(operTx -> {
+                    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
+                        futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operTx -> {
                             InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpIdentifier =
                                     VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterfaceName, newVpnName);
                             LOG.info("VPN Interface update event - intfName {} onto vpnName {} running config-driven",
@@ -1592,7 +1609,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                             }
                                         } else {
                                             delAdjFromVpnInterface(vpnInterfaceOpIdentifier, adj, dpnId,
-                                                    operTx, confTx);
+                                                operTx, confTx);
                                         }
                                     }
                                     LOG.info("update: Adjacency {} with nextHop {} label {} subnet {} removed from"
@@ -1694,7 +1711,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     public synchronized void importSubnetRouteForNewVpn(String rd, String prefix, String nextHop, int label,
-        SubnetRoute route, String parentVpnRd, WriteTransaction writeConfigTxn) {
+        SubnetRoute route, String parentVpnRd, TypedWriteTransaction<Configuration> writeConfigTxn) {
 
         RouteOrigin origin = RouteOrigin.SELF_IMPORTED;
         VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, origin, parentVpnRd)
@@ -1705,7 +1722,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
         InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
         VrfTables vrfTableNew = new VrfTablesBuilder().setRouteDistinguisher(rd).setVrfEntry(vrfEntryList).build();
         if (writeConfigTxn != null) {
-            writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew, true);
+            writeConfigTxn.merge(vrfTableId, vrfTableNew, CREATE_MISSING_PARENTS);
         } else {
             vpnUtil.syncUpdate(LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew);
         }
@@ -1714,8 +1731,10 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     protected void addNewAdjToVpnInterface(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, String primaryRd,
-                                           Adjacency adj, BigInteger dpnId, WriteTransaction writeOperTxn,
-                                           WriteTransaction writeConfigTxn) {
+                                           Adjacency adj, BigInteger dpnId,
+                                           TypedWriteTransaction<Operational> writeOperTxn,
+                                           TypedWriteTransaction<Configuration> writeConfigTxn)
+            throws ExecutionException, InterruptedException {
         String interfaceName = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class).getName();
         String configVpnName = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class).getVpnInstanceName();
         try {
@@ -1820,7 +1839,6 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                     String parentVpnRd = getParentVpnRdForExternalSubnet(adj);
 
                     writeOperTxn.merge(
-                            LogicalDatastoreType.OPERATIONAL,
                             VpnUtil.getPrefixToInterfaceIdentifier(vpnUtil.getVpnId(adj.getSubnetId().getValue()),
                                     prefix), pnfPrefix, true);
 
@@ -1840,7 +1858,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                 aug, dpnId, currVpnIntf.getLportTag(),
                                 currVpnIntf.getGatewayMacAddress());
 
-                writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf, true);
+                writeOperTxn.merge(identifier, newVpnIntf, CREATE_MISSING_PARENTS);
             }
         } catch (ReadFailedException e) {
             LOG.error("addNewAdjToVpnInterface: Failed to read data store for interface {} dpn {} vpn {} rd {} ip "
@@ -1854,7 +1872,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     protected void delAdjFromVpnInterface(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, Adjacency adj,
-            BigInteger dpnId, WriteTransaction writeOperTxn, WriteTransaction writeConfigTxn) {
+                                            BigInteger dpnId, TypedWriteTransaction<Operational> writeOperTxn,
+                                            TypedWriteTransaction<Configuration> writeConfigTxn) {
         String interfaceName = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class).getName();
         String vpnName = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class).getVpnInstanceName();
         try {
@@ -1906,7 +1925,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     private void deleteExtraRouteFromCurrentAndImportingVpns(String vpnName, String destination, String nextHop,
-        String rd, String intfName, WriteTransaction writeConfigTxn, WriteTransaction writeOperTx) {
+                                    String rd, String intfName, TypedWriteTransaction<Configuration> writeConfigTxn,
+                                    TypedWriteTransaction<Operational> writeOperTx) {
         vpnManager.delExtraRoute(vpnName, destination, nextHop, rd, vpnName, intfName, writeConfigTxn, writeOperTx);
         List<VpnInstanceOpDataEntry> vpnsToImportRoute = vpnUtil.getVpnsImportingMyRoute(vpnName);
         for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
@@ -1930,7 +1950,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     protected void createFibEntryForRouterInterface(String primaryRd, VpnInterface vpnInterface, String interfaceName,
-                                                    WriteTransaction writeConfigTxn, String vpnName) {
+                                                TypedWriteTransaction<Configuration> writeConfigTxn, String vpnName) {
         if (vpnInterface == null) {
             return;
         }
@@ -1965,7 +1985,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     protected void deleteFibEntryForRouterInterface(VpnInterface vpnInterface,
-                                                    WriteTransaction writeConfigTxn, String vpnName) {
+            TypedWriteTransaction<Configuration> writeConfigTxn, String vpnName) {
         Adjacencies adjs = vpnInterface.augmentation(Adjacencies.class);
         String rd = vpnUtil.getVpnRd(vpnName);
         if (adjs != null) {
@@ -2170,11 +2190,13 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                     // if the oper tx goes in
                                     if (vpnUtil.isAdjacencyEligibleToVpn(adjacency, vpnName)) {
                                         List<ListenableFuture<Void>> futures = new ArrayList<>();
-                                        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(operTx ->
-                                            futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                                                confTx -> addNewAdjToVpnInterface(existingVpnInterfaceId,
-                                                    primaryRd, adjacency, vpnInterfaceOptional.get()
-                                                        .getDpnId(), confTx, operTx)))));
+                                        futures.add(
+                                            txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx ->
+                                                futures.add(
+                                                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                                                        confTx -> addNewAdjToVpnInterface(existingVpnInterfaceId,
+                                                            primaryRd, adjacency, vpnInterfaceOptional.get()
+                                                                .getDpnId(), operTx, confTx)))));
                                         return futures;
                                     } else {
                                         return Collections.emptyList();
index 80597432e21ca7264f2975762a42eb92a47173bc..e04f3297269545d0ec80b5ebf361f34aaf7193ee 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -17,12 +18,13 @@ import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Singleton;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 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;
@@ -31,7 +33,6 @@ 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.TransactionAdapter;
 import org.opendaylight.genius.infra.TypedReadTransaction;
 import org.opendaylight.genius.infra.TypedReadWriteTransaction;
 import org.opendaylight.genius.infra.TypedWriteTransaction;
@@ -191,24 +192,7 @@ public class VpnManagerImpl implements IVpnManager {
     @Override
     public void addExtraRoute(String vpnName, String destination, String nextHop, String rd, String routerID,
         Long l3vni, RouteOrigin origin, String intfName, Adjacency operationalAdj, VrfEntry.EncapType encapType,
-        TypedWriteTransaction<Configuration> confTx) {
-        addExtraRoute(vpnName, destination, nextHop, rd, routerID, l3vni, origin, intfName, operationalAdj, encapType,
-            TransactionAdapter.toWriteTransaction(confTx));
-    }
-
-    @Override
-    public void addExtraRoute(String vpnName, String destination, String nextHop, String rd, String routerID,
-            Long l3vni, RouteOrigin origin, String intfName, Adjacency operationalAdj,
-            VrfEntry.EncapType encapType, WriteTransaction writeConfigTxn) {
-        if (writeConfigTxn == null) {
-            String finalNextHop = nextHop;
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-                addExtraRoute(vpnName, destination, finalNextHop, rd, routerID, l3vni, origin, intfName, operationalAdj,
-                        encapType, tx)),
-                    LOG, "Error adding extra route");
-            return;
-        }
-
+        @Nonnull TypedWriteTransaction<Configuration> confTx) {
         //add extra route to vpn mapping; advertise with nexthop as tunnel ip
         vpnUtil.syncUpdate(LogicalDatastoreType.OPERATIONAL,
                 VpnExtraRouteHelper.getVpnToExtrarouteVrfIdIdentifier(vpnName, rd != null ? rd : routerID,
@@ -263,7 +247,7 @@ public class VpnManagerImpl implements IVpnManager {
                     L3vpnInput input = new L3vpnInput().setNextHop(operationalAdj).setNextHopIp(nextHop).setL3vni(l3vni)
                             .setPrimaryRd(primaryRd).setVpnName(vpnName).setDpnId(dpnId)
                             .setEncapType(encapType).setRd(rd).setRouteOrigin(origin);
-                    L3vpnRegistry.getRegisteredPopulator(encapType).populateFib(input, writeConfigTxn);
+                    L3vpnRegistry.getRegisteredPopulator(encapType).populateFib(input, confTx);
                 }
             }
         }
@@ -271,26 +255,8 @@ public class VpnManagerImpl implements IVpnManager {
 
     @Override
     public void delExtraRoute(String vpnName, String destination, String nextHop, String rd, String routerID,
-        String intfName, TypedWriteTransaction<Configuration> confTx, TypedWriteTransaction<Operational> operTx) {
-        delExtraRoute(vpnName, destination, nextHop, rd, routerID, intfName,
-            TransactionAdapter.toWriteTransaction(confTx), TransactionAdapter.toWriteTransaction(operTx));
-    }
-
-    @Override
-    public void delExtraRoute(String vpnName, String destination, String nextHop, String rd, String routerID,
-            String intfName, WriteTransaction writeConfigTxn, WriteTransaction writeOperTx) {
-        if (writeConfigTxn == null) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
-                delExtraRoute(vpnName, destination, nextHop, rd, routerID, intfName, tx, writeOperTx);
-            }), LOG, "Error deleting extra route");
-            return;
-        }
-        if (writeOperTx == null) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
-                delExtraRoute(vpnName, destination, nextHop, rd, routerID, intfName, writeConfigTxn, tx);
-            }), LOG, "Error deleting extra route");
-            return;
-        }
+                              String intfName, @Nonnull TypedWriteTransaction<Configuration> confTx,
+                              @Nonnull TypedWriteTransaction<Operational> operTx) {
         BigInteger dpnId = null;
         String tunnelIp = nextHop;
         if (intfName != null && !intfName.isEmpty()) {
@@ -305,40 +271,31 @@ public class VpnManagerImpl implements IVpnManager {
         }
         if (rd != null) {
             String primaryRd = vpnUtil.getVpnRd(vpnName);
-            removePrefixFromBGP(vpnName, primaryRd, rd, intfName, destination, nextHop, tunnelIp, dpnId,
-                    writeConfigTxn, writeOperTx);
+            removePrefixFromBGP(vpnName, primaryRd, rd, intfName, destination,
+                                nextHop, tunnelIp, dpnId, confTx, operTx);
             LOG.info("delExtraRoute: Removed extra route {} from interface {} for rd {}", destination, intfName, rd);
         } else {
             // add FIB route directly
-            fibManager.removeOrUpdateFibEntry(routerID, destination, tunnelIp, writeConfigTxn);
+            fibManager.removeOrUpdateFibEntry(routerID, destination, tunnelIp, confTx);
             LOG.info("delExtraRoute: Removed extra route {} from interface {} for rd {}", destination, intfName,
                     routerID);
         }
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void removePrefixFromBGP(String vpnName, String primaryRd, String extraRouteRd, String vpnInterfaceName,
                                     String prefix, String nextHop, String nextHopTunnelIp, BigInteger dpnId,
                                     TypedWriteTransaction<Configuration> confTx,
                                     TypedWriteTransaction<Operational> operTx) {
-        removePrefixFromBGP(vpnName, primaryRd, extraRouteRd, vpnInterfaceName, prefix, nextHop, nextHopTunnelIp,
-                dpnId, TransactionAdapter.toWriteTransaction(confTx), TransactionAdapter.toWriteTransaction(operTx));
-    }
-
-    // TODO Clean up the exception handling
-    @Override
-    @SuppressWarnings("checkstyle:IllegalCatch")
-    public void removePrefixFromBGP(String vpnName, String primaryRd, String extraRouteRd, String vpnInterfaceName,
-        String prefix, String nextHop, String nextHopTunnelIp, BigInteger dpnId, WriteTransaction writeConfigTxn,
-        WriteTransaction writeOperTx) {
         try {
             String vpnNamePrefixKey = VpnUtil.getVpnNamePrefixKey(vpnName, prefix);
             synchronized (vpnNamePrefixKey.intern()) {
                 if (vpnUtil.removeOrUpdateDSForExtraRoute(vpnName, primaryRd, extraRouteRd, vpnInterfaceName, prefix,
-                        nextHop, nextHopTunnelIp, writeOperTx)) {
+                        nextHop, nextHopTunnelIp, operTx)) {
                     return;
                 }
-                fibManager.removeOrUpdateFibEntry(primaryRd, prefix, nextHopTunnelIp, writeConfigTxn);
+                fibManager.removeOrUpdateFibEntry(primaryRd, prefix, nextHopTunnelIp, confTx);
                 if (VpnUtil.isEligibleForBgp(extraRouteRd, vpnName, dpnId, null /*networkName*/)) {
                     // TODO: Might be needed to include nextHop here
                     bgpManager.withdrawPrefix(extraRouteRd, prefix);
@@ -379,13 +336,6 @@ public class VpnManagerImpl implements IVpnManager {
             (vpnId, dpId, subnetVpnId) -> addGwMac(srcMacAddress, confTx, vpnId, dpId, subnetVpnId));
     }
 
-    @Override
-    public void addSubnetMacIntoVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
-            BigInteger dpnId, WriteTransaction tx) throws ExecutionException, InterruptedException {
-        setupSubnetMacInVpnInstance(vpnName, subnetVpnName, srcMacAddress, dpnId,
-            (vpnId, dpId, subnetVpnId) -> addGwMac(srcMacAddress, tx, vpnId, dpId, subnetVpnId));
-    }
-
     @Override
     public void removeSubnetMacFromVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
             BigInteger dpnId, TypedReadWriteTransaction<Configuration> confTx)
@@ -394,13 +344,6 @@ public class VpnManagerImpl implements IVpnManager {
             (vpnId, dpId, subnetVpnId) -> removeGwMac(srcMacAddress, confTx, vpnId, dpId, subnetVpnId));
     }
 
-    @Override
-    public void removeSubnetMacFromVpnInstance(String vpnName, String subnetVpnName, String srcMacAddress,
-            BigInteger dpnId, WriteTransaction tx) throws ExecutionException, InterruptedException {
-        setupSubnetMacInVpnInstance(vpnName, subnetVpnName, srcMacAddress, dpnId,
-            (vpnId, dpId, subnetVpnId) -> removeGwMac(srcMacAddress, tx, vpnId, dpId, subnetVpnId));
-    }
-
     @FunctionalInterface
     private interface VpnInstanceSubnetMacSetupMethod {
         void process(long vpnId, BigInteger dpId, long subnetVpnId) throws InterruptedException, ExecutionException;
@@ -426,22 +369,15 @@ public class VpnManagerImpl implements IVpnManager {
         }
     }
 
-    private void addGwMac(String srcMacAddress, WriteTransaction tx, long vpnId, BigInteger dpId, long subnetVpnId) {
-        FlowEntity flowEntity = vpnUtil.buildL3vpnGatewayFlow(dpId, srcMacAddress, vpnId, subnetVpnId);
-        mdsalManager.addFlowToTx(flowEntity, tx);
-    }
-
     private void addGwMac(String srcMacAddress, TypedWriteTransaction<Configuration> tx, long vpnId, BigInteger dpId,
         long subnetVpnId) {
         FlowEntity flowEntity = vpnUtil.buildL3vpnGatewayFlow(dpId, srcMacAddress, vpnId, subnetVpnId);
         mdsalManager.addFlow(tx, flowEntity);
     }
 
-    private void removeGwMac(String srcMacAddress, WriteTransaction tx, long vpnId, BigInteger dpId, long subnetVpnId) {
-        FlowEntity flowEntity = vpnUtil.buildL3vpnGatewayFlow(dpId, srcMacAddress, vpnId, subnetVpnId);
-        mdsalManager.removeFlowToTx(flowEntity, tx);
-    }
-
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeGwMac(String srcMacAddress, TypedReadWriteTransaction<Configuration> tx, long vpnId,
             BigInteger dpId, long subnetVpnId) throws ExecutionException, InterruptedException {
         mdsalManager.removeFlow(tx, dpId,
@@ -457,13 +393,6 @@ public class VpnManagerImpl implements IVpnManager {
             vpnId -> addSubnetMacIntoVpnInstance(vpnId, subnetVpnName, routerGwMac, dpnId, confTx), "Installing");
     }
 
-    @Override
-    public void addRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
-            String subnetVpnName, WriteTransaction writeTx) throws ExecutionException, InterruptedException {
-        setupRouterGwMacFlow(routerName, routerGwMac, dpnId, extNetworkId, writeTx,
-            (vpnId, tx) -> addSubnetMacIntoVpnInstance(vpnId, subnetVpnName, routerGwMac, dpnId, tx), "Installing");
-    }
-
     @Override
     public void removeRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
             String subnetVpnName, TypedReadWriteTransaction<Configuration> confTx)
@@ -472,48 +401,6 @@ public class VpnManagerImpl implements IVpnManager {
             vpnId -> removeSubnetMacFromVpnInstance(vpnId, subnetVpnName, routerGwMac, dpnId, confTx), "Removing");
     }
 
-    @Override
-    public void removeRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
-            String subnetVpnName, WriteTransaction writeTx) throws ExecutionException, InterruptedException {
-        setupRouterGwMacFlow(routerName, routerGwMac, dpnId, extNetworkId, writeTx,
-            (vpnId, tx) -> removeSubnetMacFromVpnInstance(vpnId, subnetVpnName, routerGwMac, dpnId, tx), "Removing");
-    }
-
-    @FunctionalInterface
-    private interface RouterGwMacFlowSetupMethod {
-        void process(String vpnId, WriteTransaction tx) throws InterruptedException, ExecutionException;
-    }
-
-    private void setupRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
-            WriteTransaction writeTx, RouterGwMacFlowSetupMethod consumer, String operation)
-            throws ExecutionException, InterruptedException {
-        if (routerGwMac == null) {
-            LOG.warn("Failed to handle router GW flow in GW-MAC table. MAC address is missing for router-id {}",
-                    routerName);
-            return;
-        }
-
-        if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
-            LOG.info("setupRouterGwMacFlow: DPN id is missing for router-id {}",
-                    routerName);
-            return;
-        }
-
-        Uuid vpnId = vpnUtil.getExternalNetworkVpnId(extNetworkId);
-        if (vpnId == null) {
-            LOG.warn("Network {} is not associated with VPN", extNetworkId.getValue());
-            return;
-        }
-
-        LOG.info("{} router GW MAC flow for router-id {} on switch {}", operation, routerName, dpnId);
-        if (writeTx == null) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                tx -> consumer.process(vpnId.getValue(), tx)), LOG, "Commit transaction");
-        } else {
-            consumer.process(vpnId.getValue(), writeTx);
-        }
-    }
-
     private void setupRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId,
             InterruptibleCheckedConsumer<String, ExecutionException> consumer, String operation)
             throws ExecutionException, InterruptedException {
@@ -539,12 +426,6 @@ public class VpnManagerImpl implements IVpnManager {
         consumer.accept(vpnId.getValue());
     }
 
-    @Override
-    public void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress,
-        BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx) {
-        addArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId);
-    }
-
     @Override
     public void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress,
             BigInteger dpnId, Uuid extNetworkId) {
index 8e84209f822c56a2e6e3f9a4cbc52a98d6481567..56a3afd49d6a3c440e9c4e3aa41a2a58ce958e74 100644 (file)
@@ -7,21 +7,26 @@
  */
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutionException;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
+import org.opendaylight.genius.infra.Datastore.Configuration;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
@@ -112,7 +117,7 @@ public class VpnNodeListener extends AsyncClusteredDataTreeChangeListenerBase<No
 
     private void processNodeAdd(BigInteger dpId) {
         jobCoordinator.enqueueJob("VPNNODE-" + dpId.toString(),
-            () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+            () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
                 LOG.debug("Received notification to install TableMiss entries for dpn {} ", dpId);
                 makeTableMissFlow(tx, dpId, NwConstants.ADD_FLOW);
                 makeL3IntfTblMissFlow(tx, dpId, NwConstants.ADD_FLOW);
@@ -124,7 +129,8 @@ public class VpnNodeListener extends AsyncClusteredDataTreeChangeListenerBase<No
             })), 3);
     }
 
-    private void makeTableMissFlow(WriteTransaction writeFlowTx, BigInteger dpnId, int addOrRemove) {
+    private void makeTableMissFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId, int addOrRemove)
+            throws ExecutionException, InterruptedException {
         final BigInteger cookieTableMiss = new BigInteger("1030000", 16);
         // Instruction to goto L3 InterfaceTable
         List<InstructionInfo> instructions =
@@ -136,13 +142,14 @@ public class VpnNodeListener extends AsyncClusteredDataTreeChangeListenerBase<No
 
         if (addOrRemove == NwConstants.ADD_FLOW) {
             LOG.debug("Invoking MDSAL to install Table Miss Entry");
-            mdsalManager.addFlowToTx(flowEntityLfib, writeFlowTx);
+            mdsalManager.addFlow(confTx, flowEntityLfib);
         } else {
-            mdsalManager.removeFlowToTx(flowEntityLfib, writeFlowTx);
+            mdsalManager.removeFlow(confTx, flowEntityLfib);
         }
     }
 
-    private void makeL3IntfTblMissFlow(WriteTransaction writeFlowTx, BigInteger dpnId, int addOrRemove) {
+    private void makeL3IntfTblMissFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
+            int addOrRemove) throws ExecutionException, InterruptedException {
         List<InstructionInfo> instructions = new ArrayList<>();
         List<MatchInfo> matches = new ArrayList<>();
         final BigInteger cookieTableMiss = new BigInteger("1030000", 16);
@@ -159,13 +166,14 @@ public class VpnNodeListener extends AsyncClusteredDataTreeChangeListenerBase<No
             matches, instructions);
         if (addOrRemove == NwConstants.ADD_FLOW) {
             LOG.debug("Invoking MDSAL to install L3 interface Table Miss Entries");
-            mdsalManager.addFlowToTx(flowEntityL3Intf, writeFlowTx);
+            mdsalManager.addFlow(confTx, flowEntityL3Intf);
         } else {
-            mdsalManager.removeFlowToTx(flowEntityL3Intf, writeFlowTx);
+            mdsalManager.removeFlow(confTx, flowEntityL3Intf);
         }
     }
 
-    private void makeSubnetRouteTableMissFlow(WriteTransaction writeFlowTx, BigInteger dpnId, int addOrRemove) {
+    private void makeSubnetRouteTableMissFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
+            int addOrRemove) throws ExecutionException, InterruptedException {
         List<ActionInfo> actionsInfos = new ArrayList<>();
         List<InstructionInfo> instructions = new ArrayList<>();
         actionsInfos.add(new ActionPuntToController());
@@ -197,13 +205,14 @@ public class VpnNodeListener extends AsyncClusteredDataTreeChangeListenerBase<No
                 NwConstants.COOKIE_SUBNET_ROUTE_TABLE_MISS, matches, instructions);
 
         if (addOrRemove == NwConstants.ADD_FLOW) {
-            mdsalManager.addFlowToTx(flowEntity, writeFlowTx);
+            mdsalManager.addFlow(confTx, flowEntity);
         } else {
-            mdsalManager.removeFlowToTx(flowEntity, writeFlowTx);
+            mdsalManager.removeFlow(confTx, flowEntity);
         }
     }
 
-    private void makeIpv6SubnetRouteTableMissFlow(WriteTransaction writeFlowTx, BigInteger dpnId, int addOrRemove) {
+    private void makeIpv6SubnetRouteTableMissFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
+            int addOrRemove) throws ExecutionException, InterruptedException {
         List<ActionInfo> actionsInfos = new ArrayList<>();
         List<InstructionInfo> instructions = new ArrayList<>();
         actionsInfos.add(new ActionPuntToController());
@@ -236,14 +245,15 @@ public class VpnNodeListener extends AsyncClusteredDataTreeChangeListenerBase<No
                 NwConstants.COOKIE_SUBNET_ROUTE_TABLE_MISS, matches, instructions);
         if (addOrRemove == NwConstants.ADD_FLOW) {
             LOG.debug("makeIpv6SubnetRouteTableMissFlow: Install Ipv6 Subnet Route Table Miss entry");
-            mdsalManager.addFlowToTx(flowEntity, writeFlowTx);
+            mdsalManager.addFlow(confTx, flowEntity);
         } else {
             LOG.debug("makeIpv6SubnetRouteTableMissFlow: Remove Ipv6 Subnet Route Table Miss entry");
-            mdsalManager.removeFlowToTx(flowEntity, writeFlowTx);
+            mdsalManager.removeFlow(confTx, flowEntity);
         }
     }
 
-    private void programTableMissForVpnVniDemuxTable(WriteTransaction writeFlowTx, BigInteger dpnId, int addOrRemove) {
+    private void programTableMissForVpnVniDemuxTable(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
+            int addOrRemove) throws ExecutionException, InterruptedException {
         List<ActionInfo> actionsInfos = Collections.singletonList(new ActionNxResubmit(NwConstants
                 .LPORT_DISPATCHER_TABLE));
         List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(actionsInfos));
@@ -255,13 +265,13 @@ public class VpnNodeListener extends AsyncClusteredDataTreeChangeListenerBase<No
                 new BigInteger("1080000", 16), matches, instructions);
 
         if (addOrRemove == NwConstants.ADD_FLOW) {
-            mdsalManager.addFlowToTx(flowEntity, writeFlowTx);
+            mdsalManager.addFlow(confTx, flowEntity);
         } else {
-            mdsalManager.removeFlowToTx(flowEntity, writeFlowTx);
+            mdsalManager.removeFlow(confTx, flowEntity);
         }
     }
 
-    private void createTableMissForVpnGwFlow(WriteTransaction writeFlowTx, BigInteger dpId) {
+    private void createTableMissForVpnGwFlow(TypedWriteTransaction<Configuration> confTx, BigInteger dpId) {
         List<MatchInfo> matches = new ArrayList<>();
         List<ActionInfo> actionsInfos =
                 Collections.singletonList(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
@@ -271,20 +281,20 @@ public class VpnNodeListener extends AsyncClusteredDataTreeChangeListenerBase<No
             NwConstants.TABLE_MISS_PRIORITY, "L3 Gw Mac Table Miss", 0, 0, new BigInteger("1080000", 16), matches,
             instructions);
         LOG.trace("Invoking MDSAL to install L3 Gw Mac Table Miss Entry");
-        mdsalManager.addFlowToTx(flowEntityMissforGw, writeFlowTx);
+        mdsalManager.addFlow(confTx, flowEntityMissforGw);
     }
 
-    private void createL3GwMacArpFlows(WriteTransaction writeFlowTx, BigInteger dpId) {
+    private void createL3GwMacArpFlows(TypedWriteTransaction<Configuration> confTx, BigInteger dpId) {
         FlowEntity arpReqGwMacTbl = ArpResponderUtil.createArpDefaultFlow(dpId, NwConstants.L3_GW_MAC_TABLE,
                 NwConstants.ARP_REQUEST, () -> Arrays.asList(MatchEthernetType.ARP, MatchArpOp.REQUEST),
             () -> Collections.singletonList(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE)));
         LOG.trace("Invoking MDSAL to install Arp Rquest Match Flow for table {}", NwConstants.L3_GW_MAC_TABLE);
-        mdsalManager.addFlowToTx(arpReqGwMacTbl, writeFlowTx);
+        mdsalManager.addFlow(confTx, arpReqGwMacTbl);
         FlowEntity arpRepGwMacTbl = ArpResponderUtil.createArpDefaultFlow(dpId, NwConstants.L3_GW_MAC_TABLE,
                 NwConstants.ARP_REPLY, () -> Arrays.asList(MatchEthernetType.ARP, MatchArpOp.REPLY),
             () -> Collections.singletonList(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE)));
         LOG.trace("Invoking MDSAL to install  Arp Reply Match Flow for Table {} ", NwConstants.L3_GW_MAC_TABLE);
-        mdsalManager.addFlowToTx(arpRepGwMacTbl, writeFlowTx);
+        mdsalManager.addFlow(confTx, arpRepGwMacTbl);
     }
 
     private String getTableMissFlowRef(BigInteger dpnId, short tableId, int tableMiss) {
index f645acbf8075af8c06327aece46a30cf71979c61..47c8f1d1d702ffc27f6b382bc770dc9defcf32ba 100644 (file)
@@ -7,16 +7,20 @@
  */
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.concurrent.ExecutionException;
 import java.util.function.Consumer;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
+import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
 import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
 import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
@@ -24,7 +28,6 @@ import org.opendaylight.netvirt.vpnmanager.api.IVpnManager;
 import org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkCache;
 import org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite;
 import org.opendaylight.netvirt.vpnmanager.intervpnlink.InterVpnLinkUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.AddStaticRouteInput;
@@ -52,8 +55,7 @@ import org.slf4j.helpers.MessageFormatter;
 @Singleton
 public class VpnRpcServiceImpl implements VpnRpcService {
     private static final Logger LOG = LoggerFactory.getLogger(VpnRpcServiceImpl.class);
-    private final DataBroker dataBroker;
-    private final IdManagerService idManager;
+    private final ManagedNewTransactionRunner txRunner;
     private final IFibManager fibManager;
     private final IBgpManager bgpManager;
     private final IVpnManager vpnManager;
@@ -62,11 +64,10 @@ public class VpnRpcServiceImpl implements VpnRpcService {
     private final InterVpnLinkUtil interVpnLinkUtil;
 
     @Inject
-    public VpnRpcServiceImpl(final DataBroker dataBroker, final IdManagerService idManager,
+    public VpnRpcServiceImpl(final DataBroker dataBroker,
             final IFibManager fibManager, IBgpManager bgpManager, final IVpnManager vpnManager,
             final InterVpnLinkCache interVpnLinkCache, VpnUtil vpnUtil, InterVpnLinkUtil interVpnLinkUtil) {
-        this.dataBroker = dataBroker;
-        this.idManager = idManager;
+        this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
         this.fibManager = fibManager;
         this.bgpManager = bgpManager;
         this.vpnManager = vpnManager;
@@ -184,9 +185,17 @@ public class VpnRpcServiceImpl implements VpnRpcService {
                 return result;
             }
         } else {
-            vpnManager.addExtraRoute(vpnInstanceName, destination, nexthop, vpnRd, null /* routerId */,
-                    vpnOpEntry.getL3vni(), RouteOrigin.STATIC, null /* intfName */,
-                            null /*Adjacency*/, encapType, (WriteTransaction) null);
+            try {
+                txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                    confTx -> vpnManager.addExtraRoute(vpnInstanceName, destination, nexthop, vpnRd,
+                            null /* routerId */, vpnOpEntry.getL3vni(), RouteOrigin.STATIC, null /* intfName */,
+                        null /*Adjacency*/, encapType, confTx)).get();
+            } catch (InterruptedException | ExecutionException e) {
+                LOG.error("Error adding static route {}", input, e);
+                result.set(RpcResultBuilder.<AddStaticRouteOutput>failed().withError(ErrorType.APPLICATION,
+                    "Error adding static route " + input, e).build());
+                return result;
+            }
         }
 
         AddStaticRouteOutput labelOutput = new AddStaticRouteOutputBuilder().setLabel(label).build();
@@ -244,12 +253,13 @@ public class VpnRpcServiceImpl implements VpnRpcService {
             bgpManager.withdrawPrefix(vpnRd, destination);
         } else {
             vpnManager.delExtraRoute(vpnInstanceName, destination,
-                    nexthop, vpnRd, null /* routerId */, null /* intfName */, (WriteTransaction) null,
-                    (WriteTransaction) null);
+                    nexthop, vpnRd, null /* routerId */, null /* intfName */, null,
+                    null);
         }
         result.set(RpcResultBuilder.success(new RemoveStaticRouteOutputBuilder().build()).build());
 
         return result;
+
     }
 
     private String formatAndLog(Consumer<String> logger, String template, Object arg1, Object arg2) {
index 9df6af92d68f0d94efa24c75d7a1571e4288fc8a..0de063566460a7e57e4c05d93d6b3d9a3422f865 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -25,11 +24,8 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
 import org.opendaylight.netvirt.vpnmanager.api.VpnHelper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
@@ -51,7 +47,6 @@ public class VpnServiceElanDpnInterfacesListener
     private final IInterfaceManager interfaceManager;
     private final IFibManager fibManager;
     private final JobCoordinator jobCoordinator;
-    private final ManagedNewTransactionRunner txRunner;
     private final VpnUtil vpnUtil;
 
     @Inject
@@ -61,7 +56,6 @@ public class VpnServiceElanDpnInterfacesListener
         this.interfaceManager = interfaceManager;
         this.fibManager = fibManager;
         this.jobCoordinator = jobCoordinator;
-        this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
         this.vpnUtil = vpnUtil;
     }
 
@@ -95,39 +89,34 @@ public class VpnServiceElanDpnInterfacesListener
         String primaryRd = vpnUtil.getPrimaryRd(vpnName);
         if (elanInstance != null && !elanInstance.isExternal() && VpnUtil.isVlan(elanInstance)) {
             jobCoordinator.enqueueJob(elanInstance.getElanInstanceName(), () -> {
-                ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
-                    List<String> addedInterfaces = getUpdatedInterfaceList(update.getInterfaces(),
-                            original.getInterfaces());
-                    for (String addedInterface: addedInterfaces) {
-                        if (interfaceManager.isExternalInterface(addedInterface)) {
-                            InstanceIdentifier<VpnToDpnList> id = VpnHelper.getVpnToDpnListIdentifier(primaryRd,
-                                    dpnId);
-                            Optional<VpnToDpnList> dpnInVpn = SingleTransactionDataBroker.syncReadOptional(dataBroker,
-                                    LogicalDatastoreType.OPERATIONAL, id);
-                            if (!dpnInVpn.isPresent() || (dpnInVpn.get().getVpnInterfaces() != null
-                                    && dpnInVpn.get().getVpnInterfaces().size() != 1)) {
-                                return;
-                            }
-                            if (!vpnUtil.shouldPopulateFibForVlan(vpnName, elanInstanceName, dpnId)) {
-                                return;
-                            }
-                            long vpnId = vpnUtil.getVpnId(vpnName);
-                            fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, null);
-                            break;
+                List<String> addedInterfaces = getUpdatedInterfaceList(update.getInterfaces(),
+                    original.getInterfaces());
+                for (String addedInterface : addedInterfaces) {
+                    if (interfaceManager.isExternalInterface(addedInterface)) {
+                        InstanceIdentifier<VpnToDpnList> id = VpnHelper.getVpnToDpnListIdentifier(primaryRd, dpnId);
+                        Optional<VpnToDpnList> dpnInVpn = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+                            LogicalDatastoreType.OPERATIONAL, id);
+                        if (!dpnInVpn.isPresent() || (dpnInVpn.get().getVpnInterfaces() != null
+                            && dpnInVpn.get().getVpnInterfaces().size() != 1)) {
+                            return Collections.emptyList();
                         }
-                    }
-                    List<String> deletedInterfaces = getUpdatedInterfaceList(original.getInterfaces(),
-                            update.getInterfaces());
-                    if (!deletedInterfaces.isEmpty()) {
-                        String routerPortUuid = vpnUtil.getRouterPordIdFromElanInstance(elanInstanceName);
-                        if (update.getInterfaces().size() == 2 && update.getInterfaces().contains(routerPortUuid)) {
-                            vpnUtil.removeRouterPortFromElanForVlanInDpn(vpnName, dpnId);
+                        if (!vpnUtil.shouldPopulateFibForVlan(vpnName, elanInstanceName, dpnId)) {
+                            return Collections.emptyList();
                         }
+                        long vpnId = vpnUtil.getVpnId(vpnName);
+                        fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, null);
+                        break;
+                    }
+                }
+                List<String> deletedInterfaces = getUpdatedInterfaceList(original.getInterfaces(),
+                    update.getInterfaces());
+                if (!deletedInterfaces.isEmpty()) {
+                    String routerPortUuid = vpnUtil.getRouterPordIdFromElanInstance(elanInstanceName);
+                    if (update.getInterfaces().size() == 2 && update.getInterfaces().contains(routerPortUuid)) {
+                        vpnUtil.removeRouterPortFromElanForVlanInDpn(vpnName, dpnId);
                     }
-                });
-                ListenableFutures.addErrorLogging(future, LOG, "Failed to process DpnInterfaces update event for"
-                        + "dpn {} elan {} vpn {}", dpnId, elanInstanceName, vpnName);
-                return Collections.singletonList(future);
+                }
+                return Collections.emptyList();
             });
         }
     }
index 6591b2742444b740d71a6bd2acca9c500eb5c1fb..5922561373441c6719d66373a119da13b9f9376c 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.netvirt.vpnmanager;
 
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
 import com.google.common.base.Optional;
 import com.google.common.collect.Iterators;
 import com.google.common.net.InetAddresses;
@@ -49,6 +51,7 @@ 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.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
@@ -658,7 +661,7 @@ public final class VpnUtil {
 
     public boolean removeOrUpdateDSForExtraRoute(String vpnName, String primaryRd, String extraRouteRd,
                                                  String vpnInterfaceName, String prefix, String nextHop,
-                                                 String nextHopTunnelIp, WriteTransaction operTx) {
+                                                 String nextHopTunnelIp, TypedWriteTransaction<Operational> operTx) {
         LOG.info("removeOrUpdateDSForExtraRoute: VPN WITHDRAW: Removing Fib Entry rd {} prefix {} nexthop {}",
                 extraRouteRd, prefix, nextHop);
         boolean areNextHopsClearedForRd = false;
@@ -679,8 +682,7 @@ public final class VpnUtil {
                 LOG.debug("removeOrUpdateDSForExtraRoute: Removed vpn-to-extraroute with rd {} prefix {} nexthop {}",
                         extraRouteRd, prefix, nextHop);
                 fibManager.refreshVrfEntry(primaryRd, prefix);
-                operTx.delete(LogicalDatastoreType.OPERATIONAL, VpnUtil
-                        .getVpnInterfaceOpDataEntryAdjacencyIdentifier(vpnInterfaceName, vpnName, prefix));
+                operTx.delete(VpnUtil.getVpnInterfaceOpDataEntryAdjacencyIdentifier(vpnInterfaceName, vpnName, prefix));
                 LOG.info("VPN WITHDRAW: removeOrUpdateDSForExtraRoute: Removed Fib Entry rd {} prefix {} nexthop {}",
                         extraRouteRd, prefix, nextHopTunnelIp);
                 areNextHopsClearedForRd = true;
@@ -860,39 +862,32 @@ public final class VpnUtil {
             new ElanTagNameKey(elanTag)).build();
     }
 
-    static void removePrefixToInterfaceForVpnId(long vpnId,
-                                                       @Nonnull TypedWriteTransaction<Operational> operTx) {
+    static void removePrefixToInterfaceForVpnId(long vpnId, @Nonnull TypedWriteTransaction<Operational> operTx) {
         // Clean up PrefixToInterface Operational DS
         operTx.delete(InstanceIdentifier.builder(
                     PrefixToInterface.class).child(VpnIds.class, new VpnIdsKey(vpnId)).build());
     }
 
-    static void removeVpnExtraRouteForVpn(String vpnName,
-                                                    @Nonnull TypedWriteTransaction<Operational> operTx) {
+    static void removeVpnExtraRouteForVpn(String vpnName, @Nonnull TypedWriteTransaction<Operational> operTx) {
         // Clean up VPNExtraRoutes Operational DS
         operTx.delete(InstanceIdentifier.builder(VpnToExtraroutes.class).child(Vpn.class, new VpnKey(vpnName)).build());
     }
 
-    // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
-    static void removeVpnOpInstance(String vpnName,
-                                                    @Nonnull TypedWriteTransaction<Operational> operTx) {
+    static void removeVpnOpInstance(String vpnName, @Nonnull TypedWriteTransaction<Operational> operTx) {
         // Clean up VPNInstanceOpDataEntry
         operTx.delete(getVpnInstanceOpDataIdentifier(vpnName));
     }
 
-    static void removeVpnInstanceToVpnId(String vpnName,
-                                                @Nonnull TypedWriteTransaction<Configuration> confTx) {
+    static void removeVpnInstanceToVpnId(String vpnName, @Nonnull TypedWriteTransaction<Configuration> confTx) {
         confTx.delete(VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnName));
     }
 
-    static void removeVpnIdToVpnInstance(long vpnId,
-                                                @Nonnull TypedWriteTransaction<Configuration> confTx) {
+    static void removeVpnIdToVpnInstance(long vpnId, @Nonnull TypedWriteTransaction<Configuration> confTx) {
         confTx.delete(getVpnIdToVpnInstanceIdentifier(vpnId));
     }
 
-    static void removeL3nexthopForVpnId(long vpnId,
-                                               @Nonnull TypedWriteTransaction<Operational> operTx) {
+    static void removeL3nexthopForVpnId(long vpnId, @Nonnull TypedWriteTransaction<Operational> operTx) {
         // Clean up L3NextHop Operational DS
         operTx.delete(InstanceIdentifier.builder(L3nexthop.class).child(
                                     VpnNexthops.class, new VpnNexthopsKey(vpnId)).build());
@@ -1150,6 +1145,14 @@ public final class VpnUtil {
         return routerData.isPresent() ? routerData.get() : null;
     }
 
+    @Nullable
+    Routers getExternalRouter(TypedReadTransaction<Configuration> tx, String routerId)
+            throws ExecutionException, InterruptedException {
+        InstanceIdentifier<Routers> id = InstanceIdentifier.builder(ExtRouters.class).child(Routers.class,
+            new RoutersKey(routerId)).build();
+        return tx.read(id).get().orNull();
+    }
+
     static InstanceIdentifier<Subnetmaps> buildSubnetMapsWildCardPath() {
         return InstanceIdentifier.create(Subnetmaps.class);
     }
@@ -1277,12 +1280,13 @@ public final class VpnUtil {
         return gatewayMac;
     }
 
-    void setupGwMacIfExternalVpn(BigInteger dpnId, String interfaceName, long vpnId, WriteTransaction writeInvTxn,
-                                 int addOrRemove, String gwMac) {
+    void setupGwMacIfExternalVpn(BigInteger dpnId, String interfaceName, long vpnId,
+                                 TypedReadWriteTransaction<Configuration> writeInvTxn, int addOrRemove, String gwMac)
+            throws ExecutionException, InterruptedException {
         InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.id.to.vpn.instance
             .VpnIds> vpnIdsInstanceIdentifier = getVpnIdToVpnInstanceIdentifier(vpnId);
         Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.id.to.vpn.instance
-            .VpnIds> vpnIdsOptional = read(LogicalDatastoreType.CONFIGURATION, vpnIdsInstanceIdentifier);
+            .VpnIds> vpnIdsOptional = writeInvTxn.read(vpnIdsInstanceIdentifier).get();
         if (vpnIdsOptional.isPresent() && vpnIdsOptional.get().isExternalVpn()) {
             if (gwMac == null) {
                 LOG.error("setupGwMacIfExternalVpn: Failed to get gwMacAddress for interface {} on dpn {} vpn {}",
@@ -1291,9 +1295,9 @@ public final class VpnUtil {
             }
             FlowEntity flowEntity = buildL3vpnGatewayFlow(dpnId, gwMac, vpnId, VpnConstants.INVALID_ID);
             if (addOrRemove == NwConstants.ADD_FLOW) {
-                mdsalManager.addFlowToTx(flowEntity, writeInvTxn);
+                mdsalManager.addFlow(writeInvTxn, flowEntity);
             } else if (addOrRemove == NwConstants.DEL_FLOW) {
-                mdsalManager.removeFlowToTx(flowEntity, writeInvTxn);
+                mdsalManager.removeFlow(writeInvTxn, flowEntity);
             }
         }
     }
@@ -1792,7 +1796,7 @@ public final class VpnUtil {
 
     ListenableFuture<Void> unsetScheduledToRemoveForVpnInterface(String interfaceName) {
         VpnInterfaceBuilder builder = new VpnInterfaceBuilder().withKey(new VpnInterfaceKey(interfaceName));
-        return txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.OPERATIONAL, tx -> tx.merge(
+        return txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> tx.merge(
                 VpnUtil.getVpnInterfaceIdentifier(interfaceName), builder.build(),
                 WriteTransaction.CREATE_MISSING_PARENTS));
     }
index 8a056bf1dab3e9fbc834c28f11336dc9ba66e0fc..ef49e6cfa1971cc214742c7d5fb8e9f722e221f4 100755 (executable)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.vpnmanager.intervpnlink;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.math.BigInteger;
@@ -183,9 +185,8 @@ public class IVpnLinkServiceImpl implements IVpnLinkService, AutoCloseable {
                               .child(VrfTables.class, new VrfTablesKey(dstVpnRd))
                               .child(VrfEntry.class, new VrfEntryKey(newVrfEntry.getDestPrefix()))
                               .build();
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-            tx.put(LogicalDatastoreType.CONFIGURATION, newVrfEntryIid, newVrfEntry)),
-                LOG, "Error adding VRF entry {}", newVrfEntry);
+        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+            tx.put(newVrfEntryIid, newVrfEntry)), LOG, "Error adding VRF entry {}", newVrfEntry);
 
         // Finally, route is advertised it to the DC-GW. But while in the FibEntries the nexthop is the other
         // endpoint's IP, in the DC-GW the nexthop for those prefixes are the IPs of those DPNs where the target
index 85dbfe1143312ad6170b401d535fa852ad2eb52e..5ef652691bf2712903ce3b682e72d4edb1295a9f 100755 (executable)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.netvirt.vpnmanager.intervpnlink;
 
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
@@ -23,7 +26,6 @@ import javax.inject.Inject;
 import javax.inject.Singleton;
 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.datastoreutils.AsyncDataTreeChangeListenerBase;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
@@ -362,9 +364,8 @@ public class InterVpnLinkListener extends AsyncDataTreeChangeListenerBase<InterV
         // Removing the InterVpnLinkState
         InstanceIdentifier<InterVpnLinkState> interVpnLinkStateIid =
             InterVpnLinkUtil.getInterVpnLinkStateIid(del.getName());
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-            tx.delete(LogicalDatastoreType.CONFIGURATION, interVpnLinkStateIid)), LOG,
-                "Error deleting inter-VPN link state {}", interVpnLinkStateIid);
+        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+            tx.delete(interVpnLinkStateIid)), LOG, "Error deleting inter-VPN link state {}", interVpnLinkStateIid);
     }
 
     // We're catching Exception here to continue deleting as much as possible
@@ -464,9 +465,8 @@ public class InterVpnLinkListener extends AsyncDataTreeChangeListenerBase<InterV
             new InterVpnLinkStateBuilder(vpnLinkState).setState(InterVpnLinkState.State.Error)
                 .setErrorDescription(errorMsg)
                 .build();
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-            tx.put(LogicalDatastoreType.CONFIGURATION, vpnLinkStateIid, vpnLinkErrorState,
-                    WriteTransaction.CREATE_MISSING_PARENTS)),
+        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+            tx.put(vpnLinkStateIid, vpnLinkErrorState, CREATE_MISSING_PARENTS)),
                 LOG, "Error storing the VPN link error state for {}, {}", vpnLinkStateIid, vpnLinkErrorState);
 
         // Sending out an error Notification
index 90f8d8b0718cea257ac117f8c4c615c32c88d3e5..4af10f6b2dc4cbe51b1fdf2c63add9691c313310 100755 (executable)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.netvirt.vpnmanager.intervpnlink;
 
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
@@ -15,8 +18,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-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.mdsalutil.interfaces.IMdsalApiManager;
@@ -112,10 +113,9 @@ public class InterVpnLinkNodeAddTask implements Callable<List<ListenableFuture<V
             new InterVpnLinkStateBuilder(interVpnLinkState).setState(InterVpnLinkState.State.Active)
                     .setFirstEndpointState(firstEndPointState).setSecondEndpointState(secondEndPointState)
                     .build();
-        return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-            tx.merge(LogicalDatastoreType.CONFIGURATION,
-                    InterVpnLinkUtil.getInterVpnLinkStateIid(interVpnLinkState.getInterVpnLinkName()),
-                    newInterVpnLinkState, WriteTransaction.CREATE_MISSING_PARENTS));
+        return txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+            tx.merge(InterVpnLinkUtil.getInterVpnLinkStateIid(interVpnLinkState.getInterVpnLinkName()),
+                    newInterVpnLinkState, CREATE_MISSING_PARENTS));
     }
 
     private void installLPortDispatcherTable(InterVpnLinkState interVpnLinkState, List<BigInteger> firstDpnList,
index d8b881e4545c255cb6d9aa8e5cc4971be721cf9b..2a4e67175ba06fac9d13f76d1cd2dc2822b0e705 100644 (file)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.netvirt.vpnmanager.intervpnlink.tasks;
 
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-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.netvirt.vpnmanager.intervpnlink.InterVpnLinkUtil;
@@ -42,10 +43,9 @@ public class InterVpnLinkCreatorTask implements Callable<List<ListenableFuture<V
             interVpnLinkToPersist.getSecondEndpoint().getVpnUuid(),
             interVpnLinkToPersist.getSecondEndpoint().getIpAddress());
 
-        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-            tx.merge(LogicalDatastoreType.CONFIGURATION,
-                    InterVpnLinkUtil.getInterVpnLinkPath(interVpnLinkToPersist.getName()),
-                    interVpnLinkToPersist, WriteTransaction.CREATE_MISSING_PARENTS)));
+        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+            tx.merge(InterVpnLinkUtil.getInterVpnLinkPath(interVpnLinkToPersist.getName()),
+                    interVpnLinkToPersist, CREATE_MISSING_PARENTS)));
     }
 
 }
index 4ee7e93df4f8fe67a10ed5532c82c9a1333fbbe1..e4034527821c1d0f595eefd64d0d6e2de0be8651 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.netvirt.vpnmanager.intervpnlink.tasks;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink;
@@ -36,7 +37,7 @@ public class InterVpnLinkRemoverTask implements Callable<List<ListenableFuture<V
     @Override
     public List<ListenableFuture<Void>> call() {
         LOG.debug("Removing InterVpnLink {} from storage", interVpnLinkName);
-        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
-            tx.delete(LogicalDatastoreType.CONFIGURATION, this.interVpnLinkIid)));
+        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+            tx.delete(this.interVpnLinkIid)));
     }
 }
index 78ce22f4be0d8577cc847b775530f2500eb68876..203e7abc82d6bd12690761c480601fe8759d4b70 100644 (file)
@@ -16,7 +16,8 @@ import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.genius.infra.Datastore.Configuration;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
 import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
@@ -57,7 +58,7 @@ public class L3vpnOverMplsGrePopulator extends L3vpnPopulator {
     }
 
     @Override
-    public void populateFib(L3vpnInput input, WriteTransaction writeConfigTxn) {
+    public void populateFib(L3vpnInput input, TypedWriteTransaction<Configuration> writeConfigTxn) {
         if (input.getRouteOrigin() == RouteOrigin.CONNECTED) {
             LOG.info("populateFib : Found SubnetRoute for subnet {} rd {}", input.getSubnetIp(), input.getPrimaryRd());
             addSubnetRouteFibEntry(input);
index 9debf0802d3e792ab22fa098c8ad593af5d863e7..e5bc0fd9341d6e0c21d879f50ecedcfde91d8669 100644 (file)
@@ -15,7 +15,8 @@ import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.genius.infra.Datastore.Configuration;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
 import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
@@ -51,7 +52,7 @@ public class L3vpnOverVxlanPopulator extends L3vpnPopulator {
     }
 
     @Override
-    public void populateFib(L3vpnInput input, WriteTransaction writeConfigTxn) {
+    public void populateFib(L3vpnInput input, TypedWriteTransaction<Configuration> writeConfigTxn) {
         if (input.getRouteOrigin() == RouteOrigin.CONNECTED) {
             LOG.info("populateFib : Found SubnetRoute for subnet {} rd {}", input.getSubnetIp(), input.getPrimaryRd());
             addSubnetRouteFibEntry(input);
index 62789a1ea61e954fac00ee18aa31530cfae4b8d7..f47793d4421ca80877693bf8069f1b8df7b4787f 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.vpnmanager.populator.impl;
 
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
 import static org.opendaylight.infrautils.utils.concurrent.ListenableFutures.addErrorLogging;
 
 import com.google.common.base.Optional;
@@ -15,10 +17,11 @@ import java.math.BigInteger;
 import java.util.Collections;
 import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.infra.Datastore.Configuration;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
 import org.opendaylight.netvirt.fibmanager.api.FibHelper;
@@ -67,7 +70,7 @@ public abstract class L3vpnPopulator implements VpnPopulator {
     }
 
     @Override
-    public void populateFib(L3vpnInput input, WriteTransaction writeCfgTxn) {}
+    public void populateFib(L3vpnInput input, TypedWriteTransaction<Configuration> writeCfgTxn) {}
 
     public void addSubnetRouteFibEntry(L3vpnInput input) {
         String rd = input.getRd();
@@ -146,7 +149,7 @@ public abstract class L3vpnPopulator implements VpnPopulator {
             Preconditions.checkNotNull(nextHopIpList, "addToLabelMapper: nextHopIp cannot be null or empty!");
         }
         synchronized (label.toString().intern()) {
-            addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+            addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
                 LOG.info("addToLabelMapper: label {} dpn {} prefix {} nexthoplist {} vpnid {} vpnIntfcName {} rd {}"
                         + " elanTag {}", label, dpnId, prefix, nextHopIpList, vpnId, vpnInterfaceName, rd, elanTag);
                 if (dpnId != null) {
@@ -175,7 +178,7 @@ public abstract class L3vpnPopulator implements VpnPopulator {
                     LabelRouteInfo lri = lriBuilder.build();
                     InstanceIdentifier<LabelRouteInfo> lriIid = InstanceIdentifier.builder(LabelRouteMap.class)
                             .child(LabelRouteInfo.class, new LabelRouteInfoKey(label)).build();
-                    tx.merge(LogicalDatastoreType.OPERATIONAL, lriIid, lri, true);
+                    tx.merge(lriIid, lri, CREATE_MISSING_PARENTS);
                     LOG.info("addToLabelMapper: Added label route info to label {} prefix {} nextHopList {} vpnId {}"
                             + " interface {} rd {} elantag {}", label, prefix, nextHopIpList, vpnId, vpnInterfaceName,
                             rd, elanTag);
@@ -196,7 +199,7 @@ public abstract class L3vpnPopulator implements VpnPopulator {
     @SuppressWarnings("checkstyle:IllegalCatch")
     protected void addPrefixToBGP(String rd, String primaryRd, String macAddress, String prefix, String nextHopIp,
                                   VrfEntry.EncapType encapType, long label, long l3vni, String gatewayMac,
-                                  RouteOrigin origin, WriteTransaction writeConfigTxn) {
+                                  RouteOrigin origin, TypedWriteTransaction<Configuration> writeConfigTxn) {
         try {
             List<String> nextHopList = Collections.singletonList(nextHopIp);
             LOG.info("ADD: addPrefixToBGP: Adding Fib entry rd {} prefix {} nextHop {} label {} gwMac {}", rd, prefix,
index 8b0c80e0c3a6d6ac98e9c0f162675e79dbec6e7f..0cf2ad13b29aba01a9ee6d625bc13250ca6405bf 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.netvirt.vpnmanager.populator.intfc;
 
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.genius.infra.Datastore.Configuration;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency;
 
 public interface VpnPopulator {
-    void populateFib(L3vpnInput input, WriteTransaction writeCfgTxn);
+    void populateFib(L3vpnInput input, TypedWriteTransaction<Configuration> writeCfgTxn);
 
     Adjacency createOperationalAdjacency(L3vpnInput input);
 }