Eliminate circular dependencies and convert to BP annotations in elanmanager 80/65880/14
authorTom Pantelis <tompantelis@gmail.com>
Fri, 24 Nov 2017 06:32:05 +0000 (01:32 -0500)
committerSam Hague <shague@redhat.com>
Sat, 9 Dec 2017 19:32:58 +0000 (19:32 +0000)
ElanInstanceManager -> ElanInterfaceManager -> ElanUtils -> ElanInstanceManager

  Elimnated ElanUtils -> ElanInstanceManager by moving
  ElanInterfaceManager.getElanDPNByName to ElanUtils.

Eliminated ElanInterfaceManager.setElanUtils and
ElanUtils.getElanL2GatewayMulticastUtils that were put in to avoid circular
dependencies between ElanUtils, ElanInterfaceManager, ElanInterfaceManager and
ElanL2GatewayMulticastUtils. The circular dependencies were eliminated by
eliminating the dependencies between

  ElanL2GatewayMulticastUtils -> ElanInterfaceManager and
  ElanL2GatewayMulticastUtils -> ElanInstanceManager.

The former entailed moving
ElanInterfaceManager.updateRemoteBroadcastGroupForAllElanDpns et al
to ElanL2GatewayMulticastUtils.

The latter entailed the caller looking up and passing the ElanInstance to
updateRemoteBroadcastGroupForAllElanDpns via handleMcastForElanL2GwDeviceDelete,
handleMcastForElanL2GwDeviceAdd. The call sites for these are
DisAssociateHwvtepFromElanJob and LogicalSwitchAddedJob via
L2GatewayConnectionUtils, AssociateHwvtepToElanJob and HwvtepLogicalSwitchListener.

Change-Id: Ida1d3c64e6a122af6f96fad59b5295319a2098ef
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
52 files changed:
vpnservice/elanmanager/elanmanager-impl/pom.xml
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/evpn/utils/EvpnMacVrfUtils.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/evpn/utils/EvpnUtils.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanBridgeManager.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanDpnInterfaceClusteredListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanDpnInterfacesListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanDpnToTransportZoneListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanExtnTepListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInstanceManager.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceConfigListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceManager.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceStateChangeListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceStateClusteredListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanLearntVpnVipToPortListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanNodeListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanOvsdbNodeListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanPacketInHandler.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanServiceProvider.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanSmacFlowEventListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanTunnelInterfaceStateListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/internal/VpnDpnToTransportZoneListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/ha/handlers/HAEventHandler.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/ha/listeners/HAConfigNodeListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/ha/listeners/HAListeners.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/ha/listeners/HAOpClusteredListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/ha/listeners/HAOpNodeListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/ha/listeners/HwvtepNodeBaseListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/jobs/AssociateHwvtepToElanJob.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/jobs/DisAssociateHwvtepFromElanJob.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/jobs/LogicalSwitchAddedJob.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/listeners/ChildListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/listeners/ElanGroupListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/listeners/ElanInstanceListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/listeners/HwvtepLogicalSwitchListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/listeners/HwvtepPhysicalSwitchListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/listeners/HwvtepTerminationPointListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/listeners/L2GatewayConnectionListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/listeners/LocalUcastMacListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/ElanL2GatewayMulticastUtils.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/ElanL2GatewayUtils.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/L2GatewayConnectionUtils.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/L2GatewayUtils.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/L2gwServiceProvider.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/statisitcs/ElanStatisticsImpl.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/statusanddiag/ElanStatusMonitorJMX.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/utils/CacheElanInstanceListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/utils/CacheElanInterfaceListener.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanForwardingEntriesHandler.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanUtils.java
vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/utils/TransportZoneNotificationUtil.java
vpnservice/elanmanager/elanmanager-impl/src/main/resources/org/opendaylight/blueprint/elanmanager.xml
vpnservice/elanmanager/elanmanager-impl/src/test/java/org/opendaylight/netvirt/elanmanager/tests/ElanServiceTestModule.java

index 182220b5da5c8a4fbd1af8e5b0642843268c3b24..6adcde6b51c2234799793c07fce3e9a36c67712d 100644 (file)
           <failOnError>true</failOnError>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.aries.blueprint</groupId>
+        <artifactId>blueprint-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
 
index 81e233d15bd6ad9b215c966f01a87053d52ece2e..85e09132e71979f15f08fad8b5aba3f9c331c4c1 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
-import org.opendaylight.netvirt.elan.internal.ElanInstanceManager;
 import org.opendaylight.netvirt.elan.utils.ElanConstants;
 import org.opendaylight.netvirt.elan.utils.ElanUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -45,25 +44,24 @@ public class EvpnMacVrfUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(EvpnMacVrfUtils.class);
     private final DataBroker dataBroker;
-    private final ElanInstanceManager elanInstanceManager;
     private final IdManagerService idManager;
     private final ElanEvpnFlowUtils elanEvpnFlowUtils;
     private final IMdsalApiManager mdsalManager;
     private final EvpnUtils evpnUtils;
     private final JobCoordinator jobCoordinator;
+    private final ElanUtils elanUtils;
 
     @Inject
-    public EvpnMacVrfUtils(final DataBroker dataBroker, final ElanInstanceManager elanInstanceManager,
-                           final IdManagerService idManager, final ElanEvpnFlowUtils elanEvpnFlowUtils,
-                           final IMdsalApiManager mdsalManager, final EvpnUtils evpnUtils,
-                           final JobCoordinator jobCoordinator) {
+    public EvpnMacVrfUtils(final DataBroker dataBroker, final IdManagerService idManager,
+            final ElanEvpnFlowUtils elanEvpnFlowUtils, final IMdsalApiManager mdsalManager, final EvpnUtils evpnUtils,
+            final JobCoordinator jobCoordinator, final ElanUtils elanUtils) {
         this.dataBroker = dataBroker;
-        this.elanInstanceManager = elanInstanceManager;
         this.idManager = idManager;
         this.elanEvpnFlowUtils = elanEvpnFlowUtils;
         this.mdsalManager = mdsalManager;
         this.evpnUtils = evpnUtils;
         this.jobCoordinator = jobCoordinator;
+        this.elanUtils = elanUtils;
     }
 
     public Long getElanTagByMacvrfiid(InstanceIdentifier<MacVrfEntry> macVrfEntryIid) {
@@ -149,7 +147,7 @@ public class EvpnMacVrfUtils {
             return;
         }
 
-        List<DpnInterfaces> dpnInterfaceLists = elanInstanceManager.getElanDPNByName(elanName);
+        List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
         if (checkEvpnAttachedToNet(elanName)) {
             //TODO(Riyaz) : Check if accessing first nexthop address is right solution
             String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
@@ -182,7 +180,7 @@ public class EvpnMacVrfUtils {
             LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
             return;
         }
-        List<DpnInterfaces> dpnInterfaceLists = elanInstanceManager.getElanDPNByName(elanName);
+        List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
 
         //if (checkEvpnAttachedToNet(elanName)) {
         //TODO(Riyaz) : Check if accessing first nexthop address is right
@@ -214,7 +212,7 @@ public class EvpnMacVrfUtils {
         }
 
         String elanName = elanInstance.getElanInstanceName();
-        List<DpnInterfaces> dpnInterfaceLists = elanInstanceManager.getElanDPNByName(elanName);
+        List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
 
         if (checkEvpnAttachedToNet(elanName)) {
             String nexthopIP = getRoutePathNexthopIp(macVrfEntry);
@@ -259,8 +257,7 @@ public class EvpnMacVrfUtils {
             LOG.error("Error : elanInstance is null for iid {}", instanceIdentifier);
             return;
         }
-        List<DpnInterfaces> dpnInterfaceLists =
-                elanInstanceManager.getElanDPNByName(elanInstance.getElanInstanceName());
+        List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
 
         //if (checkEvpnAttachedToNet(elanName)) {
         String nexthopIP = getRoutePathNexthopIp(macVrfEntry);
index 4b8b52092c39b5807740290104b4c3d7877f995e..cb9f99afa6d8f1cd2afab9367b775cc23f10a98f 100644 (file)
@@ -100,12 +100,6 @@ public class EvpnUtils {
         this.jobCoordinator = jobCoordinator;
     }
 
-    public void init() {
-    }
-
-    public void close() {
-    }
-
     public boolean isWithdrawEvpnRT2Routes(ElanInstance original, ElanInstance update) {
         return isNetDetach.test(getEvpnNameFromElan(original), getEvpnNameFromElan(update));
     }
index c0d1db2b928c97cbdb07ef5dbf395951ad90e92b..de38abede5bd4575da062e3a1faa819606b711ee 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Random;
 import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.interfacemanager.globals.IfmConstants;
@@ -54,6 +55,7 @@ import org.slf4j.LoggerFactory;
 /**
  * This class provides functions for creating bridges via OVSDB, specifically the br-int bridge.
  */
+@Singleton
 public class ElanBridgeManager implements IElanBridgeManager {
     private static final Logger LOG = LoggerFactory.getLogger(ElanBridgeManager.class);
 
@@ -70,7 +72,7 @@ public class ElanBridgeManager implements IElanBridgeManager {
 
     private final MdsalUtils mdsalUtils;
     private final IInterfaceManager interfaceManager;
-    final SouthboundUtils southboundUtils;
+    private final SouthboundUtils southboundUtils;
     private final Random random;
     private final Long maxBackoff;
     private final Long inactivityProbe;
@@ -83,11 +85,12 @@ public class ElanBridgeManager implements IElanBridgeManager {
      * @param interfaceManager InterfaceManager
      */
     @Inject
-    public ElanBridgeManager(DataBroker dataBroker, ElanConfig elanConfig, IInterfaceManager interfaceManager) {
+    public ElanBridgeManager(DataBroker dataBroker, ElanConfig elanConfig, IInterfaceManager interfaceManager,
+            SouthboundUtils southboundUtils, MdsalUtils mdsalUtils) {
         //TODO: ClusterAware!!!??
-        this.mdsalUtils = new MdsalUtils(dataBroker);
+        this.mdsalUtils = mdsalUtils;
         this.interfaceManager = interfaceManager;
-        this.southboundUtils = new SouthboundUtils(mdsalUtils);
+        this.southboundUtils = southboundUtils;
         this.random = new Random(System.currentTimeMillis());
         this.maxBackoff = elanConfig.getControllerMaxBackoff();
         this.inactivityProbe = elanConfig.getControllerInactivityProbe();
index b97993b8932d29b189604e9490d15733330fb8c7..247e3d71e15d64f9e13ab21c4c03445fdd86a6d6 100644 (file)
@@ -8,6 +8,9 @@
 package org.opendaylight.netvirt.elan.internal;
 
 import java.util.Collections;
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
@@ -27,6 +30,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanDpnInterfaceClusteredListener
         extends AsyncClusteredDataTreeChangeListenerBase<DpnInterfaces, ElanDpnInterfaceClusteredListener> {
 
@@ -39,17 +43,20 @@ public class ElanDpnInterfaceClusteredListener
     private final ElanClusterUtils elanClusterUtils;
     private final JobCoordinator jobCoordinator;
 
+    @Inject
     public ElanDpnInterfaceClusteredListener(DataBroker broker, EntityOwnershipUtils entityOwnershipUtils,
-                                             ElanUtils elanUtils, ElanL2GatewayUtils elanL2GatewayUtils,
-                                             ElanClusterUtils elanClusterUtils, JobCoordinator jobCoordinator) {
+                                             ElanL2GatewayUtils elanL2GatewayUtils,
+                                             ElanClusterUtils elanClusterUtils, JobCoordinator jobCoordinator,
+                                             ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils) {
         this.broker = broker;
         this.entityOwnershipUtils = entityOwnershipUtils;
         this.elanL2GatewayUtils = elanL2GatewayUtils;
-        this.elanL2GatewayMulticastUtils = elanUtils.getElanL2GatewayMulticastUtils();
+        this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
         this.elanClusterUtils = elanClusterUtils;
         this.jobCoordinator = jobCoordinator;
     }
 
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.OPERATIONAL, this.broker);
     }
index 2c31e1a12193986771a5931311d2726e25d980f1..f65405fe9c520829144fd1e200e5b6224a7fcd20 100644 (file)
@@ -11,7 +11,9 @@ package org.opendaylight.netvirt.elan.internal;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.List;
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
@@ -26,6 +28,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanDpnInterfacesListener
         extends AsyncDataTreeChangeListenerBase<DpnInterfaces, ElanDpnInterfacesListener> {
 
@@ -44,6 +47,7 @@ public class ElanDpnInterfacesListener
         this.jobCoordinator = jobCoordinator;
     }
 
+    @PostConstruct
     public void start() {
         registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
     }
index cfcb9c522a77236162b10cf1a830b2c12304194c..fef1284f50c2ddb92ab14c431d912d54d49cd90d 100644 (file)
@@ -8,7 +8,9 @@
 package org.opendaylight.netvirt.elan.internal;
 
 import java.math.BigInteger;
-
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
@@ -23,6 +25,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanDpnToTransportZoneListener
         extends AsyncDataTreeChangeListenerBase<DpnInterfaces, ElanDpnToTransportZoneListener> {
 
@@ -31,6 +34,7 @@ public class ElanDpnToTransportZoneListener
     private final DataBroker dbx;
     private final Boolean useTransportZone;
 
+    @Inject
     public ElanDpnToTransportZoneListener(final DataBroker dbx, final IInterfaceManager interfaceManager,
             final ElanConfig elanConfig, final TransportZoneNotificationUtil tznu) {
         useTransportZone = elanConfig.isAutoConfigTransportZones();
@@ -38,6 +42,7 @@ public class ElanDpnToTransportZoneListener
         this.dbx = dbx;
     }
 
+    @PostConstruct
     public void start() {
         LOG.info("{} start", getClass().getSimpleName());
 
@@ -90,4 +95,4 @@ public class ElanDpnToTransportZoneListener
     protected ElanDpnToTransportZoneListener getDataTreeChangeListener() {
         return ElanDpnToTransportZoneListener.this;
     }
-}
\ No newline at end of file
+}
index 2bc479b7e77808e354ebb2e1e73bb30dffc7ea15..9c33a3a7688f6bc7d1046c75dc753fdbfa95602b 100644 (file)
@@ -9,10 +9,14 @@ package org.opendaylight.netvirt.elan.internal;
 
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.SettableFuture;
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
 import org.opendaylight.netvirt.elan.utils.ElanConstants;
 import org.opendaylight.netvirt.elan.utils.ElanUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
@@ -22,32 +26,30 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanExtnTepListener extends AsyncDataTreeChangeListenerBase<ExternalTeps, ElanExtnTepListener> {
 
     private static final Logger LOG = LoggerFactory.getLogger(ElanExtnTepListener.class);
 
     private final DataBroker broker;
-    private final ElanInterfaceManager elanInterfaceManager;
+    private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
     private final JobCoordinator jobCoordinator;
 
-    public ElanExtnTepListener(DataBroker dataBroker, ElanInterfaceManager elanInterfaceManager,
+    @Inject
+    public ElanExtnTepListener(DataBroker dataBroker, ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
             JobCoordinator jobCoordinator) {
         super(ExternalTeps.class, ElanExtnTepListener.class);
         this.broker = dataBroker;
-        this.elanInterfaceManager = elanInterfaceManager;
+        this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
         this.jobCoordinator = jobCoordinator;
     }
 
     @Override
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.CONFIGURATION, broker);
     }
 
-    @Override
-    public void close() {
-        super.close();
-    }
-
     @Override
     protected InstanceIdentifier<ExternalTeps> getWildCardPath() {
         return InstanceIdentifier.create(ElanInstances.class).child(ElanInstance.class).child(ExternalTeps.class);
@@ -78,7 +80,7 @@ public class ElanExtnTepListener extends AsyncDataTreeChangeListenerBase<Externa
             SettableFuture<Void> ft = SettableFuture.create();
             try {
                 //TODO make the following method return ft
-                elanInterfaceManager.updateRemoteBroadcastGroupForAllElanDpns(elanInfo);
+                elanL2GatewayMulticastUtils.updateRemoteBroadcastGroupForAllElanDpns(elanInfo);
                 ft.set(null);
             } catch (Exception e) {
                 //since the above method does a sync write , if it fails there was no retry
index b196d2b573fb17b2b5d1b2bfb100de20c67110c2..5a55dd6219420099d5570c2aa2a5eb8bf5d1b5cc 100644 (file)
@@ -14,7 +14,6 @@ import com.google.common.base.Optional;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import javax.annotation.Nonnull;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -35,7 +34,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.Elan
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
@@ -177,18 +175,6 @@ public class ElanInstanceManager extends AsyncDataTreeChangeListenerBase<ElanIns
         return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, elanIdentifierId).orNull();
     }
 
-    @Nonnull
-    public List<DpnInterfaces> getElanDPNByName(String elanInstanceName) {
-        return getElanDPNByName(broker, elanInstanceName);
-    }
-
-    @Nonnull
-    public static List<DpnInterfaces> getElanDPNByName(DataBroker dataBroker, String elanInstanceName) {
-        InstanceIdentifier<ElanDpnInterfacesList> elanIdentifier = getElanDpnOperationDataPath(elanInstanceName);
-        return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, elanIdentifier).toJavaUtil().map(
-                ElanDpnInterfacesList::getDpnInterfaces).orElse(Collections.emptyList());
-    }
-
     private static InstanceIdentifier<ElanDpnInterfacesList> getElanDpnOperationDataPath(String elanInstanceName) {
         return InstanceIdentifier.builder(ElanDpnInterfaces.class)
                 .child(ElanDpnInterfacesList.class, new ElanDpnInterfacesListKey(elanInstanceName)).build();
index f804b03371570cbf2329b5aa3709da80790d69a5..c5ab4442ab08ed1a4b61733bc5d9803449b503bc 100644 (file)
@@ -52,12 +52,6 @@ public class ElanInterfaceConfigListener
         registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
     }
 
-    @Override
-    public void close() {
-        LOG.info("ElanInterfaceConfigListener Closed");
-        super.close();
-    }
-
     @Override
     protected InstanceIdentifier<Interface> getWildCardPath() {
         return InstanceIdentifier.create(Interfaces.class).child(Interface.class);
index 762b3d98869dcba8696eca7aacfb40d06eee4dd5..62cf34092b410a7ddad869eacb1d21831c7d1a52 100644 (file)
@@ -25,9 +25,7 @@ import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ConcurrentMap;
 import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -105,7 +103,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ExternalTeps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan;
@@ -129,8 +126,11 @@ import org.slf4j.LoggerFactory;
  * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface
  */
 @Singleton
-@SuppressWarnings("deprecation")
 public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanInterface, ElanInterfaceManager> {
+    private static final Logger LOG = LoggerFactory.getLogger(ElanInterfaceManager.class);
+    private static final long WAIT_TIME_FOR_SYNC_INSTALL = Long.getLong("wait.time.sync.install", 300L);
+    private static final boolean SH_FLAG_SET = true;
+    private static final boolean SH_FLAG_UNSET = false;
 
     private final DataBroker broker;
     private final IMdsalApiManager mdsalManager;
@@ -141,26 +141,21 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
     private final ElanItmUtils elanItmUtils;
     private final ElanEtreeUtils elanEtreeUtils;
     private final ElanL2GatewayUtils elanL2GatewayUtils;
-    private ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
-    private ElanUtils elanUtils;
+    private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
+    private final ElanUtils elanUtils;
     private final JobCoordinator jobCoordinator;
 
-    private static final long WAIT_TIME_FOR_SYNC_INSTALL = Long.getLong("wait.time.sync.install", 300L);
-    private static final boolean SH_FLAG_SET = true;
-    private static final boolean SH_FLAG_UNSET = false;
-
     private final Map<String, ConcurrentLinkedQueue<ElanInterface>>
         unProcessedElanInterfaces = new ConcurrentHashMap<>();
 
-    private static final Logger LOG = LoggerFactory.getLogger(ElanInterfaceManager.class);
-
     @Inject
     public ElanInterfaceManager(final DataBroker dataBroker, final IdManagerService managerService,
                                 final IMdsalApiManager mdsalApiManager, IInterfaceManager interfaceManager,
                                 final ElanForwardingEntriesHandler elanForwardingEntriesHandler,
                                 final INeutronVpnManager neutronVpnManager, final ElanItmUtils elanItmUtils,
                                 final ElanEtreeUtils elanEtreeUtils, final ElanL2GatewayUtils elanL2GatewayUtils,
-                                final JobCoordinator jobCoordinator) {
+                                final ElanUtils elanUtils, final JobCoordinator jobCoordinator,
+                                final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils) {
         super(ElanInterface.class, ElanInterfaceManager.class);
         this.broker = dataBroker;
         this.idManager = managerService;
@@ -171,20 +166,9 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
         this.elanItmUtils = elanItmUtils;
         this.elanEtreeUtils = elanEtreeUtils;
         this.elanL2GatewayUtils = elanL2GatewayUtils;
-        this.jobCoordinator = jobCoordinator;
-    }
-
-    /**
-     * This method is used instead of "regular" standard constructor dependency injection in, only,
-     * ElanServiceProvider's constructor to wire things together. It was done like this because of the unholy
-     * triumvirate of unhealthy love triangle between (at least) ElanUtils, ElanInterfaceManager and
-     * ElanL2GatewayMulticastUtils. The proper solution to be able to get rid of this would be to split up some of these
-     * relatively big classes into smaller classes, and then inject more fine grained among them.
-     */
-    public void setElanUtils(ElanUtils elanUtils) {
         this.elanUtils = elanUtils;
-        this.elanL2GatewayMulticastUtils = elanUtils.getElanL2GatewayMulticastUtils();
-        this.elanForwardingEntriesHandler.setElanUtils(elanUtils);
+        this.jobCoordinator = jobCoordinator;
+        this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
     }
 
     @Override
@@ -868,7 +852,7 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
             } catch (InterruptedException e1) {
                 LOG.warn("Error while waiting for local BC group for ELAN {} to install", elanInfo);
             }
-            setupElanBroadcastGroups(elanInfo, dpnInterfaces, dpId);
+            elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, dpnInterfaces, dpId);
             try {
                 Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
             } catch (InterruptedException e1) {
@@ -917,89 +901,8 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
 
     private List<Bucket> getRemoteBCGroupBucketInfos(ElanInstance elanInfo, int bucketKeyStart,
                                                      InterfaceInfo interfaceInfo, long elanTag) {
-        return getRemoteBCGroupBuckets(elanInfo, null, interfaceInfo.getDpId(), bucketKeyStart, elanTag);
-    }
-
-    @Nonnull
-    public List<Bucket> getRemoteBCGroupBuckets(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId,
-                                                int bucketId, long elanTag) {
-        List<Bucket> listBucketInfo = new ArrayList<>();
-        ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
-
-        if (isVxlan(elanInfo)) {
-            listBucketInfo.addAll(getRemoteBCGroupTunnelBuckets(elanDpns, dpnId, bucketId,
-                    elanUtils.isOpenstackVniSemanticsEnforced() ? elanInfo.getSegmentationId() : elanTag));
-        }
-        listBucketInfo.addAll(getRemoteBCGroupExternalPortBuckets(elanDpns, dpnInterfaces, dpnId,
-            getNextAvailableBucketId(listBucketInfo.size())));
-        listBucketInfo.addAll(getRemoteBCGroupBucketsOfElanL2GwDevices(elanInfo, dpnId,
-            getNextAvailableBucketId(listBucketInfo.size())));
-        listBucketInfo.addAll(getRemoteBCGroupBucketsOfElanExternalTeps(elanInfo, dpnId,
-                getNextAvailableBucketId(listBucketInfo.size())));
-        return listBucketInfo;
-    }
-
-    private int getNextAvailableBucketId(int bucketSize) {
-        return bucketSize + 1;
-    }
-
-    @SuppressWarnings("checkstyle:IllegalCatch")
-    private List<Bucket> getRemoteBCGroupTunnelBuckets(ElanDpnInterfacesList elanDpns, BigInteger dpnId, int bucketId,
-            long elanTagOrVni) {
-        List<Bucket> listBucketInfo = new ArrayList<>();
-        if (elanDpns != null) {
-            for (DpnInterfaces dpnInterface : elanDpns.getDpnInterfaces()) {
-                if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpnId)
-                        && dpnInterface.getInterfaces() != null && !dpnInterface.getInterfaces().isEmpty()) {
-                    try {
-                        List<Action> listActionInfo = elanItmUtils.getInternalTunnelItmEgressAction(dpnId,
-                                dpnInterface.getDpId(), elanTagOrVni);
-                        if (listActionInfo.isEmpty()) {
-                            continue;
-                        }
-                        listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
-                                MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
-                        bucketId++;
-                    } catch (Exception ex) {
-                        LOG.error("Logical Group Interface not found between source Dpn - {}, destination Dpn - {} ",
-                                dpnId, dpnInterface.getDpId(), ex);
-                    }
-                }
-            }
-        }
-        return listBucketInfo;
-    }
-
-    private List<Bucket> getRemoteBCGroupExternalPortBuckets(ElanDpnInterfacesList elanDpns,
-            DpnInterfaces dpnInterfaces, BigInteger dpnId, int bucketId) {
-        DpnInterfaces currDpnInterfaces = dpnInterfaces != null ? dpnInterfaces : getDpnInterfaces(elanDpns, dpnId);
-        if (currDpnInterfaces == null || !elanUtils.isDpnPresent(currDpnInterfaces.getDpId())
-                || currDpnInterfaces.getInterfaces() == null || currDpnInterfaces.getInterfaces().isEmpty()) {
-            return Collections.emptyList();
-        }
-        List<Bucket> listBucketInfo = new ArrayList<>();
-        for (String interfaceName : currDpnInterfaces.getInterfaces()) {
-            if (interfaceManager.isExternalInterface(interfaceName)) {
-                List<Action> listActionInfo = elanItmUtils.getExternalPortItmEgressAction(interfaceName);
-                if (!listActionInfo.isEmpty()) {
-                    listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
-                            MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
-                    bucketId++;
-                }
-            }
-        }
-        return listBucketInfo;
-    }
-
-    private DpnInterfaces getDpnInterfaces(ElanDpnInterfacesList elanDpns, BigInteger dpnId) {
-        if (elanDpns != null) {
-            for (DpnInterfaces dpnInterface : elanDpns.getDpnInterfaces()) {
-                if (dpnInterface.getDpId().equals(dpnId)) {
-                    return dpnInterface;
-                }
-            }
-        }
-        return null;
+        return elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInfo, null, interfaceInfo.getDpId(),
+                bucketKeyStart, elanTag);
     }
 
     private void setElanAndEtreeBCGrouponOtherDpns(ElanInstance elanInfo, BigInteger dpId) {
@@ -1052,8 +955,8 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
                             }
                         }
                     }
-                    List<Bucket> elanL2GwDevicesBuckets = getRemoteBCGroupBucketsOfElanL2GwDevices(elanInfo, dpId,
-                            bucketId);
+                    List<Bucket> elanL2GwDevicesBuckets = elanL2GatewayMulticastUtils
+                            .getRemoteBCGroupBucketsOfElanL2GwDevices(elanInfo, dpId, bucketId);
                     remoteListBucketInfo.addAll(elanL2GwDevicesBuckets);
 
                     if (remoteListBucketInfo.isEmpty()) {
@@ -1146,57 +1049,6 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
         return Collections.emptyList();
     }
 
-    public void setupElanBroadcastGroups(ElanInstance elanInfo, BigInteger dpnId) {
-        setupElanBroadcastGroups(elanInfo, null, dpnId);
-    }
-
-    public void setupElanBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
-        setupStandardElanBroadcastGroups(elanInfo, dpnInterfaces, dpnId);
-        setupLeavesEtreeBroadcastGroups(elanInfo, dpnInterfaces, dpnId);
-    }
-
-    public void setupStandardElanBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
-        List<Bucket> listBucket = new ArrayList<>();
-        int bucketId = 0;
-        int actionKey = 0;
-        Long elanTag = elanInfo.getElanTag();
-        List<Action> listAction = new ArrayList<>();
-        listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
-        listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT,
-                MDSALUtil.WATCH_GROUP));
-        bucketId++;
-        List<Bucket> listBucketInfoRemote = getRemoteBCGroupBuckets(elanInfo, dpnInterfaces, dpnId, bucketId, elanTag);
-        listBucket.addAll(listBucketInfoRemote);
-        long groupId = ElanUtils.getElanRemoteBCGId(elanTag);
-        Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll,
-                MDSALUtil.buildBucketLists(listBucket));
-        LOG.trace("Installing the remote BroadCast Group:{}", group);
-        mdsalManager.syncInstallGroup(dpnId, group);
-    }
-
-    public void setupLeavesEtreeBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
-        EtreeInstance etreeInstance = elanInfo.getAugmentation(EtreeInstance.class);
-        if (etreeInstance != null) {
-            long etreeLeafTag = etreeInstance.getEtreeLeafTagVal().getValue();
-            List<Bucket> listBucket = new ArrayList<>();
-            int bucketId = 0;
-            int actionKey = 0;
-            List<Action> listAction = new ArrayList<>();
-            listAction.add(new ActionGroup(ElanUtils.getEtreeLeafLocalBCGId(etreeLeafTag)).buildAction(++actionKey));
-            listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT,
-                    MDSALUtil.WATCH_GROUP));
-            bucketId++;
-            List<Bucket> listBucketInfoRemote = getRemoteBCGroupBuckets(elanInfo, dpnInterfaces, dpnId, bucketId,
-                    etreeLeafTag);
-            listBucket.addAll(listBucketInfoRemote);
-            long groupId = ElanUtils.getEtreeLeafRemoteBCGId(etreeLeafTag);
-            Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll,
-                    MDSALUtil.buildBucketLists(listBucket));
-            LOG.trace("Installing the remote BroadCast Group:{}", group);
-            mdsalManager.syncInstallGroup(dpnId, group);
-        }
-    }
-
     private void createDropBucket(List<Bucket> listBucket) {
         List<Action> actionsInfos = new ArrayList<>();
         actionsInfos.add(new ActionDrop().buildAction());
@@ -1693,7 +1545,7 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
                     // update Remote BC Group
                     LOG.trace("procesing elan remote bc group for tunnel event {}", elanInfo);
                     try {
-                        setupElanBroadcastGroups(elanInfo, srcDpId);
+                        elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, srcDpId);
                     } catch (RuntimeException e) {
                         LOG.error("Error while adding remote bc group for {} on dpId {} ", elanName, srcDpId);
                     }
@@ -1761,7 +1613,7 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
             }
             LOG.debug("Elan instance:{} is present in Dpn:{} ", elanName, dpId);
 
-            setupElanBroadcastGroups(elanInfo, dpId);
+            elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, dpId);
             // install L2gwDevices local macs in dpn.
             elanL2GatewayUtils.installL2gwDeviceMacsInDpn(dpId, externalNodeId, elanInfo, intrf.getName());
             // Install dpn macs on external device
@@ -1860,56 +1712,6 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
         return mkMatches;
     }
 
-    public void updateRemoteBroadcastGroupForAllElanDpns(ElanInstance elanInfo) {
-        List<DpnInterfaces> dpns = elanUtils.getInvolvedDpnsInElan(elanInfo.getElanInstanceName());
-        for (DpnInterfaces dpn : dpns) {
-            setupElanBroadcastGroups(elanInfo, dpn.getDpId());
-        }
-    }
-
-    public List<Bucket> getRemoteBCGroupBucketsOfElanL2GwDevices(ElanInstance elanInfo, BigInteger dpnId,
-            int bucketId) {
-        List<Bucket> listBucketInfo = new ArrayList<>();
-        ConcurrentMap<String, L2GatewayDevice> map = ElanL2GwCacheUtils
-                .getInvolvedL2GwDevices(elanInfo.getElanInstanceName());
-        for (L2GatewayDevice device : map.values()) {
-            String interfaceName = elanItmUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId),
-                    device.getHwvtepNodeId());
-            if (interfaceName == null) {
-                continue;
-            }
-            List<Action> listActionInfo = elanItmUtils.buildTunnelItmEgressActions(interfaceName,
-                    ElanUtils.getVxlanSegmentationId(elanInfo));
-            listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
-                    MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
-            bucketId++;
-        }
-        return listBucketInfo;
-    }
-
-    public List<Bucket> getRemoteBCGroupBucketsOfElanExternalTeps(ElanInstance elanInfo, BigInteger dpnId,
-                                                                  int bucketId) {
-        List<Bucket> listBucketInfo = new ArrayList<>();
-        List<ExternalTeps> teps = elanInfo.getExternalTeps();
-        if (teps == null || teps.isEmpty()) {
-            return listBucketInfo;
-        }
-        for (ExternalTeps tep : teps) {
-            String interfaceName = elanItmUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId),
-                    tep.getTepIp().toString());
-            if (interfaceName == null) {
-                LOG.error("Could not get interface name to ext tunnel {} {}", dpnId, tep.getTepIp());
-                continue;
-            }
-            List<Action> listActionInfo = elanItmUtils.buildTunnelItmEgressActions(interfaceName,
-                    elanInfo.getSegmentationId());
-            listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
-                    MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
-            bucketId++;
-        }
-        return listBucketInfo;
-    }
-
     @Override
     protected ElanInterfaceManager getDataTreeChangeListener() {
         return this;
@@ -1918,7 +1720,7 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
     public void handleExternalInterfaceEvent(ElanInstance elanInstance, DpnInterfaces dpnInterfaces,
                                              BigInteger dpId) {
         LOG.debug("setting up remote BC group for elan {}", elanInstance.getPhysicalNetworkName());
-        setupStandardElanBroadcastGroups(elanInstance, dpnInterfaces, dpId);
+        elanL2GatewayMulticastUtils.setupStandardElanBroadcastGroups(elanInstance, dpnInterfaces, dpId);
         try {
             Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
         } catch (InterruptedException e) {
index ffd1c373738ce3ccb0024e637a1221bf2a8c8664..edd5cfd38a4a18af33abb62e7d49f79608301e93 100644 (file)
@@ -8,6 +8,9 @@
 package org.opendaylight.netvirt.elan.internal;
 
 import java.math.BigInteger;
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
@@ -26,6 +29,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanInterfaceStateChangeListener
         extends AsyncDataTreeChangeListenerBase<Interface, ElanInterfaceStateChangeListener> {
 
@@ -35,6 +39,7 @@ public class ElanInterfaceStateChangeListener
     private final ElanInterfaceManager elanInterfaceManager;
     private final JobCoordinator jobCoordinator;
 
+    @Inject
     public ElanInterfaceStateChangeListener(final DataBroker db, final ElanInterfaceManager ifManager,
             final JobCoordinator jobCoordinator) {
         super(Interface.class, ElanInterfaceStateChangeListener.class);
@@ -44,6 +49,7 @@ public class ElanInterfaceStateChangeListener
     }
 
     @Override
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.OPERATIONAL, broker);
     }
@@ -97,11 +103,6 @@ public class ElanInterfaceStateChangeListener
         elanInterfaceManager.add(elanInterfaceId, elanInterface);
     }
 
-    @Override
-    public void close() {
-
-    }
-
     @Override
     protected InstanceIdentifier<Interface> getWildCardPath() {
         return InstanceIdentifier.create(InterfacesState.class).child(Interface.class);
index 632440e23df2b7608a49f3c8e906ba7b331f77fd..a0bd0b49fbdc7ffa7255b2e15b8d17868369f52c 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.netvirt.elan.internal;
 
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
@@ -21,6 +24,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanInterfaceStateClusteredListener extends
     AsyncClusteredDataTreeChangeListenerBase<Interface, ElanInterfaceStateClusteredListener> {
 
@@ -35,6 +39,7 @@ public class ElanInterfaceStateClusteredListener extends
      * Why do we have ElanInterfaceStateChangeListener and ElanInterfaceStateClusteredListener
      * both within same module? Refactor this code into single listener.
      */
+    @Inject
     public ElanInterfaceStateClusteredListener(DataBroker broker, ElanInterfaceManager elanInterfaceManager,
                                                ElanUtils elanUtils, ElanClusterUtils elanClusterUtils) {
         this.broker = broker;
@@ -43,6 +48,7 @@ public class ElanInterfaceStateClusteredListener extends
         this.elanClusterUtils = elanClusterUtils;
     }
 
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.OPERATIONAL, broker);
     }
index 5dbdd63109308b1cdb6415639eee3b169258e40a..2b269c442f26fc6b3a69c4cb80462dadc27f7ec8 100644 (file)
@@ -12,6 +12,9 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
+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;
@@ -27,6 +30,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanLearntVpnVipToPortListener extends
         AsyncDataTreeChangeListenerBase<LearntVpnVipToPort, ElanLearntVpnVipToPortListener> {
     private static final Logger LOG = LoggerFactory.getLogger(ElanLearntVpnVipToPortListener.class);
@@ -35,6 +39,7 @@ public class ElanLearntVpnVipToPortListener extends
     private final ElanUtils elanUtils;
     private final JobCoordinator jobCoordinator;
 
+    @Inject
     public ElanLearntVpnVipToPortListener(DataBroker broker, IInterfaceManager interfaceManager, ElanUtils elanUtils,
             JobCoordinator jobCoordinator) {
         super(LearntVpnVipToPort.class, ElanLearntVpnVipToPortListener.class);
@@ -45,16 +50,11 @@ public class ElanLearntVpnVipToPortListener extends
     }
 
     @Override
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.OPERATIONAL, broker);
     }
 
-    @Override
-    public void close() {
-        super.close();
-        LOG.debug("ElanLearntVpnPortIpToPort Listener Closed");
-    }
-
     @Override
     protected InstanceIdentifier<LearntVpnVipToPort> getWildCardPath() {
         return InstanceIdentifier.create(LearntVpnVipToPortData.class).child(LearntVpnVipToPort.class);
index 3cb3269f129050d9c98303e3324847d89045340d..db3444779c717b27678e9caf5446a740c56948a7 100644 (file)
@@ -12,6 +12,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+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;
@@ -51,6 +54,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanNodeListener extends AsyncDataTreeChangeListenerBase<Node, ElanNodeListener> {
 
     private static final Logger LOG = LoggerFactory.getLogger(ElanNodeListener.class);
@@ -63,6 +67,7 @@ public class ElanNodeListener extends AsyncDataTreeChangeListenerBase<Node, Elan
     private final boolean puntLldpToController;
     private final JobCoordinator jobCoordinator;
 
+    @Inject
     public ElanNodeListener(DataBroker dataBroker, IMdsalApiManager mdsalManager, ElanConfig elanConfig,
             IdManagerService idManagerService, JobCoordinator jobCoordinator) {
         this.broker = dataBroker;
@@ -74,6 +79,7 @@ public class ElanNodeListener extends AsyncDataTreeChangeListenerBase<Node, Elan
     }
 
     @Override
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.OPERATIONAL, broker);
     }
@@ -229,7 +235,7 @@ public class ElanNodeListener extends AsyncDataTreeChangeListenerBase<Node, Elan
     }
 
     private void setupExternalL2vniTableMissFlow(BigInteger dpnId) {
-        List<MatchInfo> matches = new ArrayList<MatchInfo>();
+        List<MatchInfo> matches = new ArrayList<>();
         List<ActionInfo> actionsInfos = Collections.singletonList(new ActionNxResubmit(NwConstants
                         .LPORT_DISPATCHER_TABLE));
         List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(actionsInfos));
index a67f34c6a5942e82c40224f41ec1d44daa470675..8135957d313c86517a46ef95d6ea115c54cdf787 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.netvirt.elan.internal;
 
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
@@ -25,6 +28,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Listen for new OVSDB nodes and then make sure they have the necessary bridges configured.
  */
+@Singleton
 public class ElanOvsdbNodeListener extends AsyncDataTreeChangeListenerBase<Node, ElanOvsdbNodeListener> {
     private static final Logger LOG = LoggerFactory.getLogger(ElanOvsdbNodeListener.class);
     private final DataBroker dataBroker;
@@ -41,6 +45,7 @@ public class ElanOvsdbNodeListener extends AsyncDataTreeChangeListenerBase<Node,
      * @param bridgeMgr bridge manager
      * @param elanProvider elan provider
      */
+    @Inject
     public ElanOvsdbNodeListener(final DataBroker dataBroker, ElanConfig elanConfig,
                                  final ElanBridgeManager bridgeMgr,
                                  final IElanService elanProvider, final TransportZoneNotificationUtil tzUtil) {
@@ -53,6 +58,7 @@ public class ElanOvsdbNodeListener extends AsyncDataTreeChangeListenerBase<Node,
     }
 
     @Override
+    @PostConstruct
     public void init() {
         LOG.info("{} init", getClass().getSimpleName());
         registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
index 1fbca0b3d5a192912f1bed64b401eeee6a522b96..89ea8961c773a02c7fbf673153bc5acde74f1fac 100755 (executable)
@@ -10,6 +10,8 @@ package org.opendaylight.netvirt.elan.internal;
 import com.google.common.base.Optional;
 import java.math.BigInteger;
 import java.util.Collections;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.liblldp.NetUtils;
 import org.opendaylight.controller.liblldp.PacketException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -42,7 +44,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@SuppressWarnings("deprecation")
+@Singleton
 public class ElanPacketInHandler implements PacketProcessingListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(ElanPacketInHandler.class);
@@ -54,6 +56,7 @@ public class ElanPacketInHandler implements PacketProcessingListener {
     private final EvpnUtils evpnUtils;
     private final JobCoordinator jobCoordinator;
 
+    @Inject
     public ElanPacketInHandler(DataBroker dataBroker, final IInterfaceManager interfaceManager, ElanUtils elanUtils,
             EvpnUtils evpnUtils, ElanL2GatewayUtils elanL2GatewayUtils, JobCoordinator jobCoordinator) {
         broker = dataBroker;
index d7bec284edc4bf08c9dce20a7726eb60c4b9a1f3..f904aa90637631937fb8b34ac155508823efc6e8 100644 (file)
@@ -47,6 +47,7 @@ import org.opendaylight.netvirt.elan.utils.ElanUtils;
 import org.opendaylight.netvirt.elanmanager.api.ElanHelper;
 import org.opendaylight.netvirt.elanmanager.api.IElanService;
 import org.opendaylight.netvirt.elanmanager.exceptions.MacNotFoundException;
+import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
@@ -92,8 +93,7 @@ public class ElanServiceProvider extends AbstractLifecycle implements IElanServi
     private final DataBroker broker;
     private final ElanStatusMonitor elanStatusMonitor;
     private final ElanUtils elanUtils;
-
-    private boolean generateIntBridgeMac = true;
+    private final SouthboundUtils southboundUtils;
     private boolean isL2BeforeL3;
 
     private final EntityOwnershipCandidateRegistration candidateRegistration;
@@ -104,7 +104,8 @@ public class ElanServiceProvider extends AbstractLifecycle implements IElanServi
                                DataBroker dataBroker,
                                ElanInterfaceManager elanInterfaceManager,
                                ElanStatusMonitor elanStatusMonitor, ElanUtils elanUtils,
-                               EntityOwnershipService entityOwnershipService) {
+                               EntityOwnershipService entityOwnershipService,
+                               SouthboundUtils southboundUtils) {
         this.idManager = idManager;
         this.interfaceManager = interfaceManager;
         this.elanInstanceManager = elanInstanceManager;
@@ -112,7 +113,7 @@ public class ElanServiceProvider extends AbstractLifecycle implements IElanServi
         this.broker = dataBroker;
         this.elanStatusMonitor = elanStatusMonitor;
         this.elanUtils = elanUtils;
-        elanInterfaceManager.setElanUtils(elanUtils);
+        this.southboundUtils = southboundUtils;
 
         candidateRegistration = registerCandidate(entityOwnershipService);
     }
@@ -131,7 +132,7 @@ public class ElanServiceProvider extends AbstractLifecycle implements IElanServi
     @Override
     @SuppressWarnings("checkstyle:IllegalCatch")
     protected void start() throws Exception {
-        LOG.info("Starting ElnaServiceProvider");
+        LOG.info("Starting ElanServiceProvider");
         elanStatusMonitor.reportStatus("STARTING");
         setIsL2BeforeL3();
         try {
@@ -148,6 +149,8 @@ public class ElanServiceProvider extends AbstractLifecycle implements IElanServi
         if (candidateRegistration != null) {
             candidateRegistration.close();
         }
+
+        LOG.info("ElanServiceProvider stopped");
     }
 
     @Override
@@ -451,14 +454,6 @@ public class ElanServiceProvider extends AbstractLifecycle implements IElanServi
         return elanInterfaces;
     }
 
-    public boolean getGenerateIntBridgeMac() {
-        return generateIntBridgeMac;
-    }
-
-    public void setGenerateIntBridgeMac(boolean generateIntBridgeMac) {
-        this.generateIntBridgeMac = generateIntBridgeMac;
-    }
-
     @Override
     public void createExternalElanNetworks(Node node) {
         handleExternalElanNetworks(node, true, (elanInstance, interfaceName) -> {
@@ -822,7 +817,7 @@ public class ElanServiceProvider extends AbstractLifecycle implements IElanServi
             return;
         }
 
-        List<Node> nodes = bridgeMgr.southboundUtils.getOvsdbNodes();
+        List<Node> nodes = southboundUtils.getOvsdbNodes();
         if (nodes == null || nodes.isEmpty()) {
             LOG.trace("No OVS nodes found while creating external network for ELAN {}",
                     elanInstance.getElanInstanceName());
index 51d910eea1355e93a6b883699bded12d763f0c81..ab74c0ad23fdb212ee3665f364086ea02694be5b 100644 (file)
@@ -15,6 +15,8 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
+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;
@@ -40,7 +42,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@SuppressWarnings("deprecation")
+@Singleton
 public class ElanSmacFlowEventListener implements SalFlowListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(ElanSmacFlowEventListener.class);
@@ -50,6 +52,7 @@ public class ElanSmacFlowEventListener implements SalFlowListener {
     private final ElanUtils elanUtils;
     private final JobCoordinator jobCoordinator;
 
+    @Inject
     public ElanSmacFlowEventListener(DataBroker broker, IInterfaceManager interfaceManager, ElanUtils elanUtils,
             JobCoordinator jobCoordinator) {
         this.broker = broker;
index 4e4edaee752251bbe787403dfc661a574759adac..94319ac4c36f616e8ce1b4d58b76594d4a51a79e 100644 (file)
@@ -9,6 +9,9 @@ package org.opendaylight.netvirt.elan.internal;
 
 import java.math.BigInteger;
 import java.util.Collections;
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
@@ -24,6 +27,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanTunnelInterfaceStateListener extends AsyncDataTreeChangeListenerBase<StateTunnelList,
     ElanTunnelInterfaceStateListener> {
     private static final Logger LOG = LoggerFactory.getLogger(ElanTunnelInterfaceStateListener.class);
@@ -32,6 +36,7 @@ public class ElanTunnelInterfaceStateListener extends AsyncDataTreeChangeListene
     private final ElanUtils elanUtils;
     private final JobCoordinator jobCoordinator;
 
+    @Inject
     public ElanTunnelInterfaceStateListener(final DataBroker dataBroker,
             final ElanInterfaceManager elanInterfaceManager, final ElanUtils elanUtils,
             final JobCoordinator jobCoordinator) {
@@ -43,6 +48,7 @@ public class ElanTunnelInterfaceStateListener extends AsyncDataTreeChangeListene
     }
 
     @Override
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
     }
index f3223f15e8ae8d8580adef33271f9c4e863a5677..6f3d41c6d9df513b0639c1ffb2e74b7fd13e2878 100644 (file)
@@ -8,7 +8,9 @@
 package org.opendaylight.netvirt.elan.internal;
 
 import java.util.stream.Collectors;
-
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
@@ -22,14 +24,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class VpnDpnToTransportZoneListener
         extends AsyncDataTreeChangeListenerBase<VpnToDpnList, VpnDpnToTransportZoneListener> {
 
     private static final Logger LOG = LoggerFactory.getLogger(VpnDpnToTransportZoneListener.class);
-    private TransportZoneNotificationUtil transportZoneNotificationUtil;
-    private DataBroker dbx;
-    private Boolean useTransportZone;
+    private final TransportZoneNotificationUtil transportZoneNotificationUtil;
+    private final DataBroker dbx;
+    private final Boolean useTransportZone;
 
+    @Inject
     public VpnDpnToTransportZoneListener(final DataBroker dbx, final IInterfaceManager interfaceManager,
             final ElanConfig elanConfig, final TransportZoneNotificationUtil tznu) {
         useTransportZone = elanConfig.isAutoConfigTransportZones();
@@ -37,6 +41,7 @@ public class VpnDpnToTransportZoneListener
         this.dbx = dbx;
     }
 
+    @PostConstruct
     public void start() {
         LOG.info("{} start", getClass().getSimpleName());
 
index 3f4cb8777bacb22bf82cd935622bae640884853e..8fc95effabe48bb69d23d38e80cdf50c447edc62 100644 (file)
@@ -9,25 +9,26 @@ package org.opendaylight.netvirt.elan.l2gw.ha.handlers;
 
 import com.google.common.base.Optional;
 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.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+@Singleton
 public class HAEventHandler implements IHAEventHandler {
 
     private final NodeConnectedHandler nodeConnectedHandler;
     private final ConfigNodeUpdatedHandler configNodeUpdatedHandler = new ConfigNodeUpdatedHandler();
     private final OpNodeUpdatedHandler opNodeUpdatedHandler = new OpNodeUpdatedHandler();
 
+    @Inject
     public HAEventHandler(DataBroker db) {
         nodeConnectedHandler = new NodeConnectedHandler(db);
     }
 
-    public void close() {
-    }
-
     @Override
     public void handleChildNodeConnected(Node connectedNode,
                                          InstanceIdentifier<Node> connectedNodePath,
index 97f1c4e61d02a3c0b3da9f3ef10a3a937f1c0106..d05a5e67bcf92c390ed396db5dc77eea7d35040d 100644 (file)
@@ -11,6 +11,8 @@ import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastor
 
 import java.util.Set;
 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.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -21,9 +23,11 @@ import org.opendaylight.netvirt.elan.l2gw.ha.handlers.IHAEventHandler;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+@Singleton
 public class HAConfigNodeListener extends HwvtepNodeBaseListener {
     private final IHAEventHandler haEventHandler;
 
+    @Inject
     public HAConfigNodeListener(DataBroker db, HAEventHandler haEventHandler) throws Exception {
         super(LogicalDatastoreType.CONFIGURATION, db);
         this.haEventHandler = haEventHandler;
index c505bf40a6988bbf0fbd9e8c505122a01b1e266b..8dd0bf27cfd46182ce6d7ee0def88f95674ba398 100644 (file)
@@ -9,6 +9,9 @@ package org.opendaylight.netvirt.elan.l2gw.ha.listeners;
 
 import java.util.ArrayList;
 import java.util.List;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.genius.utils.batching.ResourceBatchingManager;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
@@ -35,6 +38,7 @@ import org.opendaylight.yangtools.yang.binding.ChildOf;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+@Singleton
 public class HAListeners implements AutoCloseable {
     private static final InstanceIdentifier<TerminationPoint> PHYSICAL_PORT_IID =
         InstanceIdentifier.create(NetworkTopology.class)
@@ -44,6 +48,7 @@ public class HAListeners implements AutoCloseable {
     private final DataBroker broker;
     private final List<HwvtepNodeDataListener<?>> listeners = new ArrayList<>();
 
+    @Inject
     public HAListeners(DataBroker broker) {
         this.broker = broker;
         registerListener(LocalMcastMacs.class, new LocalMcastCmd());
@@ -59,10 +64,8 @@ public class HAListeners implements AutoCloseable {
                 ResourceBatchingManager.ShardResource.OPERATIONAL_TOPOLOGY));
     }
 
-    public void init() {
-    }
-
     @Override
+    @PreDestroy
     public void close() throws Exception {
         for (HwvtepNodeDataListener listener : listeners) {
             listener.close();
index 74b14422e9bc6be8ffd1d39e663d48baa2582c28..da4b87c9110d8c06f72d00b2ac2da17f18f0c73d 100644 (file)
@@ -16,6 +16,8 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
+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.ReadWriteTransaction;
@@ -29,12 +31,14 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class HAOpClusteredListener extends HwvtepNodeBaseListener implements ClusteredDataTreeChangeListener<Node> {
     private static final Logger LOG = LoggerFactory.getLogger(HAOpClusteredListener.class);
 
     private final Set<InstanceIdentifier<Node>> connectedNodes = ConcurrentHashMap.newKeySet();
     private final Map<InstanceIdentifier<Node>, Set<Consumer<Optional<Node>>>> waitingJobs = new ConcurrentHashMap<>();
 
+    @Inject
     public HAOpClusteredListener(DataBroker db) throws Exception {
         super(LogicalDatastoreType.OPERATIONAL, db);
         LOG.info("Registering HAOpClusteredListener");
index 74953130caba4f183349d31d1bd461890a1277a9..1fe8c5a358100b41651078a6a7fdeb22b68422a2 100644 (file)
@@ -22,6 +22,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import javax.annotation.Nonnull;
+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.common.api.data.ReadFailedException;
@@ -34,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hw
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+@Singleton
 public class HAOpNodeListener extends HwvtepNodeBaseListener {
 
     private final IHAEventHandler haEventHandler;
@@ -41,6 +44,7 @@ public class HAOpNodeListener extends HwvtepNodeBaseListener {
     private final Map<String, Boolean> availableGlobalNodes = new HashMap<>();
     private final Map<String, Boolean> availablePsNodes = new HashMap<>();
 
+    @Inject
     public HAOpNodeListener(DataBroker db, HAEventHandler haEventHandler) throws Exception {
         super(OPERATIONAL, db);
         this.haEventHandler = haEventHandler;
index 4f6eb29b9411fb2f08261410544107cd83f7115b..d992d96026e00a57f0baf081ac28f6bb3b6f575a 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.netvirt.elan.l2gw.ha.listeners;
 
 import java.util.Collection;
 import java.util.concurrent.ExecutionException;
+import javax.annotation.PreDestroy;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
@@ -144,7 +145,8 @@ public abstract class HwvtepNodeBaseListener implements DataTreeChangeListener<N
     }
 
     @Override
-    public void close() throws Exception {
+    @PreDestroy
+    public void close() {
         if (registration != null) {
             registration.close();
         }
index 919ebec9611a5def9371abc2a583fa0fc72040c9..f939e9762e06c2bc1940fb4ffcafd1bf9c3444cb 100644 (file)
@@ -17,6 +17,7 @@ import java.util.concurrent.Callable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
 import org.opendaylight.genius.utils.hwvtep.HwvtepUtils;
+import org.opendaylight.netvirt.elan.internal.ElanInstanceManager;
 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
@@ -39,6 +40,7 @@ public class AssociateHwvtepToElanJob implements Callable<List<ListenableFuture<
     private final DataBroker broker;
     private final ElanL2GatewayUtils elanL2GatewayUtils;
     private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
+    private final ElanInstanceManager elanInstanceManager;
     private final L2GatewayDevice l2GatewayDevice;
     private final ElanInstance elanInstance;
     private final Devices l2Device;
@@ -46,12 +48,13 @@ public class AssociateHwvtepToElanJob implements Callable<List<ListenableFuture<
     private final boolean createLogicalSwitch;
 
     public AssociateHwvtepToElanJob(DataBroker broker, ElanL2GatewayUtils elanL2GatewayUtils,
-                                    ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
-                                    L2GatewayDevice l2GatewayDevice, ElanInstance elanInstance, Devices l2Device,
-                                    Integer defaultVlan, boolean createLogicalSwitch) {
+            ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils, ElanInstanceManager elanInstanceManager,
+            L2GatewayDevice l2GatewayDevice, ElanInstance elanInstance, Devices l2Device, Integer defaultVlan,
+            boolean createLogicalSwitch) {
         this.broker = broker;
         this.elanL2GatewayUtils = elanL2GatewayUtils;
         this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
+        this.elanInstanceManager = elanInstanceManager;
         this.l2GatewayDevice = l2GatewayDevice;
         this.elanInstance = elanInstance;
         this.l2Device = l2Device;
@@ -86,8 +89,8 @@ public class AssociateHwvtepToElanJob implements Callable<List<ListenableFuture<
 
             LogicalSwitchAddedJob logicalSwitchAddedJob =
                     new LogicalSwitchAddedJob(elanL2GatewayUtils, elanL2GatewayMulticastUtils,
-                            logicalSwitchName, l2Device,
-                            l2GatewayDevice, defaultVlan);
+                        logicalSwitchName, l2Device, l2GatewayDevice, defaultVlan,
+                        () -> elanInstanceManager.getElanInstanceByName(logicalSwitchName));
             return logicalSwitchAddedJob.call();
         }
     }
index a6fde389f2cd305bd07506c55d573f815b544322..0dc50a6cc36a720c7493a7f01b83df3db8112867 100644 (file)
@@ -11,12 +11,13 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Callable;
+import java.util.function.Supplier;
 import javax.annotation.Nullable;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
@@ -28,7 +29,6 @@ import org.slf4j.LoggerFactory;
 public class DisAssociateHwvtepFromElanJob implements Callable<List<ListenableFuture<Void>>> {
     private static final Logger LOG = LoggerFactory.getLogger(DisAssociateHwvtepFromElanJob.class);
 
-    private final DataBroker broker;
     private final ElanL2GatewayUtils elanL2GatewayUtils;
     private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
     private final L2GatewayDevice l2GatewayDevice;
@@ -37,17 +37,18 @@ public class DisAssociateHwvtepFromElanJob implements Callable<List<ListenableFu
     private final Integer defaultVlan;
     private final boolean isLastL2GwConnDeleted;
     private final NodeId hwvtepNodeId;
+    private final Supplier<ElanInstance> elanInstanceSupplier;
 
-    public DisAssociateHwvtepFromElanJob(DataBroker broker, ElanL2GatewayUtils elanL2GatewayUtils,
+    public DisAssociateHwvtepFromElanJob(ElanL2GatewayUtils elanL2GatewayUtils,
                                          ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
                                          @Nullable L2GatewayDevice l2GatewayDevice,  String elanName,
-                                         Devices l2Device, Integer defaultVlan, String nodeId,
-                                         boolean isLastL2GwConnDeleted) {
-        this.broker = broker;
+                                         Supplier<ElanInstance> elanInstanceSupplier, Devices l2Device,
+                                         Integer defaultVlan, String nodeId, boolean isLastL2GwConnDeleted) {
         this.elanL2GatewayUtils = elanL2GatewayUtils;
         this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
         this.l2GatewayDevice = l2GatewayDevice;
         this.elanName = elanName;
+        this.elanInstanceSupplier = elanInstanceSupplier;
         this.l2Device = l2Device;
         this.defaultVlan = defaultVlan;
         this.isLastL2GwConnDeleted = isLastL2GwConnDeleted;
@@ -84,7 +85,7 @@ public class DisAssociateHwvtepFromElanJob implements Callable<List<ListenableFu
 
             LOG.info("delete mcast mac for {} {}", elanName, strHwvtepNodeId);
             futures.addAll(elanL2GatewayMulticastUtils.handleMcastForElanL2GwDeviceDelete(this.elanName,
-                    l2GatewayDevice));
+                    elanInstanceSupplier.get(), l2GatewayDevice));
 
             LOG.info("delete local ucast macs {} {}", elanName, strHwvtepNodeId);
             futures.addAll(elanL2GatewayUtils.deleteL2GwDeviceUcastLocalMacsFromElan(l2GatewayDevice, elanName));
index 4dee099a438749b13e120b12a79af14d38752571..c53a9a12d25b345e9d611308bc81c7b0dd7e91c4 100644 (file)
@@ -11,10 +11,12 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Callable;
+import java.util.function.Supplier;
 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
@@ -24,6 +26,8 @@ import org.slf4j.LoggerFactory;
  * The Class LogicalSwitchAddedWorker.
  */
 public class LogicalSwitchAddedJob implements Callable<List<ListenableFuture<Void>>> {
+    private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchAddedJob.class);
+
     /** The logical switch name. */
     private final String logicalSwitchName;
 
@@ -36,21 +40,21 @@ public class LogicalSwitchAddedJob implements Callable<List<ListenableFuture<Voi
     /** The default vlan id. */
     private final Integer defaultVlanId;
 
-    private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchAddedJob.class);
-
     private final ElanL2GatewayUtils elanL2GatewayUtils;
     private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
+    private final Supplier<ElanInstance> elanInstanceSupplier;
 
     public LogicalSwitchAddedJob(ElanL2GatewayUtils elanL2GatewayUtils,
                                  ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils, String logicalSwitchName,
-                                 Devices physicalDevice, L2GatewayDevice l2GatewayDevice,
-                                 Integer defaultVlanId) {
+                                 Devices physicalDevice, L2GatewayDevice l2GatewayDevice, Integer defaultVlanId,
+                                 Supplier<ElanInstance> elanInstanceSupplier) {
         this.elanL2GatewayUtils = elanL2GatewayUtils;
         this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
         this.logicalSwitchName = logicalSwitchName;
         this.physicalDevice = physicalDevice;
         this.elanL2GwDevice = l2GatewayDevice;
         this.defaultVlanId = defaultVlanId;
+        this.elanInstanceSupplier = elanInstanceSupplier;
         LOG.debug("created logical switch added job for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
     }
 
@@ -69,7 +73,8 @@ public class LogicalSwitchAddedJob implements Callable<List<ListenableFuture<Voi
         futures.add(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(
             new NodeId(elanL2GwDevice.getHwvtepNodeId()), logicalSwitchName, physicalDevice, defaultVlanId));
         LOG.info("creating mast mac entries for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
-        futures.add(elanL2GatewayMulticastUtils.handleMcastForElanL2GwDeviceAdd(logicalSwitchName, elanL2GwDevice));
+        futures.add(elanL2GatewayMulticastUtils.handleMcastForElanL2GwDeviceAdd(logicalSwitchName,
+                elanInstanceSupplier.get(), elanL2GwDevice));
         futures.add(elanL2GatewayUtils.installElanMacsInL2GatewayDevice(
                 logicalSwitchName, elanL2GwDevice));
         return futures;
index e5338f41ddad373e86412aed488b7e70654f5176..0055781f713ff9661b9617c72a8441cd8d246950 100644 (file)
@@ -11,6 +11,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import javax.annotation.PreDestroy;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
@@ -111,6 +112,7 @@ public abstract class ChildListener<P extends DataObject, C extends DataObject,
     protected abstract InstanceIdentifier<Node> getParentWildCardPath();
 
     @Override
+    @PreDestroy
     public void close() throws Exception {
         if (registration != null) {
             registration.close();
index 6ac0f974d016b0065733cd2b9d538f37f47b2f23..bfd66da2e5add271776089df2a0ffac12ed5213b 100644 (file)
@@ -11,11 +11,12 @@ import java.math.BigInteger;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
-import org.opendaylight.netvirt.elan.internal.ElanInstanceManager;
-import org.opendaylight.netvirt.elan.internal.ElanInterfaceManager;
+import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
 import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
 import org.opendaylight.netvirt.elan.utils.ElanUtils;
 import org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils;
@@ -31,21 +32,23 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanGroupListener extends AsyncClusteredDataTreeChangeListenerBase<Group, ElanGroupListener> {
 
     private static final Logger LOG = LoggerFactory.getLogger(ElanGroupListener.class);
-    private final ElanInterfaceManager elanInterfaceManager;
     private final DataBroker broker;
-    private final ElanInstanceManager elanInstanceManager;
     private final ElanClusterUtils elanClusterUtils;
+    private final ElanUtils elanUtils;
+    private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
 
-    public ElanGroupListener(ElanInterfaceManager elanInterfaceManager, final DataBroker db,
-            ElanClusterUtils elanClusterUtils, ElanInstanceManager elanInstanceManager) {
+    @Inject
+    public ElanGroupListener(DataBroker db, ElanClusterUtils elanClusterUtils, ElanUtils elanUtils,
+            ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils) {
         super(Group.class, ElanGroupListener.class);
-        this.elanInterfaceManager = elanInterfaceManager;
         broker = db;
         this.elanClusterUtils = elanClusterUtils;
-        this.elanInstanceManager = elanInstanceManager;
+        this.elanUtils = elanUtils;
+        this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
         registerListener(LogicalDatastoreType.CONFIGURATION, broker);
         LOG.trace("ElanGroupListener registered");
     }
@@ -114,7 +117,7 @@ public class ElanGroupListener extends AsyncClusteredDataTreeChangeListenerBase<
             return;
         }
         boolean updateGroup = false;
-        List<DpnInterfaces> dpns = elanInstanceManager.getElanDPNByName(elanInstance.getElanInstanceName());
+        List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
         if (dpns.size() > 0) {
             expectedElanFootprint += dpns.size();
         } else {
@@ -130,7 +133,7 @@ public class ElanGroupListener extends AsyncClusteredDataTreeChangeListenerBase<
             }
         }
         if (updateGroup) {
-            List<Bucket> bucketList = elanInterfaceManager.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0,
+            List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0,
                     elanInstance.getElanTag());
             expectedElanFootprint--;//remove local bcgroup bucket
             if (bucketList.size() != expectedElanFootprint) {
@@ -140,7 +143,7 @@ public class ElanGroupListener extends AsyncClusteredDataTreeChangeListenerBase<
             LOG.trace("no of buckets mismatched {} {}", elanInstance.getElanInstanceName(),
                     update.getKey().getGroupId());
             elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
-                elanInterfaceManager.setupElanBroadcastGroups(elanInstance, dpnId);
+                elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId);
                 return null;
             });
         } else {
index 224e36358823eba8ca5659d8e0d08ad0b4fe3086..d1fa8434ff0913cb313a5134db618578140a7097 100644 (file)
@@ -11,6 +11,9 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+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.common.api.data.LogicalDatastoreType;
@@ -27,6 +30,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanInstanceListener extends AsyncClusteredDataTreeChangeListenerBase<ElanInstance,
         ElanInstanceListener> {
 
@@ -36,18 +40,16 @@ public class ElanInstanceListener extends AsyncClusteredDataTreeChangeListenerBa
     private final ElanClusterUtils elanClusterUtils;
     private static final Map<String, List<Runnable>> WAITING_JOB_LIST = new ConcurrentHashMap<>();
 
+    @Inject
     public ElanInstanceListener(final DataBroker db, final ElanClusterUtils elanClusterUtils) {
         super(ElanInstance.class, ElanInstanceListener.class);
         broker = db;
         this.elanClusterUtils = elanClusterUtils;
-        registerListener(LogicalDatastoreType.CONFIGURATION, db);
     }
 
+    @PostConstruct
     public void init() {
-    }
-
-    @Override
-    public void close() {
+        registerListener(LogicalDatastoreType.CONFIGURATION, broker);
     }
 
     @Override
index b059fb11e170c942c090572374ddd63f7eb7ff9a..75b2c8e6e7d6cbb4be8ba184309655958a70f029 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.netvirt.elan.l2gw.listeners;
 
 import org.opendaylight.genius.datastoreutils.hwvtep.HwvtepClusteredDataTreeChangeListener;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
+import org.opendaylight.netvirt.elan.internal.ElanInstanceManager;
 import org.opendaylight.netvirt.elan.l2gw.jobs.LogicalSwitchAddedJob;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
@@ -54,6 +55,7 @@ public class HwvtepLogicalSwitchListener extends
     // Id of L2 Gateway connection responsible for this logical switch creation
     private final Uuid l2GwConnId;
 
+    private final ElanInstanceManager elanInstanceManager;
     private final ElanL2GatewayUtils elanL2GatewayUtils;
     private final ElanClusterUtils elanClusterUtils;
     private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
@@ -62,11 +64,12 @@ public class HwvtepLogicalSwitchListener extends
     /**
      * Instantiates a new hardware vtep logical switch listener.
      */
-    public HwvtepLogicalSwitchListener(ElanL2GatewayUtils elanL2GatewayUtils, ElanClusterUtils elanClusterUtils,
-            ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils, L2GatewayConnectionUtils l2GatewayConnectionUtils,
-            L2GatewayDevice l2GatewayDevice, String logicalSwitchName, Devices physicalDevice, Integer defaultVlanId,
-            Uuid l2GwConnId) {
+    public HwvtepLogicalSwitchListener(ElanInstanceManager elanInstanceManager, ElanL2GatewayUtils elanL2GatewayUtils,
+            ElanClusterUtils elanClusterUtils, ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
+            L2GatewayConnectionUtils l2GatewayConnectionUtils, L2GatewayDevice l2GatewayDevice,
+            String logicalSwitchName, Devices physicalDevice, Integer defaultVlanId, Uuid l2GwConnId) {
         super(LogicalSwitches.class, HwvtepLogicalSwitchListener.class);
+        this.elanInstanceManager = elanInstanceManager;
         this.elanL2GatewayUtils = elanL2GatewayUtils;
         this.elanClusterUtils = elanClusterUtils;
         this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
@@ -136,9 +139,9 @@ public class HwvtepLogicalSwitchListener extends
             L2GatewayDevice elanDevice = l2GatewayConnectionUtils.addL2DeviceToElanL2GwCache(
                     logicalSwitchNew.getHwvtepNodeName().getValue(), l2GatewayDevice, l2GwConnId, physicalDevice);
 
-            LogicalSwitchAddedJob logicalSwitchAddedWorker = new LogicalSwitchAddedJob(elanL2GatewayUtils,
-                    elanL2GatewayMulticastUtils, logicalSwitchName, physicalDevice, elanDevice,
-                    defaultVlanId);
+            LogicalSwitchAddedJob logicalSwitchAddedWorker = new LogicalSwitchAddedJob(
+                    elanL2GatewayUtils, elanL2GatewayMulticastUtils, logicalSwitchName, physicalDevice, elanDevice,
+                    defaultVlanId, () -> elanInstanceManager.getElanInstanceByName(logicalSwitchName));
             elanClusterUtils.runOnlyInOwnerNode(logicalSwitchAddedWorker.getJobKey(),
                     "create vlan mappings and mcast configurations", logicalSwitchAddedWorker);
         } catch (RuntimeException e) {
index 4b94277ba86cb36929dfbf63d04a42dafeeff6e9..851d306a40b3314533961d05db7f4f704e415c44 100644 (file)
@@ -15,6 +15,9 @@ 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.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.ReadWriteTransaction;
@@ -50,6 +53,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Listener to handle physical switch updates.
  */
+@Singleton
 public class HwvtepPhysicalSwitchListener
         extends HwvtepAbstractDataTreeChangeListener<PhysicalSwitchAugmentation, HwvtepPhysicalSwitchListener>
         implements ClusteredDataTreeChangeListener<PhysicalSwitchAugmentation> {
@@ -122,6 +126,7 @@ public class HwvtepPhysicalSwitchListener
     /**
      * Instantiates a new hwvtep physical switch listener.
      */
+    @Inject
     public HwvtepPhysicalSwitchListener(final DataBroker dataBroker, ItmRpcService itmRpcService,
             ElanClusterUtils elanClusterUtils, L2gwServiceProvider l2gwServiceProvider,
             HAOpClusteredListener haListener) {
@@ -134,6 +139,7 @@ public class HwvtepPhysicalSwitchListener
     }
 
     @Override
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
     }
index 3c398cc41f99b15571f73d50868f6679b3bd9e53..a90aa3e84516e8517a2c5ccb18c97a067e65a024 100644 (file)
@@ -18,6 +18,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import javax.annotation.Nonnull;
+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.common.api.data.LogicalDatastoreType;
@@ -53,6 +55,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Listener for physical locator presence in operational datastore.
  */
+@Singleton
 public class HwvtepTerminationPointListener
         extends HwvtepClusteredDataTreeChangeListener<TerminationPoint, HwvtepTerminationPointListener> {
 
@@ -62,6 +65,7 @@ public class HwvtepTerminationPointListener
     private final ElanL2GatewayUtils elanL2GatewayUtils;
     private final ElanClusterUtils elanClusterUtils;
 
+    @Inject
     public HwvtepTerminationPointListener(DataBroker broker, ElanL2GatewayUtils elanL2GatewayUtils,
             ElanClusterUtils elanClusterUtils) {
         super(TerminationPoint.class, HwvtepTerminationPointListener.class);
index cf5214c5a01b36660e7d6f8ea47bdcd7a97471e3..5de55b3d170446502b136491b2bb5857ae613f1a 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.netvirt.elan.l2gw.listeners;
 
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
@@ -18,6 +21,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class L2GatewayConnectionListener extends AsyncClusteredDataTreeChangeListenerBase<L2gatewayConnection,
         L2GatewayConnectionListener> {
     private static final Logger LOG = LoggerFactory.getLogger(L2GatewayConnectionListener.class);
@@ -25,12 +29,14 @@ public class L2GatewayConnectionListener extends AsyncClusteredDataTreeChangeLis
     private final DataBroker broker;
     private final L2GatewayConnectionUtils l2GatewayConnectionUtils;
 
+    @Inject
     public L2GatewayConnectionListener(final DataBroker db, L2GatewayConnectionUtils l2GatewayConnectionUtils) {
         super(L2gatewayConnection.class, L2GatewayConnectionListener.class);
         this.broker = db;
         this.l2GatewayConnectionUtils = l2GatewayConnectionUtils;
     }
 
+    @PostConstruct
     public void init() {
         registerListener(LogicalDatastoreType.CONFIGURATION, broker);
     }
index d23807d222fedf4fa17ff10e392817e0ec33036c..fdf9e8db12618dfda2991498dbfa7671d71b8687 100644 (file)
@@ -13,12 +13,13 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Predicate;
+import javax.annotation.PostConstruct;
+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.DataObjectModification;
@@ -45,6 +46,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+@Singleton
 public class LocalUcastMacListener extends ChildListener<Node, LocalUcastMacs, String>
         implements ClusteredDataTreeChangeListener<Node> {
 
@@ -64,11 +66,10 @@ public class LocalUcastMacListener extends ChildListener<Node, LocalUcastMacs, S
     };
 
     private final ElanL2GatewayUtils elanL2GatewayUtils;
-    private final Map<InstanceIdentifier<Node>, List<InstanceIdentifier<LocalUcastMacs>>> staleCandidateMacsByNodeId
-            = new ConcurrentHashMap<>();
     private final HAOpClusteredListener haOpClusteredListener;
     private final JobCoordinator jobCoordinator;
 
+    @Inject
     public LocalUcastMacListener(final DataBroker dataBroker,
                                  final HAOpClusteredListener haOpClusteredListener,
                                  final ElanL2GatewayUtils elanL2GatewayUtils,
@@ -80,6 +81,7 @@ public class LocalUcastMacListener extends ChildListener<Node, LocalUcastMacs, S
     }
 
     @Override
+    @PostConstruct
     public void init() throws Exception {
         ResourceBatchingManager.getInstance().registerDefaultBatchHandlers(this.dataBroker);
         super.init();
@@ -146,11 +148,6 @@ public class LocalUcastMacListener extends ChildListener<Node, LocalUcastMacs, S
     }
 
     public void added(final InstanceIdentifier<LocalUcastMacs> identifier, final LocalUcastMacs macAdded) {
-        InstanceIdentifier<Node> nodeIid = identifier.firstIdentifierOf(Node.class);
-        if (staleCandidateMacsByNodeId.get(nodeIid) != null) {
-            LOG.trace("Clearing from candidate stale mac {}", identifier);
-            staleCandidateMacsByNodeId.get(nodeIid).remove(identifier);
-        }
         ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY,
                 identifier, macAdded);
 
index 32f75fbb426d4b602203e230649777d121a9129f..567496e368f46238f1f04c28a6478feb8e09eaa5 100644 (file)
@@ -7,38 +7,52 @@
  */
 package org.opendaylight.netvirt.elan.l2gw.utils;
 
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.isVxlan;
+
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentMap;
+import javax.annotation.Nonnull;
 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.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
+import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
+import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.genius.utils.batching.ResourceBatchingManager;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
 import org.opendaylight.genius.utils.hwvtep.HwvtepUtils;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
-import org.opendaylight.netvirt.elan.internal.ElanInstanceManager;
-import org.opendaylight.netvirt.elan.internal.ElanInterfaceManager;
 import org.opendaylight.netvirt.elan.l2gw.jobs.HwvtepDeviceMcastMacUpdateJob;
 import org.opendaylight.netvirt.elan.utils.ElanConstants;
 import org.opendaylight.netvirt.elan.utils.ElanItmUtils;
+import org.opendaylight.netvirt.elan.utils.ElanUtils;
 import org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp.rev160428.DesignatedSwitchesForExternalTunnels;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp.rev160428.designated.switches._for.external.tunnels.DesignatedSwitchForTunnel;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp.rev160428.designated.switches._for.external.tunnels.DesignatedSwitchForTunnelKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ExternalTeps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
@@ -68,23 +82,21 @@ public class ElanL2GatewayMulticastUtils {
     /** The broker. */
     private final DataBroker broker;
 
-    /** The elan instance manager. */
-    private final ElanInstanceManager elanInstanceManager;
-
-    /** The elan interface manager. */
-    private final ElanInterfaceManager elanInterfaceManager;
-
     private final ElanItmUtils elanItmUtils;
     private final JobCoordinator jobCoordinator;
+    private final ElanUtils elanUtils;
+    private final IMdsalApiManager mdsalManager;
+    private final IInterfaceManager interfaceManager;
 
     @Inject
-    public ElanL2GatewayMulticastUtils(DataBroker broker, ElanInstanceManager elanInstanceManager,
-            ElanInterfaceManager elanInterfaceManager, ElanItmUtils elanItmUtils, JobCoordinator jobCoordinator) {
+    public ElanL2GatewayMulticastUtils(DataBroker broker, ElanItmUtils elanItmUtils, JobCoordinator jobCoordinator,
+            ElanUtils elanUtils, IMdsalApiManager mdsalManager, IInterfaceManager interfaceManager) {
         this.broker = broker;
-        this.elanInstanceManager = elanInstanceManager;
-        this.elanInterfaceManager = elanInterfaceManager;
         this.elanItmUtils = elanItmUtils;
         this.jobCoordinator = jobCoordinator;
+        this.elanUtils = elanUtils;
+        this.mdsalManager = mdsalManager;
+        this.interfaceManager = interfaceManager;
     }
 
     /**
@@ -96,8 +108,9 @@ public class ElanL2GatewayMulticastUtils {
      *            the device
      * @return the listenable future
      */
-    public ListenableFuture<Void> handleMcastForElanL2GwDeviceAdd(String elanName, L2GatewayDevice device) {
-        return updateMcastMacsForAllElanDevices(elanName, device, true/* updateThisDevice */);
+    public ListenableFuture<Void> handleMcastForElanL2GwDeviceAdd(String elanName, ElanInstance elanInstance,
+            L2GatewayDevice device) {
+        return updateMcastMacsForAllElanDevices(elanName, elanInstance, device, true/* updateThisDevice */);
     }
 
     /**
@@ -147,7 +160,7 @@ public class ElanL2GatewayMulticastUtils {
                                                            L2GatewayDevice device) {
         ConcurrentMap<String, L2GatewayDevice> elanL2gwDevices = ElanL2GwCacheUtils
                 .getInvolvedL2GwDevices(elanName);
-        List<DpnInterfaces> dpns = elanInstanceManager.getElanDPNByName(elanName);
+        List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanName);
         List<IpAddress> dpnsTepIps = getAllTepIpsOfDpns(device, dpns);
         List<IpAddress> l2GwDevicesTepIps = getAllTepIpsOfL2GwDevices(elanL2gwDevices);
         preapareRemoteMcastMacEntry(transaction, elanName, device, dpnsTepIps, l2GwDevicesTepIps);
@@ -160,22 +173,23 @@ public class ElanL2GatewayMulticastUtils {
      *
      * @param elanName
      *            the elan name
+     * @param elanInstance
+     *            the ElanInstance
      * @param device
      *            the device
      * @param updateThisDevice
      *            the update this device
      * @return the listenable future
      */
-    public ListenableFuture<Void> updateMcastMacsForAllElanDevices(String elanName, L2GatewayDevice device,
-                                                                          boolean updateThisDevice) {
+    private ListenableFuture<Void> updateMcastMacsForAllElanDevices(String elanName, ElanInstance elanInstance,
+            L2GatewayDevice device, boolean updateThisDevice) {
 
         SettableFuture<Void> ft = SettableFuture.create();
         ft.set(null);
 
-        ElanInstance elanInstance = elanInstanceManager.getElanInstanceByName(elanName);
-        elanInterfaceManager.updateRemoteBroadcastGroupForAllElanDpns(elanInstance);
+        updateRemoteBroadcastGroupForAllElanDpns(elanInstance);
 
-        List<DpnInterfaces> dpns = elanInstanceManager.getElanDPNByName(elanName);
+        List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanName);
 
         ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils
                 .getInvolvedL2GwDevices(elanName);
@@ -203,6 +217,189 @@ public class ElanL2GatewayMulticastUtils {
 
     }
 
+    public void updateRemoteBroadcastGroupForAllElanDpns(ElanInstance elanInfo) {
+        List<DpnInterfaces> dpns = elanUtils.getInvolvedDpnsInElan(elanInfo.getElanInstanceName());
+        for (DpnInterfaces dpn : dpns) {
+            setupElanBroadcastGroups(elanInfo, dpn.getDpId());
+        }
+    }
+
+    public void setupElanBroadcastGroups(ElanInstance elanInfo, BigInteger dpnId) {
+        setupElanBroadcastGroups(elanInfo, null, dpnId);
+    }
+
+    public void setupElanBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
+        setupStandardElanBroadcastGroups(elanInfo, dpnInterfaces, dpnId);
+        setupLeavesEtreeBroadcastGroups(elanInfo, dpnInterfaces, dpnId);
+    }
+
+    public void setupStandardElanBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
+        List<Bucket> listBucket = new ArrayList<>();
+        int bucketId = 0;
+        int actionKey = 0;
+        Long elanTag = elanInfo.getElanTag();
+        List<Action> listAction = new ArrayList<>();
+        listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
+        listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT,
+                MDSALUtil.WATCH_GROUP));
+        bucketId++;
+        List<Bucket> listBucketInfoRemote = getRemoteBCGroupBuckets(elanInfo, dpnInterfaces, dpnId, bucketId, elanTag);
+        listBucket.addAll(listBucketInfoRemote);
+        long groupId = ElanUtils.getElanRemoteBCGId(elanTag);
+        Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll,
+                MDSALUtil.buildBucketLists(listBucket));
+        LOG.trace("Installing the remote BroadCast Group:{}", group);
+        mdsalManager.syncInstallGroup(dpnId, group);
+    }
+
+    public void setupLeavesEtreeBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
+        EtreeInstance etreeInstance = elanInfo.getAugmentation(EtreeInstance.class);
+        if (etreeInstance != null) {
+            long etreeLeafTag = etreeInstance.getEtreeLeafTagVal().getValue();
+            List<Bucket> listBucket = new ArrayList<>();
+            int bucketId = 0;
+            int actionKey = 0;
+            List<Action> listAction = new ArrayList<>();
+            listAction.add(new ActionGroup(ElanUtils.getEtreeLeafLocalBCGId(etreeLeafTag)).buildAction(++actionKey));
+            listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT,
+                    MDSALUtil.WATCH_GROUP));
+            bucketId++;
+            List<Bucket> listBucketInfoRemote = getRemoteBCGroupBuckets(elanInfo, dpnInterfaces, dpnId, bucketId,
+                    etreeLeafTag);
+            listBucket.addAll(listBucketInfoRemote);
+            long groupId = ElanUtils.getEtreeLeafRemoteBCGId(etreeLeafTag);
+            Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll,
+                    MDSALUtil.buildBucketLists(listBucket));
+            LOG.trace("Installing the remote BroadCast Group:{}", group);
+            mdsalManager.syncInstallGroup(dpnId, group);
+        }
+    }
+
+    private DpnInterfaces getDpnInterfaces(ElanDpnInterfacesList elanDpns, BigInteger dpnId) {
+        if (elanDpns != null) {
+            for (DpnInterfaces dpnInterface : elanDpns.getDpnInterfaces()) {
+                if (dpnInterface.getDpId().equals(dpnId)) {
+                    return dpnInterface;
+                }
+            }
+        }
+        return null;
+    }
+
+    private List<Bucket> getRemoteBCGroupExternalPortBuckets(ElanDpnInterfacesList elanDpns,
+            DpnInterfaces dpnInterfaces, BigInteger dpnId, int bucketId) {
+        DpnInterfaces currDpnInterfaces = dpnInterfaces != null ? dpnInterfaces : getDpnInterfaces(elanDpns, dpnId);
+        if (currDpnInterfaces == null || !elanUtils.isDpnPresent(currDpnInterfaces.getDpId())
+                || currDpnInterfaces.getInterfaces() == null || currDpnInterfaces.getInterfaces().isEmpty()) {
+            return Collections.emptyList();
+        }
+        List<Bucket> listBucketInfo = new ArrayList<>();
+        for (String interfaceName : currDpnInterfaces.getInterfaces()) {
+            if (interfaceManager.isExternalInterface(interfaceName)) {
+                List<Action> listActionInfo = elanItmUtils.getExternalPortItmEgressAction(interfaceName);
+                if (!listActionInfo.isEmpty()) {
+                    listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
+                            MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
+                    bucketId++;
+                }
+            }
+        }
+        return listBucketInfo;
+    }
+
+    @Nonnull
+    public List<Bucket> getRemoteBCGroupBuckets(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId,
+                                                int bucketId, long elanTag) {
+        List<Bucket> listBucketInfo = new ArrayList<>();
+        ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
+
+        if (isVxlan(elanInfo)) {
+            listBucketInfo.addAll(getRemoteBCGroupTunnelBuckets(elanDpns, dpnId, bucketId,
+                    elanUtils.isOpenstackVniSemanticsEnforced() ? elanInfo.getSegmentationId() : elanTag));
+        }
+        listBucketInfo.addAll(getRemoteBCGroupExternalPortBuckets(elanDpns, dpnInterfaces, dpnId,
+            getNextAvailableBucketId(listBucketInfo.size())));
+        listBucketInfo.addAll(getRemoteBCGroupBucketsOfElanL2GwDevices(elanInfo, dpnId,
+            getNextAvailableBucketId(listBucketInfo.size())));
+        listBucketInfo.addAll(getRemoteBCGroupBucketsOfElanExternalTeps(elanInfo, dpnId,
+                getNextAvailableBucketId(listBucketInfo.size())));
+        return listBucketInfo;
+    }
+
+    public List<Bucket> getRemoteBCGroupBucketsOfElanL2GwDevices(ElanInstance elanInfo, BigInteger dpnId,
+            int bucketId) {
+        List<Bucket> listBucketInfo = new ArrayList<>();
+        ConcurrentMap<String, L2GatewayDevice> map = ElanL2GwCacheUtils
+                .getInvolvedL2GwDevices(elanInfo.getElanInstanceName());
+        for (L2GatewayDevice device : map.values()) {
+            String interfaceName = elanItmUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId),
+                    device.getHwvtepNodeId());
+            if (interfaceName == null) {
+                continue;
+            }
+            List<Action> listActionInfo = elanItmUtils.buildTunnelItmEgressActions(interfaceName,
+                    ElanUtils.getVxlanSegmentationId(elanInfo));
+            listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
+                    MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
+            bucketId++;
+        }
+        return listBucketInfo;
+    }
+
+    public List<Bucket> getRemoteBCGroupBucketsOfElanExternalTeps(ElanInstance elanInfo, BigInteger dpnId,
+            int bucketId) {
+        List<Bucket> listBucketInfo = new ArrayList<>();
+        List<ExternalTeps> teps = elanInfo.getExternalTeps();
+        if (teps == null || teps.isEmpty()) {
+            return listBucketInfo;
+        }
+        for (ExternalTeps tep : teps) {
+            String interfaceName = elanItmUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId),
+                    tep.getTepIp().toString());
+            if (interfaceName == null) {
+                LOG.error("Could not get interface name to ext tunnel {} {}", dpnId, tep.getTepIp());
+                continue;
+            }
+            List<Action> listActionInfo = elanItmUtils.buildTunnelItmEgressActions(interfaceName,
+                    elanInfo.getSegmentationId());
+            listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
+                    MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
+            bucketId++;
+        }
+        return listBucketInfo;
+    }
+
+    private int getNextAvailableBucketId(int bucketSize) {
+        return bucketSize + 1;
+    }
+
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    private List<Bucket> getRemoteBCGroupTunnelBuckets(ElanDpnInterfacesList elanDpns, BigInteger dpnId, int bucketId,
+            long elanTagOrVni) {
+        List<Bucket> listBucketInfo = new ArrayList<>();
+        if (elanDpns != null) {
+            for (DpnInterfaces dpnInterface : elanDpns.getDpnInterfaces()) {
+                if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpnId)
+                        && dpnInterface.getInterfaces() != null && !dpnInterface.getInterfaces().isEmpty()) {
+                    try {
+                        List<Action> listActionInfo = elanItmUtils.getInternalTunnelItmEgressAction(dpnId,
+                                dpnInterface.getDpId(), elanTagOrVni);
+                        if (listActionInfo.isEmpty()) {
+                            continue;
+                        }
+                        listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
+                                MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
+                        bucketId++;
+                    } catch (Exception ex) {
+                        LOG.error("Logical Group Interface not found between source Dpn - {}, destination Dpn - {} ",
+                                dpnId, dpnInterface.getDpId(), ex);
+                    }
+                }
+            }
+        }
+        return listBucketInfo;
+    }
+
     /**
      * Update remote mcast mac.
      *
@@ -338,14 +535,16 @@ public class ElanL2GatewayMulticastUtils {
      *
      * @param elanName
      *            the elan instance name
+     * @param elanInstance
+     *            the ElanInstance
      * @param l2GatewayDevice
      *            the l2 gateway device
      * @return the listenable future
      */
     public List<ListenableFuture<Void>> handleMcastForElanL2GwDeviceDelete(String elanName,
-            L2GatewayDevice l2GatewayDevice) {
+            ElanInstance elanInstance, L2GatewayDevice l2GatewayDevice) {
         ListenableFuture<Void> updateMcastMacsFuture = updateMcastMacsForAllElanDevices(
-                elanName, l2GatewayDevice, false/* updateThisDevice */);
+                elanName, elanInstance, l2GatewayDevice, false/* updateThisDevice */);
         ListenableFuture<Void> deleteRemoteMcastMacFuture = deleteRemoteMcastMac(
                 new NodeId(l2GatewayDevice.getHwvtepNodeId()), elanName);
         return Arrays.asList(updateMcastMacsFuture, deleteRemoteMcastMacFuture);
index 140a3cae53d24ab0c8367a1957da62ea17b0b80e..99cc20daadc2da6eb165579bfec4e106d81fc1d8 100644 (file)
@@ -45,7 +45,6 @@ import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
 import org.opendaylight.genius.utils.hwvtep.HwvtepUtils;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.netvirt.elan.ElanException;
-import org.opendaylight.netvirt.elan.internal.ElanInstanceManager;
 import org.opendaylight.netvirt.elan.l2gw.jobs.DeleteL2GwDeviceMacsFromElanJob;
 import org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob;
 import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
@@ -113,6 +112,7 @@ public class ElanL2GatewayUtils {
     private final ElanClusterUtils elanClusterUtils;
     private final OdlInterfaceRpcService interfaceManagerRpcService;
     private final JobCoordinator jobCoordinator;
+    private final ElanUtils elanUtils;
 
     private final Timer logicalSwitchDeleteJobTimer = new Timer();
     private final ConcurrentMap<Pair<NodeId, String>, TimerTask> logicalSwitchDeletedTasks = new ConcurrentHashMap<>();
@@ -121,13 +121,14 @@ public class ElanL2GatewayUtils {
     @Inject
     public ElanL2GatewayUtils(DataBroker broker, ElanDmacUtils elanDmacUtils, ElanItmUtils elanItmUtils,
             ElanClusterUtils elanClusterUtils, OdlInterfaceRpcService interfaceManagerRpcService,
-            JobCoordinator jobCoordinator) {
+            JobCoordinator jobCoordinator, ElanUtils elanUtils) {
         this.broker = broker;
         this.elanDmacUtils = elanDmacUtils;
         this.elanItmUtils = elanItmUtils;
         this.elanClusterUtils = elanClusterUtils;
         this.interfaceManagerRpcService = interfaceManagerRpcService;
         this.jobCoordinator = jobCoordinator;
+        this.elanUtils = elanUtils;
     }
 
     @PreDestroy
@@ -1037,7 +1038,7 @@ public class ElanL2GatewayUtils {
     public List<DpnInterfaces> getElanDpns(String elanName) {
         Set<DpnInterfaces> dpnInterfaces = ElanUtils.getElanInvolvedDPNsFromCache(elanName);
         if (dpnInterfaces == null) {
-            return ElanInstanceManager.getElanDPNByName(broker, elanName);
+            return elanUtils.getElanDPNByName(elanName);
         }
         return new ArrayList<>(dpnInterfaces);
     }
index 098e04739fe8f6601cced3eb5715c9f113fb65a6..3802f40067261b576b9ecb89f81718673c85aa4f 100644 (file)
@@ -21,6 +21,9 @@ import java.util.List;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 import javax.annotation.Nonnull;
+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.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
@@ -34,7 +37,6 @@ import org.opendaylight.netvirt.elan.l2gw.listeners.ElanInstanceListener;
 import org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLocalUcastMacListener;
 import org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLogicalSwitchListener;
 import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
-import org.opendaylight.netvirt.elan.utils.ElanUtils;
 import org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.utils.L2GatewayCacheUtils;
@@ -56,6 +58,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class L2GatewayConnectionUtils implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(L2GatewayConnectionUtils.class);
 
@@ -67,18 +70,20 @@ public class L2GatewayConnectionUtils implements AutoCloseable {
     private final JobCoordinator jobCoordinator;
     private final List<AutoCloseable> closeables = new CopyOnWriteArrayList<>();
 
+    @Inject
     public L2GatewayConnectionUtils(DataBroker dataBroker, ElanInstanceManager elanInstanceManager,
-            ElanClusterUtils elanClusterUtils, ElanUtils elanUtils, ElanL2GatewayUtils elanL2GatewayUtils,
-            JobCoordinator jobCoordinator) {
+            ElanClusterUtils elanClusterUtils, ElanL2GatewayUtils elanL2GatewayUtils,
+            JobCoordinator jobCoordinator, ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils) {
         this.broker = dataBroker;
         this.elanInstanceManager = elanInstanceManager;
         this.elanL2GatewayUtils = elanL2GatewayUtils;
         this.elanClusterUtils = elanClusterUtils;
-        this.elanL2GatewayMulticastUtils = elanUtils.getElanL2GatewayMulticastUtils();
+        this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
         this.jobCoordinator = jobCoordinator;
     }
 
     @Override
+    @PreDestroy
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void close() {
         closeables.forEach(c -> {
@@ -251,8 +256,8 @@ public class L2GatewayConnectionUtils implements AutoCloseable {
             }
 
             DisAssociateHwvtepFromElanJob disAssociateHwvtepToElanJob =
-                    new DisAssociateHwvtepFromElanJob(broker, elanL2GatewayUtils, elanL2GatewayMulticastUtils,
-                            elanL2GwDevice, elanName,
+                    new DisAssociateHwvtepFromElanJob(elanL2GatewayUtils, elanL2GatewayMulticastUtils,
+                            elanL2GwDevice, elanName, () -> elanInstanceManager.getElanInstanceByName(elanName),
                             l2Device, defaultVlan, hwvtepNodeId, isLastL2GwConnDeleted);
             elanClusterUtils.runOnlyInOwnerNode(disAssociateHwvtepToElanJob.getJobKey(), "remove l2gw connection job",
                     disAssociateHwvtepToElanJob);
@@ -293,8 +298,8 @@ public class L2GatewayConnectionUtils implements AutoCloseable {
                         hwvtepNodeId, elanName);
                 if (logicalSwitch == null) {
                     HwvtepLogicalSwitchListener hwVTEPLogicalSwitchListener = new HwvtepLogicalSwitchListener(
-                            elanL2GatewayUtils, elanClusterUtils, elanL2GatewayMulticastUtils, this,
-                            l2GatewayDevice, elanName, l2Device, defaultVlan, l2GwConnId);
+                            elanInstanceManager, elanL2GatewayUtils, elanClusterUtils, elanL2GatewayMulticastUtils,
+                            this, l2GatewayDevice, elanName, l2Device, defaultVlan, l2GwConnId);
                     hwVTEPLogicalSwitchListener.registerListener(LogicalDatastoreType.OPERATIONAL, broker);
                     closeables.add(hwVTEPLogicalSwitchListener);
                     createLogicalSwitch = true;
@@ -303,8 +308,8 @@ public class L2GatewayConnectionUtils implements AutoCloseable {
                     createLogicalSwitch = false;
                 }
                 AssociateHwvtepToElanJob associateHwvtepToElanJob = new AssociateHwvtepToElanJob(broker,
-                        elanL2GatewayUtils, elanL2GatewayMulticastUtils, l2GatewayDevice, elanInstance,
-                        l2Device, defaultVlan, createLogicalSwitch);
+                        elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanInstanceManager, l2GatewayDevice,
+                        elanInstance, l2Device, defaultVlan, createLogicalSwitch);
 
                 elanClusterUtils.runOnlyInOwnerNode(associateHwvtepToElanJob.getJobKey(),
                         "create logical switch in hwvtep topo", associateHwvtepToElanJob);
index 6fb1c3bd6449b91b12a7b6a4b061c362062320c8..be993af6da642f9cc5890a7c074929f37840c917 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.netvirt.elan.l2gw.utils;
 
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -23,25 +22,6 @@ import org.slf4j.LoggerFactory;
 public class L2GatewayUtils {
     private static final Logger LOG = LoggerFactory.getLogger(L2GatewayUtils.class);
 
-    private final DataBroker dataBroker;
-
-    private final ItmRpcService itmRpcService;
-
-    private final L2GatewayConnectionUtils l2GatewayConnectionUtils;
-
-    public L2GatewayUtils(DataBroker dataBroker, ItmRpcService itmRpcService,
-                          L2GatewayConnectionUtils l2GatewayConnectionUtils) {
-        this.dataBroker = dataBroker;
-        this.itmRpcService = itmRpcService;
-        this.l2GatewayConnectionUtils = l2GatewayConnectionUtils;
-    }
-
-    public void init() {
-    }
-
-    public void close() {
-    }
-
     public static void deleteItmTunnels(ItmRpcService itmRpcService, String hwvtepId, String psName,
                                         IpAddress tunnelIp) {
         DeleteL2GwDeviceInputBuilder builder = new DeleteL2GwDeviceInputBuilder();
index 14fe0267600960c14053a6e54d2226de911ea46e..64efcda2d14d451f1b817b24c7143f22ac481f96 100644 (file)
@@ -11,6 +11,8 @@ package org.opendaylight.netvirt.elan.l2gw.utils;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.infrautils.inject.AbstractLifecycle;
 import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
@@ -27,6 +29,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Created by eaksahu on 3/15/2017.
  */
+@Singleton
 public class L2gwServiceProvider extends AbstractLifecycle implements IL2gwService {
 
     private static final Logger LOG = LoggerFactory.getLogger(L2gwServiceProvider.class);
@@ -36,6 +39,7 @@ public class L2gwServiceProvider extends AbstractLifecycle implements IL2gwServi
     private final L2GatewayConnectionUtils l2GatewayConnectionUtils;
     private final ElanClusterUtils elanClusterUtils;
 
+    @Inject
     public L2gwServiceProvider(final DataBroker dataBroker, final ElanClusterUtils elanClusterUtils,
                                ItmRpcService itmRpcService, L2GatewayConnectionUtils l2GatewayConnectionUtils) {
         this.dataBroker = dataBroker;
index 465e1fdd00c7846b279046920e48436c4b500001..6c6a081a9503b08465a608afa725eeb70ce75408 100755 (executable)
@@ -9,6 +9,8 @@ package org.opendaylight.netvirt.elan.statisitcs;
 
 import com.google.common.util.concurrent.Futures;
 import java.util.concurrent.Future;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
@@ -26,12 +28,14 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanStatisticsImpl implements ElanStatisticsService {
     private static final Logger LOG = LoggerFactory.getLogger(ElanStatisticsImpl.class);
 
     private final DataBroker dataBroker;
     private final IInterfaceManager interfaceManager;
 
+    @Inject
     public ElanStatisticsImpl(DataBroker dataBroker, IInterfaceManager interfaceManager) {
         this.dataBroker = dataBroker;
         this.interfaceManager = interfaceManager;
index 9ff946eb84e7be3e050181bb8636e7f74491cdb1..f1383e07e88b3aab6b3dcfaa58cf4ec81af5e9f3 100644 (file)
@@ -8,14 +8,16 @@
 package org.opendaylight.netvirt.elan.statusanddiag;
 
 import java.lang.management.ManagementFactory;
-
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Singleton;
 import javax.management.JMException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class ElanStatusMonitorJMX implements ElanStatusMonitor, ElanStatusMonitorMBean {
 
     private String serviceStatus;
@@ -23,6 +25,7 @@ public class ElanStatusMonitorJMX implements ElanStatusMonitor, ElanStatusMonito
     private static final Logger LOG = LoggerFactory.getLogger(ElanStatusMonitorJMX.class);
     private static final MBeanServer MBS = ManagementFactory.getPlatformMBeanServer();
 
+    @PostConstruct
     public void init() throws Exception {
         registerMbean();
     }
@@ -33,6 +36,7 @@ public class ElanStatusMonitorJMX implements ElanStatusMonitor, ElanStatusMonito
         LOG.info("ElanStatusMonitor MXBean successfully registered {}", JMX_ELAN_OBJ_NAME);
     }
 
+    @PreDestroy
     public void close() {
         try {
             ObjectName objName = new ObjectName(JMX_ELAN_OBJ_NAME);
index 6f738fedd380b864eb76a73c8f07c7a2691c04b5..c51f782f3835c001874871d02b631d9a94c0402d 100644 (file)
@@ -8,6 +8,10 @@
 package org.opendaylight.netvirt.elan.utils;
 
 import java.util.Collection;
+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.DataObjectModification;
@@ -21,6 +25,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class CacheElanInstanceListener implements ClusteredDataTreeChangeListener<ElanInstance> {
 
     private static final Logger LOG = LoggerFactory.getLogger(CacheElanInstanceListener.class);
@@ -29,10 +34,12 @@ public class CacheElanInstanceListener implements ClusteredDataTreeChangeListene
 
     private ListenerRegistration<CacheElanInstanceListener> registration;
 
+    @Inject
     public CacheElanInstanceListener(DataBroker dataBroker) {
         this.broker = dataBroker;
     }
 
+    @PostConstruct
     public void init() {
         registerListener();
     }
@@ -48,6 +55,7 @@ public class CacheElanInstanceListener implements ClusteredDataTreeChangeListene
         return InstanceIdentifier.create(ElanInstances.class).child(ElanInstance.class);
     }
 
+    @PreDestroy
     public void close() throws Exception {
         if (registration != null) {
             registration.close();
index 4208c6575a586632dbfbd12a18d7c4f83ee3602d..5e1733768f8d134cc47c1b91ae32b46199aa13b4 100644 (file)
@@ -8,6 +8,10 @@
 package org.opendaylight.netvirt.elan.utils;
 
 import java.util.Collection;
+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.DataObjectModification;
@@ -21,16 +25,19 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class CacheElanInterfaceListener implements ClusteredDataTreeChangeListener<ElanInterface> {
 
     private ListenerRegistration<CacheElanInterfaceListener> registration;
     private static final Logger LOG = LoggerFactory.getLogger(CacheElanInterfaceListener.class);
     private final DataBroker broker;
 
+    @Inject
     public CacheElanInterfaceListener(DataBroker dataBroker) {
         this.broker = dataBroker;
     }
 
+    @PostConstruct
     public void init() {
         registerListener();
     }
@@ -46,6 +53,7 @@ public class CacheElanInterfaceListener implements ClusteredDataTreeChangeListen
         return InstanceIdentifier.create(ElanInterfaces.class).child(ElanInterface.class);
     }
 
+    @PreDestroy
     public void close() throws Exception {
         if (registration != null) {
             registration.close();
index a863610ee0d72d1bfa9cc0bb6f8ec643bd9c894d..aeed676c5f712efb387fc496ff9b9554cb09b4fe 100644 (file)
@@ -30,14 +30,11 @@ public class ElanForwardingEntriesHandler {
     private static final Logger LOG = LoggerFactory.getLogger(ElanForwardingEntriesHandler.class);
 
     private final DataBroker broker;
-    private ElanUtils elanUtils;
+    private final ElanUtils elanUtils;
 
     @Inject
-    public ElanForwardingEntriesHandler(DataBroker dataBroker) {
+    public ElanForwardingEntriesHandler(DataBroker dataBroker, ElanUtils elanUtils) {
         this.broker = dataBroker;
-    }
-
-    public void setElanUtils(ElanUtils elanUtils) {
         this.elanUtils = elanUtils;
     }
 
index 75293a846e3f3a0b4e141e4084edc270cca00f82..40e107ce69396ed597dbc4f1157ed087596d5736 100755 (executable)
@@ -66,8 +66,6 @@ import org.opendaylight.genius.mdsalutil.packet.IPv4;
 import org.opendaylight.infrautils.utils.concurrent.JdkFutures;
 import org.opendaylight.netvirt.elan.ElanException;
 import org.opendaylight.netvirt.elan.arp.responder.ArpResponderUtil;
-import org.opendaylight.netvirt.elan.internal.ElanInstanceManager;
-import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
 import org.opendaylight.netvirt.elanmanager.api.ElanHelper;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
@@ -186,10 +184,8 @@ public class ElanUtils {
 
     private final DataBroker broker;
     private final IMdsalApiManager mdsalManager;
-    private final ElanInstanceManager elanInstanceManager;
     private final OdlInterfaceRpcService interfaceManagerRpcService;
     private final ItmRpcService itmRpcService;
-    private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
     private final IInterfaceManager interfaceManager;
     private final ElanConfig elanConfig;
     private final ElanItmUtils elanItmUtils;
@@ -208,29 +204,19 @@ public class ElanUtils {
     };
 
     @Inject
-    public ElanUtils(DataBroker dataBroker, IMdsalApiManager mdsalManager, ElanInstanceManager elanInstanceManager,
-                     OdlInterfaceRpcService interfaceManagerRpcService, ItmRpcService itmRpcService,
-                     ElanConfig elanConfig,
-                     IInterfaceManager interfaceManager,
-                     ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils, ElanEtreeUtils elanEtreeUtils,
-                     ElanItmUtils elanItmUtils) {
+    public ElanUtils(DataBroker dataBroker, IMdsalApiManager mdsalManager,
+            OdlInterfaceRpcService interfaceManagerRpcService, ItmRpcService itmRpcService, ElanConfig elanConfig,
+            IInterfaceManager interfaceManager, ElanEtreeUtils elanEtreeUtils, ElanItmUtils elanItmUtils) {
         this.broker = dataBroker;
         this.mdsalManager = mdsalManager;
-        this.elanInstanceManager = elanInstanceManager;
         this.interfaceManagerRpcService = interfaceManagerRpcService;
         this.itmRpcService = itmRpcService;
         this.interfaceManager = interfaceManager;
         this.elanConfig = elanConfig;
-
-        this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
         this.elanEtreeUtils = elanEtreeUtils;
         this.elanItmUtils = elanItmUtils;
     }
 
-    public ElanL2GatewayMulticastUtils getElanL2GatewayMulticastUtils() {
-        return elanL2GatewayMulticastUtils;
-    }
-
     public final Boolean isOpenstackVniSemanticsEnforced() {
         return elanConfig.isOpenstackVniSemanticsEnforced() != null
                 ? elanConfig.isOpenstackVniSemanticsEnforced() : false;
@@ -895,7 +881,14 @@ public class ElanUtils {
 
     @Nonnull
     public List<DpnInterfaces> getInvolvedDpnsInElan(String elanName) {
-        return elanInstanceManager.getElanDPNByName(elanName);
+        return getElanDPNByName(elanName);
+    }
+
+    @Nonnull
+    public List<DpnInterfaces> getElanDPNByName(String elanInstanceName) {
+        InstanceIdentifier<ElanDpnInterfacesList> elanIdentifier = getElanDpnOperationDataPath(elanInstanceName);
+        return MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, elanIdentifier).toJavaUtil().map(
+                ElanDpnInterfacesList::getDpnInterfaces).orElse(Collections.emptyList());
     }
 
     private void setupLocalDmacFlow(long elanTag, BigInteger dpId, String ifName, String macAddress,
index ad9b531fffeaf94f798efe659feaed2fc64a394b..95eb0a3617bf752bce64360cd36b2f95065c5d0b 100644 (file)
@@ -21,6 +21,8 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
+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;
@@ -62,6 +64,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class TransportZoneNotificationUtil {
     private static final Logger LOG = LoggerFactory.getLogger(TransportZoneNotificationUtil.class);
     private static final String TUNNEL_PORT = "tunnel_port";
@@ -77,6 +80,7 @@ public class TransportZoneNotificationUtil {
     private final ElanConfig elanConfig;
     private final ElanBridgeManager elanBridgeManager;
 
+    @Inject
     public TransportZoneNotificationUtil(final DataBroker dbx, final IInterfaceManager interfaceManager,
             final IElanService elanService, final ElanConfig elanConfig, final ElanBridgeManager elanBridgeManager) {
         this.dataBroker = dbx;
index 35697454fd08bee10568c30d76492792e795f7e6..43d931b654a532566063beb83cfeab74873aeecd 100644 (file)
     interface="org.opendaylight.controller.md.sal.binding.api.NotificationService" />
   <reference id="entityOwnershipService"
     interface="org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService" />
-  <reference id="mdsalUtils"
+  <reference id="iMdsalApiManager"
     interface="org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager" />
-  <reference id="interfaceManager"
+  <reference id="iInterfaceManager"
     interface="org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager" />
-  <reference id="vpnManager"
+  <reference id="iVpnManager"
              interface="org.opendaylight.netvirt.vpnmanager.api.IVpnManager" availability="optional"/>
-  <reference id="bgpManager"
+  <reference id="iBgpManager"
              interface="org.opendaylight.netvirt.bgpmanager.api.IBgpManager" availability="optional"/>
-  <reference id="neutronvpnManagerImpl"
+  <reference id="iNeutronVpnManager"
              interface="org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager" availability="optional"/>
   <reference id="diagStatusService"
              interface="org.opendaylight.infrautils.diagstatus.DiagStatusService" />
     <argument ref="entityOwnershipService" />
   </bean>
 
-  <bean id="elanBridgeManager"
-    class="org.opendaylight.netvirt.elan.internal.ElanBridgeManager">
+  <bean id="mdsalUtils" class="org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils">
     <argument ref="dataBroker" />
-    <argument ref="elanConfig" />
-    <argument ref="interfaceManager" />
   </bean>
 
-  <bean id="elanForwardingEntriesHandler"
-    class="org.opendaylight.netvirt.elan.utils.ElanForwardingEntriesHandler">
-    <argument ref="dataBroker" />
-  </bean>
-
-  <bean id="elanInterfaceManager"
-    class="org.opendaylight.netvirt.elan.internal.ElanInterfaceManager"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="idManagerService" />
+  <bean id="southboundUtils" class="org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils">
     <argument ref="mdsalUtils" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanForwardingEntriesHandler" />
-    <argument ref="neutronvpnManagerImpl"/>
-    <argument ref="elanItmUtils" />
-    <argument ref="elanEtreeUtils" />
-    <argument ref="elanL2GatewayUtils" />
-    <argument ref="jobCoordinator" />
   </bean>
 
-  <bean id="elanInstanceManager"
-    class="org.opendaylight.netvirt.elan.internal.ElanInstanceManager"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="idManagerService" />
-    <argument ref="elanInterfaceManager" />
-    <argument ref="interfaceManager" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanNodeListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanNodeListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="mdsalUtils" />
-    <argument ref="elanConfig" />
-    <argument ref="idManagerService" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanPacketInHandler"
-    class="org.opendaylight.netvirt.elan.internal.ElanPacketInHandler">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanUtils" />
-    <argument ref="evpnUtils" />
-    <argument ref="elanL2GatewayUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
   <odl:notification-listener ref="elanPacketInHandler" />
 
-  <bean id="elanSmacFlowEventListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanSmacFlowEventListener">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
   <odl:notification-listener ref="elanSmacFlowEventListener" />
 
-  <bean id="elanExtnTepListener"
-        class="org.opendaylight.netvirt.elan.internal.ElanExtnTepListener"
-        init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanInterfaceManager" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanItmUtils" class="org.opendaylight.netvirt.elan.utils.ElanItmUtils">
-    <argument ref="dataBroker" />
-    <argument ref="itmRpcService" />
-    <argument ref="odlInterfaceRpcService" />
-  </bean>
-
-  <bean id="elanDmacUtils" class="org.opendaylight.netvirt.elan.utils.ElanDmacUtils">
-    <argument ref="dataBroker" />
-    <argument ref="elanItmUtils" />
-    <argument ref="elanEtreeUtils" />
-  </bean>
-
-  <bean id="elanEtreeUtils" class="org.opendaylight.netvirt.elan.utils.ElanEtreeUtils">
-    <argument ref="dataBroker" />
-  </bean>
-
-  <bean id="elanL2GatewayMulticastUtils" class="org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils">
-    <argument ref="dataBroker" />
-    <argument ref="elanInstanceManager" />
-    <argument ref="elanInterfaceManager" />
-    <argument ref="elanItmUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanUtils" class="org.opendaylight.netvirt.elan.utils.ElanUtils">
-    <argument ref="dataBroker" />
-    <argument ref="mdsalUtils" />
-    <argument ref="elanInstanceManager" />
-    <argument ref="odlInterfaceRpcService" />
-    <argument ref="itmRpcService" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanConfig" />
-    <argument ref="elanL2GatewayMulticastUtils" />
-    <argument ref="elanEtreeUtils" />
-    <argument ref="elanItmUtils" />
-  </bean>
-
-  <bean id="elanStatisticsImpl"
-    class="org.opendaylight.netvirt.elan.statisitcs.ElanStatisticsImpl">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-  </bean>
   <odl:rpc-implementation ref="elanStatisticsImpl" />
 
-  <bean id="elanInterfaceStateChangeListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanInterfaceStateChangeListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanInterfaceManager" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanInterfaceConfigListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanInterfaceConfigListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanInterfaceManager" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanTunnelInterfaceStateListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanTunnelInterfaceStateListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanInterfaceManager" />
-    <argument ref="elanUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanInterfaceStateClusterListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanInterfaceStateClusteredListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanInterfaceManager" />
-    <argument ref="elanUtils" />
-    <argument ref="elanClusterUtils" />
-  </bean>
-
-  <bean id="elanDpnInterfaceClusteredListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanDpnInterfaceClusteredListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="entityOwnershipUtils" />
-    <argument ref="elanUtils" />
-    <argument ref="elanL2GatewayUtils" />
-    <argument ref="elanClusterUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanVpnPortIpToPortListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanLearntVpnVipToPortListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanService"
-    class="org.opendaylight.netvirt.elan.internal.ElanServiceProvider"
-    init-method="init">
-    <argument ref="idManagerService" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanInstanceManager" />
-    <argument ref="elanBridgeManager" />
-    <argument ref="dataBroker" />
-    <argument ref="elanInterfaceManager" />
-    <argument ref="elanStatusMonitor" />
-    <argument ref="elanUtils" />
-    <argument ref="entityOwnershipService" />
-  </bean>
-  <service ref="elanService" odl:type="default"
+  <service ref="elanServiceProvider" odl:type="default"
     interface="org.opendaylight.netvirt.elanmanager.api.IElanService" />
+
   <service ref="elanBridgeManager" odl:type="default"
     interface="org.opendaylight.netvirt.elanmanager.api.IElanBridgeManager" />
 
-  <bean id="cacheElanInterfaceListener"
-    class="org.opendaylight.netvirt.elan.utils.CacheElanInterfaceListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-  </bean>
-
-  <bean id="cacheElanInstanceListener"
-    class="org.opendaylight.netvirt.elan.utils.CacheElanInstanceListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-  </bean>
-
   <!--<bean id="hwvtepLocalUcastMacListener"
     class="org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLocalUcastMacListener"
     init-method="init" destroy-method="close">
     <argument ref="elanL2GatewayUtils" />
   </bean>-->
 
-  <bean id="elanStatusMonitor"
-    class="org.opendaylight.netvirt.elan.statusanddiag.ElanStatusMonitorJMX"
-    init-method="init" destroy-method="close" />
-
-  <bean id="l2GatewayConnectionListener"
-    class="org.opendaylight.netvirt.elan.l2gw.listeners.L2GatewayConnectionListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="l2GatewayConnectionUtils" />
-  </bean>
-
-  <bean id="l2GatewayConnectionUtils" class="org.opendaylight.netvirt.elan.l2gw.utils.L2GatewayConnectionUtils"
-        destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanInstanceManager" />
-    <argument ref="elanClusterUtils" />
-    <argument ref="elanUtils" />
-    <argument ref="elanL2GatewayUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanL2GatewayUtils" class="org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils"
-        destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanDmacUtils" />
-    <argument ref="elanItmUtils" />
-    <argument ref="elanClusterUtils" />
-    <argument ref="odlInterfaceRpcService" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="hwvtepPhysicalSwitchListener"
-    class="org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepPhysicalSwitchListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="itmRpcService" />
-    <argument ref="elanClusterUtils" />
-    <argument ref="l2gwService" />
-    <argument ref="haOpClusteredListener" />
-  </bean>
-
-  <bean id="hwvtepTerminationPointListener"
-    class="org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepTerminationPointListener"
-    destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanL2GatewayUtils" />
-    <argument ref="elanClusterUtils" />
-  </bean>
-
-  <bean id="haEventHandler"
-    class="org.opendaylight.netvirt.elan.l2gw.ha.handlers.HAEventHandler">
-    <argument ref="dataBroker" />
-  </bean>
-
-  <bean id="hAListeners"
-    class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAListeners">
-    <argument ref="dataBroker" />
-  </bean>
-
-  <bean id="haConfigNodeListener"
-    class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAConfigNodeListener">
-    <argument ref="dataBroker" />
-    <argument ref="haEventHandler" />
-  </bean>
-
-  <bean id="haOpClusteredListener"
-    class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpClusteredListener">
-    <argument ref="dataBroker" />
-  </bean>
-
-  <bean id="haOpNodeListener"
-    class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpNodeListener">
-    <argument ref="dataBroker" />
-    <argument ref="haEventHandler" />
-  </bean>
-
-  <bean id="ElanOvsdbNodeListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanOvsdbNodeListener"
-    init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanConfig" />
-    <argument ref="elanBridgeManager" />
-    <argument ref="elanService" />
-    <argument ref = "transportZoneNotificationUtil"/>
-  </bean>
-
-  <bean id="elanGroupListener"
-    class="org.opendaylight.netvirt.elan.l2gw.listeners.ElanGroupListener">
-    <argument ref="elanInterfaceManager" />
-    <argument ref="dataBroker" />
-    <argument ref="elanClusterUtils" />
-    <argument ref="elanInstanceManager" />
-  </bean>
-
-  <bean id="transportZoneNotificationUtil"
-    class="org.opendaylight.netvirt.elan.utils.TransportZoneNotificationUtil">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanService" />
-    <argument ref="elanConfig" />
-    <argument ref="elanBridgeManager" />
-  </bean>
-
-  <bean id="ElanDpnToTransportZoneListener"
-    class="org.opendaylight.netvirt.elan.internal.ElanDpnToTransportZoneListener"
-    init-method="start" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanConfig" />
-    <argument ref="transportZoneNotificationUtil" />
-  </bean>
-
-  <bean id="VpnDpnToTransportZoneListener"
-    class="org.opendaylight.netvirt.elan.internal.VpnDpnToTransportZoneListener"
-    init-method="start" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanConfig" />
-    <argument ref="transportZoneNotificationUtil" />
-  </bean>
-  <bean id="l2gwService"
-        class="org.opendaylight.netvirt.elan.l2gw.utils.L2gwServiceProvider"
-        init-method="init">
-    <argument ref="dataBroker" />
-    <argument ref="elanClusterUtils" />
-    <argument ref="itmRpcService" />
-    <argument ref="l2GatewayConnectionUtils" />
-  </bean>
-  <service ref="l2gwService" odl:type="default"
+  <service ref="l2gwServiceProvider" odl:type="default"
            interface="org.opendaylight.netvirt.elanmanager.api.IL2gwService" />
 
-  <bean id="elanInstanceListener"
-        class="org.opendaylight.netvirt.elan.l2gw.listeners.ElanInstanceListener"
-        init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="elanClusterUtils" />
-  </bean>
-
-  <bean id="evpnUtils" class="org.opendaylight.netvirt.elan.evpn.utils.EvpnUtils"
-        init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanUtils" />
-    <argument ref="itmRpcService" />
-    <argument ref="vpnManager" />
-    <argument ref="bgpManager" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanClusterUtils" class="org.opendaylight.netvirt.elan.utils.ElanClusterUtils">
-    <argument ref="entityOwnershipUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="evpnMacVrfUtils"
-        class="org.opendaylight.netvirt.elan.evpn.utils.EvpnMacVrfUtils">
-    <argument ref="dataBroker" />
-    <argument ref="elanInstanceManager" />
-    <argument ref="idManagerService" />
-    <argument ref="elanEvpnFlowUtils" />
-    <argument ref="mdsalUtils" />
-    <argument ref="evpnUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="elanEvpnFlowUtils"
-        class="org.opendaylight.netvirt.elan.evpn.utils.ElanEvpnFlowUtils">
-    <argument ref="mdsalUtils" />
-    <argument ref="elanItmUtils" />
-    <argument ref="elanEtreeUtils" />
-  </bean>
-
-  <bean id="macVrfEntryListener" class="org.opendaylight.netvirt.elan.evpn.listeners.MacVrfEntryListener"
-        init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="evpnMacVrfUtils" />
-  </bean>
-
-  <bean id="elanMacEntryListener" class="org.opendaylight.netvirt.elan.evpn.listeners.ElanMacEntryListener"
-        init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="evpnUtils" />
-  </bean>
-
-  <bean id="evpnElanInstanceListener" class="org.opendaylight.netvirt.elan.evpn.listeners.EvpnElanInstanceListener"
-        init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="evpnUtils" />
-    <argument ref="evpnMacVrfUtils" />
-    <argument ref="mdsalUtils" />
-  </bean>
-
-
-  <bean id="elanDpnInterfacesListener" class="org.opendaylight.netvirt.elan.internal.ElanDpnInterfacesListener"
-        init-method="start" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="interfaceManager" />
-    <argument ref="elanService" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
-  <bean id="l2gatewayUtils"
-        class="org.opendaylight.netvirt.elan.l2gw.utils.L2GatewayUtils"
-        init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="itmRpcService" />
-    <argument ref="l2GatewayConnectionUtils" />
-  </bean>
-
-  <bean id="localUcastMacListener" class="org.opendaylight.netvirt.elan.l2gw.listeners.LocalUcastMacListener"
-        init-method="init" destroy-method="close">
-    <argument ref="dataBroker" />
-    <argument ref="haOpClusteredListener" />
-    <argument ref="elanL2GatewayUtils" />
-    <argument ref="jobCoordinator" />
-  </bean>
-
 </blueprint>
index c9025bb644f2daf8de6806d2d3a8632b01215d1e..5f98f0afd5f2e932498ebf7ce4c210ca62b17ac1 100644 (file)
@@ -37,6 +37,8 @@ import org.opendaylight.netvirt.elanmanager.tests.utils.VpnManagerTestImpl;
 import org.opendaylight.netvirt.neutronvpn.NeutronvpnManagerImpl;
 import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
 import org.opendaylight.netvirt.vpnmanager.api.IVpnManager;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
@@ -111,5 +113,9 @@ public class ElanServiceTestModule extends AbstractGuiceJsr250Module {
         bind(IBgpManager.class).toInstance(ibgpManager);
         bind(DataImportBootReady.class).toInstance(new DataImportBootReady() {});
         bind(IElanService.class).to(ElanServiceProvider.class);
+
+        MdsalUtils mdsalUtils = new MdsalUtils(dataBroker);
+        bind(MdsalUtils.class).toInstance(mdsalUtils);
+        bind(SouthboundUtils.class).toInstance(new SouthboundUtils(mdsalUtils));
     }
 }