Bulk merge of l2gw changes
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / l2gw / listeners / HwvtepPhysicalSwitchListener.java
index d7a5079744f283835857497cb2220e4589c16899..ed29269123ca3707010407b6b63f226cd98ff4b3 100644 (file)
@@ -8,34 +8,35 @@
 
 package org.opendaylight.netvirt.elan.l2gw.listeners;
 
-import com.google.common.base.Optional;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Objects;
 import java.util.Set;
-import java.util.concurrent.ExecutionException;
 import java.util.function.BiPredicate;
 import java.util.function.Predicate;
 import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
-
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.genius.datastoreutils.hwvtep.HwvtepAbstractDataTreeChangeListener;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
+import org.opendaylight.genius.utils.batching.ResourceBatchingManager;
 import org.opendaylight.genius.utils.hwvtep.HwvtepHACache;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.infrautils.utils.concurrent.Executors;
+import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner;
+import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.netvirt.elan.l2gw.MdsalEvent;
 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
 import org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpClusteredListener;
+import org.opendaylight.netvirt.elan.l2gw.recovery.impl.L2GatewayServiceRecoveryHandler;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
 import org.opendaylight.netvirt.elan.l2gw.utils.L2GatewayConnectionUtils;
 import org.opendaylight.netvirt.elan.l2gw.utils.L2GatewayUtils;
@@ -45,10 +46,11 @@ import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
 import org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayCache;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
+import org.opendaylight.serviceutils.srm.RecoverableListener;
+import org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -66,7 +68,7 @@ import org.slf4j.LoggerFactory;
 @Singleton
 public class HwvtepPhysicalSwitchListener
         extends HwvtepAbstractDataTreeChangeListener<PhysicalSwitchAugmentation, HwvtepPhysicalSwitchListener>
-        implements ClusteredDataTreeChangeListener<PhysicalSwitchAugmentation> {
+        implements ClusteredDataTreeChangeListener<PhysicalSwitchAugmentation>, RecoverableListener {
 
     /** The Constant LOG. */
     private static final Logger LOG = LoggerFactory.getLogger(HwvtepPhysicalSwitchListener.class);
@@ -79,7 +81,7 @@ public class HwvtepPhysicalSwitchListener
         };
 
     private static final Predicate<PhysicalSwitchAugmentation> TUNNEL_IP_AVAILABLE =
-        phySwitch -> !HwvtepHAUtil.isEmpty(phySwitch.getTunnelIps());
+        phySwitch -> !HwvtepHAUtil.isEmpty(phySwitch.nonnullTunnelIps().values());
 
     private static final Predicate<PhysicalSwitchAugmentation> TUNNEL_IP_NOT_AVAILABLE = TUNNEL_IP_AVAILABLE.negate();
 
@@ -87,7 +89,7 @@ public class HwvtepPhysicalSwitchListener
         (phySwitchAfter, existingDevice) -> {
             return TUNNEL_IP_AVAILABLE.test(phySwitchAfter)
                     && !Objects.equals(
-                            existingDevice.getTunnelIp(),  phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
+                            existingDevice.getTunnelIp(),  phySwitchAfter.nonnullTunnelIps().get(0).getTunnelIpsKey());
         };
 
     /** The data broker. */
@@ -138,8 +140,12 @@ public class HwvtepPhysicalSwitchListener
 
     private final StaleVlanBindingsCleaner staleVlanBindingsCleaner;
 
+    private final L2GwTransportZoneListener transportZoneListener;
+
     /**
      * Instantiates a new hwvtep physical switch listener.
+     * @param l2GatewayServiceRecoveryHandler L2GatewayServiceRecoveryHandler
+     * @param serviceRecoveryRegistry ServiceRecoveryRegistry
      * @param dataBroker DataBroker
      * @param itmRpcService ItmRpcService
      * @param elanClusterUtils ElanClusterUtils
@@ -149,11 +155,20 @@ public class HwvtepPhysicalSwitchListener
      * @param staleVlanBindingsCleaner StaleVlanBindingsCleaner
      */
     @Inject
-    public HwvtepPhysicalSwitchListener(final DataBroker dataBroker, ItmRpcService itmRpcService,
-            ElanClusterUtils elanClusterUtils, L2gwServiceProvider l2gwServiceProvider,
-            HAOpClusteredListener haListener, L2GatewayCache l2GatewayCache,
-            StaleVlanBindingsCleaner staleVlanBindingsCleaner) {
-        super(PhysicalSwitchAugmentation.class, HwvtepPhysicalSwitchListener.class);
+    public HwvtepPhysicalSwitchListener(final L2GatewayServiceRecoveryHandler l2GatewayServiceRecoveryHandler,
+                                        final ServiceRecoveryRegistry serviceRecoveryRegistry,
+                                        final DataBroker dataBroker, ItmRpcService itmRpcService,
+                                        ElanClusterUtils elanClusterUtils, L2gwServiceProvider l2gwServiceProvider,
+                                        HAOpClusteredListener haListener, L2GatewayCache l2GatewayCache,
+                                        StaleVlanBindingsCleaner staleVlanBindingsCleaner,
+                                        L2GwTransportZoneListener transportZoneListener) {
+
+        super(dataBroker,  DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+            InstanceIdentifier.create(NetworkTopology.class)
+                .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID)).child(Node.class)
+                .augmentation(PhysicalSwitchAugmentation.class)),
+            Executors.newListeningSingleThreadExecutor("HwvtepPhysicalSwitchListener", LOG));
+
         this.dataBroker = dataBroker;
         this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
         this.itmRpcService = itmRpcService;
@@ -162,24 +177,41 @@ public class HwvtepPhysicalSwitchListener
         this.staleVlanBindingsCleaner = staleVlanBindingsCleaner;
         this.haOpClusteredListener = haListener;
         this.l2GatewayCache = l2GatewayCache;
+        this.transportZoneListener = transportZoneListener;
+        serviceRecoveryRegistry.addRecoverableListener(l2GatewayServiceRecoveryHandler.buildServiceRegistryKey(),
+                this);
+        //TODOD recover
     }
 
-    @Override
     @PostConstruct
     public void init() {
-        registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+        ResourceBatchingManager.getInstance().registerDefaultBatchHandlers(this.dataBroker);
+        //RegisterListener is called from L2GatewayConnectionListener
+        //registerListener();
     }
 
     @Override
-    protected InstanceIdentifier<PhysicalSwitchAugmentation> getWildCardPath() {
-        return InstanceIdentifier.create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID)).child(Node.class)
-                .augmentation(PhysicalSwitchAugmentation.class);
+    public void register() {
+        LOG.info("Registering HwvtepPhysicalSwitchListener in Overwritten Method");
+        super.register();
+    }
+
+    @Override
+    public void registerListener() {
+        LOG.info("Registering HwvtepPhysicalSwitchListener");
+        super.register();
+    }
+
+    public void deregisterListener() {
+        LOG.info("Deregistering HwvtepPhysicalSwitchListener");
+        super.close();
     }
 
     @Override
-    protected HwvtepPhysicalSwitchListener getDataTreeChangeListener() {
-        return HwvtepPhysicalSwitchListener.this;
+    @PreDestroy
+    public void close() {
+        super.close();
+        Executors.shutdownAndAwaitTermination(getExecutorService());
     }
 
     @Override
@@ -193,17 +225,16 @@ public class HwvtepPhysicalSwitchListener
         if (l2GwDevice != null) {
             if (!L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
                 l2GatewayCache.remove(psName);
-                LOG.debug("{} details removed from L2Gateway Cache", psName);
-                MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
-                        HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
+                LOG.info("HwvtepPhysicalSwitchListener {} details removed from L2Gateway Cache", psName);
             } else {
-                LOG.debug("{} details are not removed from L2Gateway Cache as it has L2Gateway reference", psName);
+                LOG.error("HwvtepPhysicalSwitchListener {} details are not removed from L2Gateway "
+                        + " Cache as it has L2Gateway reference", psName);
             }
 
             l2GwDevice.setConnected(false);
             //ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(psName);
         } else {
-            LOG.error("Unable to find L2 Gateway details for {}", psName);
+            LOG.error("HwvtepPhysicalSwitchListener Unable to find L2 Gateway details for {}", psName);
         }
     }
 
@@ -226,11 +257,14 @@ public class HwvtepPhysicalSwitchListener
                 + "PhysicalSwitch After: {}", nodeId.getValue(), phySwitchBefore, phySwitchAfter);
         String psName = getPsName(identifier);
         if (psName == null) {
-            LOG.error("Could not find the physical switch name for node {}", nodeId.getValue());
+            LOG.error("PhysicalSwitchListener Could not find the physical switch name for node {}", nodeId.getValue());
             return;
         }
         L2GatewayDevice existingDevice = l2GatewayCache.get(psName);
-        LOG.info("Received physical switch {} update event for node {}", psName, nodeId.getValue());
+        if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps())) {
+            LOG.info("PhysicalSwitchListener Received physical switch update for {} before teps {} after teps {}",
+                    nodeId.getValue(), phySwitchBefore.getTunnelIps(), phySwitchAfter.getTunnelIps());
+        }
         InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
 
         if (DEVICE_NOT_CACHED_OR_PARENT_CONNECTED.test(existingDevice, globalNodeIid)) {
@@ -245,13 +279,13 @@ public class HwvtepPhysicalSwitchListener
                 elanClusterUtils.runOnlyInOwnerNode(existingDevice.getDeviceName(),
                     "handling Physical Switch add create itm tunnels ",
                     () -> {
-                        LOG.info("Deleting itm tunnels for device {}", existingDevice.getDeviceName());
+                        LOG.info("PhysicalSwitchListener Deleting itm tunnels for {}", existingDevice.getDeviceName());
                         L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId,
                                 existingDevice.getDeviceName(), existingDevice.getTunnelIp());
                         Thread.sleep(10000L);//TODO remove these sleeps
                         LOG.info("Creating itm tunnels for device {}", existingDevice.getDeviceName());
                         ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepId, psName,
-                                phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
+                            phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
                         return Collections.emptyList();
                     }
                 );
@@ -273,27 +307,41 @@ public class HwvtepPhysicalSwitchListener
         final InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
         NodeId nodeId = getNodeId(identifier);
         if (TUNNEL_IP_NOT_AVAILABLE.test(phySwitchAdded)) {
-            LOG.error("Could not find the /tunnel ips for node {}", nodeId.getValue());
+            LOG.error("PhysicalSwitchListener Could not find the /tunnel ips for node {}", nodeId.getValue());
             return;
         }
         final String psName = getPsName(identifier);
-        LOG.trace("Received physical switch {} added event received for node {}", psName, nodeId.getValue());
+        LOG.info("PhysicalSwitchListener Received physical switch added event received for node {} {}",
+                nodeId.getValue(), phySwitchAdded.getTunnelIps());
 
         haOpClusteredListener.runAfterNodeIsConnected(globalNodeIid, (node) -> {
-            LOG.trace("Running job for node {} ", globalNodeIid);
+            LOG.info("PhysicalSwitchListener Global oper node found for {}", nodeId.getValue());
             if (!node.isPresent()) {
-                LOG.error("Global node is absent {}", globalNodeId);
+                LOG.error("PhysicalSwitchListener Global node is absent {}", globalNodeId);
                 return;
             }
             HAOpClusteredListener.addToCacheIfHAChildNode(globalNodeIid, node.get());
+            L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
             if (hwvtepHACache.isHAEnabledDevice(globalNodeIid)) {
-                LOG.trace("Ha enabled device {}", globalNodeIid);
-                return;
+                InstanceIdentifier<Node> parent = hwvtepHACache.getParent(globalNodeIid);
+                if (l2GwDevice == null || !Objects.equals(parent.firstKeyOf(Node.class).getNodeId().getValue(),
+                        l2GwDevice.getHwvtepNodeId())) {
+                    Collection<TunnelIps> tunnelIps = phySwitchAdded.nonnullTunnelIps().values();
+                    if (tunnelIps != null && !tunnelIps.isEmpty()) {
+                        l2GatewayCache.updateL2GatewayCache(psName,
+                                parent.firstKeyOf(Node.class).getNodeId().getValue(),
+                            new ArrayList<>(phySwitchAdded.nonnullTunnelIps().values()));
+                    }
+                    return;//TODO provision l2gw
+                } else {
+                    LOG.info("PhysicalSwitchListener Ha enabled device {} connected skip update cache", globalNodeIid);
+                    return;
+                }
             }
-            LOG.trace("Updating cache for node {}", globalNodeIid);
-            L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
+            LOG.info("PhysicalSwitchListener Updating cache for node {} existing {}",
+                globalNodeId, (l2GwDevice != null ? l2GwDevice.getDeviceName() : null));
             if (childConnectedAfterParent.test(l2GwDevice, globalNodeIid)) {
-                LOG.trace("Device {} {} is already Connected by ",
+                LOG.info("PhysicalSwitchListener Device {} {} is already Connected by {}",
                         psName, globalNodeId, l2GwDevice.getHwvtepNodeId());
                 return;
             }
@@ -303,71 +351,72 @@ public class HwvtepPhysicalSwitchListener
             }
             if (parentConnectedAfterChild.test(l2GwDevice, globalNodeIid)
                     && alreadyHasL2Gwids.test(l2GwDevice)) {
-                LOG.error("Child node {} having l2gw configured became ha node "
+                LOG.error("PhysicalSwitchListener Child node {} having l2gw configured became ha node "
                                 + " removing the l2device {} from all elan cache and provision parent node {}",
                           existingIid, psName, globalNodeIid);
                 ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(l2GwDevice.getHwvtepNodeId());
             }
 
-            l2GwDevice = l2GatewayCache.addOrGet(psName);
-            l2GwDevice.setConnected(true);
-            l2GwDevice.setHwvtepNodeId(globalNodeId);
-
-            List<TunnelIps> tunnelIps = phySwitchAdded.getTunnelIps();
-            if (tunnelIps != null) {
-                for (TunnelIps tunnelIp : tunnelIps) {
-                    IpAddress tunnelIpAddr = tunnelIp.getTunnelIpsKey();
-                    l2GwDevice.addTunnelIp(tunnelIpAddr);
-                }
+            Collection<TunnelIps> tunnelIps = phySwitchAdded.nonnullTunnelIps().values();
+            if (tunnelIps != null && !tunnelIps.isEmpty()) {
+                l2GatewayCache.updateL2GatewayCache(psName, globalNodeId,
+                    new ArrayList<>(phySwitchAdded.nonnullTunnelIps().values()));
+                l2GwDevice = l2GatewayCache.get(psName);
+                handleAdd(l2GwDevice, identifier, phySwitchAdded);
             }
-
-            handleAdd(l2GwDevice);
-            elanClusterUtils.runOnlyInOwnerNode("Update config tunnels IP ", () -> {
-                try {
-                    updateConfigTunnelIp(identifier, phySwitchAdded);
-                } catch (ReadFailedException e) {
-                    LOG.error("Failed to update tunnel ips {}", identifier);
-                }
-            });
+            /*elanClusterUtils.runOnlyInOwnerNode(psName + ":" + "tunnelIp",
+                    "Update config tunnels IP ", () -> {
+                    List<ListenableFuture<Void>> result = new ArrayList<>();
+                    try {
+                        updateConfigTunnelIp(identifier, phySwitchAdded, result);
+                    } catch (ReadFailedException e) {
+                        LOG.error("PhysicalSwitchListener Failed to update tunnel ips {}", identifier);
+                    }
+                    return result;
+                });
+            */
             return;
         });
     }
 
-    boolean updateHACacheIfHANode(InstanceIdentifier<Node> globalNodeId)
-            throws ExecutionException, InterruptedException {
-        try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
-            tx.read(LogicalDatastoreType.OPERATIONAL, globalNodeId).get().toJavaUtil().ifPresent(
-                node -> HAOpClusteredListener.addToCacheIfHAChildNode(globalNodeId, node));
-        }
-        return hwvtepHACache.isHAEnabledDevice(globalNodeId);
-    }
-
     /**
      * Handle add.
      *
      * @param l2GwDevice
      *            the l2 gw device
      */
-    private void handleAdd(L2GatewayDevice l2GwDevice) {
+    private void handleAdd(L2GatewayDevice l2GwDevice,
+                           InstanceIdentifier<PhysicalSwitchAugmentation> identifier,
+                           PhysicalSwitchAugmentation phySwitchAdded) {
+        LOG.info("PhysicalSwitchListener Handle add of tunnel ips {} psNode {} device {}",
+                phySwitchAdded.getTunnelIps(), identifier.firstKeyOf(Node.class).getNodeId(), l2GwDevice);
         final String psName = l2GwDevice.getDeviceName();
         final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
         Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
-        for (final IpAddress tunnelIpAddr : tunnelIps) {
-            if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
-                LOG.debug("L2Gateway {} associated for {} physical switch; creating ITM tunnels for {}",
-                        l2GwDevice.getL2GatewayIds(), psName, tunnelIpAddr);
-                l2gwServiceProvider.provisionItmAndL2gwConnection(l2GwDevice, psName, hwvtepNodeId, tunnelIpAddr);
-            } else {
-                LOG.info("l2gw.provision.skip {}", hwvtepNodeId, psName);
+        if (tunnelIps != null) {
+            //TODO add logical switch and mcast put itm tep event and update mcast
+            hwvtepHACache.addDebugEvent(new MdsalEvent("ps add provision", l2GwDevice.getHwvtepNodeId()));
+            for (final IpAddress tunnelIpAddr : tunnelIps) {
+                if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
+                    LOG.info("PhysicalSwitchListener L2Gateway {} associated for {} physical switch "
+                                    + " creating ITM tunnels for {}",
+                            l2GwDevice.getL2GatewayIds(), psName, tunnelIpAddr);
+                    l2gwServiceProvider.provisionItmAndL2gwConnection(l2GwDevice, psName, hwvtepNodeId, tunnelIpAddr);
+                } else {
+                    LOG.info("l2gw.provision.skip hwvtepNodeId: {} psName : {}", hwvtepNodeId, psName);
+                }
             }
-        }
-        elanClusterUtils.runOnlyInOwnerNode("Stale entry cleanup", () -> {
             InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(
                     new NodeId(hwvtepNodeId));
-            InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(
-                    HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
-            staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
-        });
+            HwvtepHACache.getInstance().setTepIpOfNode(globalNodeIid, tunnelIps.iterator().next());
+            elanClusterUtils.runOnlyInOwnerNode(psName, "Stale entry cleanup", () -> {
+                InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(
+                        HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
+                staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
+                transportZoneListener.createL2gwZeroDayConfig();
+                return Collections.emptyList();
+            });
+        }
     }
 
 
@@ -378,11 +427,11 @@ public class HwvtepPhysicalSwitchListener
      *            the identifier
      * @return the node id
      */
-    private NodeId getNodeId(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
+    private static NodeId getNodeId(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
         return identifier.firstKeyOf(Node.class).getNodeId();
     }
 
-    private String getManagedByNodeId(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
+    private static String getManagedByNodeId(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
         String psNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
         if (psNodeId.contains(HwvtepHAUtil.PHYSICALSWITCH)) {
             return psNodeId.substring(0, psNodeId.indexOf(HwvtepHAUtil.PHYSICALSWITCH));
@@ -390,7 +439,9 @@ public class HwvtepPhysicalSwitchListener
         return psNodeId;
     }
 
-    private InstanceIdentifier<Node> getManagedByNodeIid(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
+    @Nullable
+    private static InstanceIdentifier<Node> getManagedByNodeIid(
+                        InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
         String psNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
         if (psNodeId.contains(HwvtepHAUtil.PHYSICALSWITCH)) {
             psNodeId = psNodeId.substring(0, psNodeId.indexOf(HwvtepHAUtil.PHYSICALSWITCH));
@@ -399,7 +450,8 @@ public class HwvtepPhysicalSwitchListener
         return null;
     }
 
-    private String getPsName(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
+    @Nullable
+    private static String getPsName(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
         String psNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
         if (psNodeId.contains(HwvtepHAUtil.PHYSICALSWITCH)) {
             return psNodeId.substring(psNodeId.indexOf(HwvtepHAUtil.PHYSICALSWITCH) + HwvtepHAUtil.PHYSICALSWITCH
@@ -408,21 +460,22 @@ public class HwvtepPhysicalSwitchListener
         return null;
     }
 
-    private void updateConfigTunnelIp(InstanceIdentifier<PhysicalSwitchAugmentation> identifier,
-                                      PhysicalSwitchAugmentation phySwitchAdded) throws ReadFailedException {
+    /*private void updateConfigTunnelIp(InstanceIdentifier<PhysicalSwitchAugmentation> identifier,
+                                                        PhysicalSwitchAugmentation phySwitchAdded,
+                                                        List<ListenableFuture<Void>> result)
+                                                        throws ReadFailedException {
         if (phySwitchAdded.getTunnelIps() != null) {
-            ListenableFutures.addErrorLogging(
-                txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
-                    Optional<PhysicalSwitchAugmentation> existingSwitch = tx.read(
-                            LogicalDatastoreType.CONFIGURATION, identifier).checkedGet();
-                    PhysicalSwitchAugmentationBuilder psBuilder = new PhysicalSwitchAugmentationBuilder();
-                    if (existingSwitch.isPresent()) {
-                        psBuilder = new PhysicalSwitchAugmentationBuilder(existingSwitch.get());
-                    }
-                    psBuilder.setTunnelIps(phySwitchAdded.getTunnelIps());
-                    tx.put(LogicalDatastoreType.CONFIGURATION, identifier, psBuilder.build(), true);
-                    LOG.trace("Updating config tunnel ips {}", identifier);
-                }), LOG, "Failed to update the config tunnel ips {}", identifier);
+            result.add(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+                Optional<PhysicalSwitchAugmentation> existingSwitch = tx.read(
+                        LogicalDatastoreType.CONFIGURATION, identifier).checkedGet();
+                PhysicalSwitchAugmentationBuilder psBuilder = new PhysicalSwitchAugmentationBuilder();
+                if (existingSwitch.isPresent()) {
+                    psBuilder = new PhysicalSwitchAugmentationBuilder(existingSwitch.get());
+                }
+                psBuilder.setTunnelIps(phySwitchAdded.getTunnelIps());
+                tx.put(LogicalDatastoreType.CONFIGURATION, identifier, psBuilder.build(), true);
+                LOG.trace("Updating config tunnel ips {}", identifier);
+            }));
         }
-    }
+    }*/
 }