hwvtep transaction batching separation across shards 37/60237/3
authorFaseela K <faseela.k@ericsson.com>
Wed, 12 Jul 2017 09:35:07 +0000 (15:05 +0530)
committerFaseela K <faseela.k@ericsson.com>
Thu, 20 Jul 2017 05:48:26 +0000 (11:18 +0530)
Hwvtep helpers were doing a single transaction for operations
spread across shards, which is not recommended, and hence refactoring
the same. Also, in case of continuous HWVTEP channel flap, there are
some issues observed with tunnels not getting programmed on TOR.
Fixing this by avoiding read on topology/oper DS to derive global nodeId.

Change-Id: I7153c8e30dd66d6474125b83dfd3f13f0b760d01
Signed-off-by: Faseela K <faseela.k@ericsson.com>
interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/listeners/HwVTEPConfigListener.java
interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java
interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java
interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigUpdateHelper.java
interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/hwvtep/utilities/SouthboundUtils.java

index e137ed62ef18699b0a4b56877659461705e341df..ce35c5baf6667a786321a644ae9e247233f3fd6a 100644 (file)
@@ -61,8 +61,7 @@ public class HwVTEPConfigListener extends AsyncDataTreeChangeListenerBase<Interf
                         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
                         RendererConfigRemoveWorker configWorker = new RendererConfigRemoveWorker(key, interfaceOld,
                                 SouthboundUtils.createPhysicalSwitchInstanceIdentifier(nodeIdentifier.getNodeId()),
-                                SouthboundUtils.createGlobalNodeInstanceIdentifier(dataBroker,
-                                        nodeIdentifier.getNodeId()));
+                                SouthboundUtils.createGlobalNodeInstanceIdentifier(nodeIdentifier.getNodeId()));
                         coordinator.enqueueJob(interfaceOld.getName(), configWorker, IfmConstants.JOB_MAX_RETRIES);
                     }
                 }
@@ -82,8 +81,7 @@ public class HwVTEPConfigListener extends AsyncDataTreeChangeListenerBase<Interf
                         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
                         RendererConfigUpdateWorker configWorker = new RendererConfigUpdateWorker(key, interfaceNew,
                                 SouthboundUtils.createPhysicalSwitchInstanceIdentifier(nodeIdentifier.getNodeId()),
-                                SouthboundUtils.createGlobalNodeInstanceIdentifier(dataBroker,
-                                        nodeIdentifier.getNodeId()),
+                                SouthboundUtils.createGlobalNodeInstanceIdentifier(nodeIdentifier.getNodeId()),
                                 ifTunnel);
                         coordinator.enqueueJob(interfaceNew.getName(), configWorker, IfmConstants.JOB_MAX_RETRIES);
                     }
@@ -104,8 +102,7 @@ public class HwVTEPConfigListener extends AsyncDataTreeChangeListenerBase<Interf
                         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
                         RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew,
                                 SouthboundUtils.createPhysicalSwitchInstanceIdentifier(nodeIdentifier.getNodeId()),
-                                SouthboundUtils.createGlobalNodeInstanceIdentifier(dataBroker,
-                                        nodeIdentifier.getNodeId()),
+                                SouthboundUtils.createGlobalNodeInstanceIdentifier(nodeIdentifier.getNodeId()),
                                 ifTunnel);
                         coordinator.enqueueJob(interfaceNew.getName(), configWorker, IfmConstants.JOB_MAX_RETRIES);
                     }
index c68ebe381d8ca0e3998ebffa1419d4040cb68526..f5708d28ecfdf199795c0c5ffdd11820416374e6 100644 (file)
@@ -31,17 +31,18 @@ public class HwVTEPConfigRemoveHelper {
     public static List<ListenableFuture<Void>> removeConfiguration(DataBroker dataBroker, Interface interfaceOld,
             InstanceIdentifier<Node> globalNodeId, InstanceIdentifier<Node> physicalSwitchNodeId) {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
-        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+        WriteTransaction defaultOperShardTransaction = dataBroker.newWriteOnlyTransaction();
+        WriteTransaction topologyConfigShardTransaction = dataBroker.newWriteOnlyTransaction();
         LOG.info("removing hwvtep configuration for {}", interfaceOld.getName());
         if (globalNodeId != null) {
             IfTunnel ifTunnel = interfaceOld.getAugmentation(IfTunnel.class);
-            // removeTunnelTableEntry(transaction, ifTunnel,
-            // physicalSwitchNodeId);
-            removeTerminationEndPoint(transaction, ifTunnel, globalNodeId);
-            InterfaceManagerCommonUtils.deleteStateEntry(interfaceOld.getName(), transaction);
-            InterfaceMetaUtils.removeTunnelToInterfaceMap(physicalSwitchNodeId, transaction, ifTunnel);
+            //removeTunnelTableEntry(defaultOperShardTransaction, ifTunnel, physicalSwitchNodeId);
+            removeTerminationEndPoint(topologyConfigShardTransaction, ifTunnel, globalNodeId);
+            InterfaceManagerCommonUtils.deleteStateEntry(interfaceOld.getName(), defaultOperShardTransaction);
+            InterfaceMetaUtils.removeTunnelToInterfaceMap(physicalSwitchNodeId, defaultOperShardTransaction, ifTunnel);
         }
-        futures.add(transaction.submit());
+        futures.add(defaultOperShardTransaction.submit());
+        futures.add(topologyConfigShardTransaction.submit());
         return futures;
     }
 
index f89c680deb989999615d03c24ba1b45c1fb3bd08..3d0d09d770dd64a5d22f24647e17854117995170 100644 (file)
@@ -39,16 +39,17 @@ public class HwVTEPInterfaceConfigAddHelper {
         LOG.info("adding hwvtep configuration for {}", interfaceNew.getName());
 
         // create hwvtep through ovsdb plugin
-        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
-        InterfaceMetaUtils.createTunnelToInterfaceMap(interfaceNew.getName(), physicalSwitchNodeId, transaction,
-                ifTunnel);
+        WriteTransaction defaultOperShardTransaction = dataBroker.newWriteOnlyTransaction();
+        WriteTransaction topologyConfigShardTransaction = dataBroker.newWriteOnlyTransaction();
+        InterfaceMetaUtils.createTunnelToInterfaceMap(interfaceNew.getName(), physicalSwitchNodeId,
+            defaultOperShardTransaction, ifTunnel);
         if (globalNodeId != null) {
-            addTerminationPoints(transaction, futures, globalNodeId, ifTunnel);
-            SouthboundUtils.addStateEntry(interfaceNew, interfaceNew.getAugmentation(IfTunnel.class), transaction);
-        } else {
-            LOG.debug("specified physical switch is not connected {}", physicalSwitchNodeId);
+            addTerminationPoints(topologyConfigShardTransaction, futures, globalNodeId,ifTunnel);
+            SouthboundUtils.addStateEntry(interfaceNew, interfaceNew.getAugmentation(IfTunnel.class),
+                defaultOperShardTransaction);
         }
-        futures.add(transaction.submit());
+        futures.add(defaultOperShardTransaction.submit());
+        futures.add(topologyConfigShardTransaction.submit());
         return futures;
     }
 
index 5bb4486b1128294a92d6dc3a5d1d4753a18a7ef3..27795f115007f784c94f1e2b81217a0226aa9f3f 100644 (file)
@@ -34,7 +34,7 @@ public class HwVTEPInterfaceConfigUpdateHelper {
             InstanceIdentifier<Node> physicalSwitchNodeId, InstanceIdentifier<Node> globalNodeId,
             Interface interfaceNew, IfTunnel ifTunnel) {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
-        LOG.info("adding hwvtep configuration for {}", interfaceNew.getName());
+        LOG.info("updating hwvtep configuration for {}", interfaceNew.getName());
 
         // Create hwvtep through OVSDB plugin
         WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
index a8887a6745e59f2631d275fa9eccc494ba909b6b..21844718a8186aa2941d01b94153e0c3195fb762 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.genius.interfacemanager.renderer.hwvtep.utilities;
 import com.google.common.base.Optional;
 import java.util.ArrayList;
 import java.util.List;
+import javax.annotation.Nullable;
 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;
@@ -50,6 +51,8 @@ public class SouthboundUtils {
     public static final String TEP_PREFIX = "vxlan_over_ipv4:";
     public static final String BFD_OP_STATE = "state";
     public static final String BFD_STATE_UP = "up";
+    public static final String PS_NODE_ID_PREFIX = "/physicalswitch";
+
     // BFD parameters
     static final String BFD_PARAM_ENABLE = "enable";
     static final String BFD_PARAM_MIN_RX = "min_rx";
@@ -95,6 +98,22 @@ public class SouthboundUtils {
         return (InstanceIdentifier<Node>) physicalSwitchAugmentation.getManagedBy().getValue();
     }
 
+    public static @Nullable InstanceIdentifier<Node> createGlobalNodeInstanceIdentifier(String psNodeIdString) {
+        String globalNodeIdStr;
+        try {
+            globalNodeIdStr = psNodeIdString.substring(0, psNodeIdString.indexOf(PS_NODE_ID_PREFIX));
+        } catch (StringIndexOutOfBoundsException ex) {
+            LOG.error("cannot determine global-node-id for the physical node {}", psNodeIdString);
+            return null;
+        }
+        NodeId globalNodeId = new NodeId(globalNodeIdStr);
+        InstanceIdentifier<Node> globalNodeInstanceId = InstanceIdentifier
+            .create(NetworkTopology.class)
+            .child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID))
+            .child(Node.class,new NodeKey(globalNodeId));
+        return globalNodeInstanceId;
+    }
+
     public static InstanceIdentifier<TerminationPoint> createTEPInstanceIdentifier(InstanceIdentifier<Node> nodeIid,
             IpAddress ipAddress) {
         TerminationPointKey localTEP = SouthboundUtils.getTerminationPointKey(ipAddress.getIpv4Address().getValue());