Modification in NeutronPortChangeListener.java 02/41702/3
authorSuraj Ranjan <suraj.ranjan@ericsson.com>
Tue, 12 Jul 2016 10:31:47 +0000 (16:01 +0530)
committerSuraj Ranjan <suraj.ranjan@ericsson.com>
Tue, 12 Jul 2016 14:26:36 +0000 (19:56 +0530)
It is always suggested that one listener should not be function of some
other listener.This commit takes care of this in
NeutronPortChangeListener.java file.

Change-Id: I7806f3eb410fa1712603d7e76a26e8287d3e04e6
Signed-off-by: Suraj Ranjan <suraj.ranjan@ericsson.com>
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnManager.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnProvider.java
vpnservice/neutronvpn/neutronvpn-impl/src/test/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListenerTest.java

index 9fdc29f5a3210745a6b691df217a990c87b9938b..81fe84f308ac10a9ed6b9d60895787495513b0d4 100644 (file)
@@ -63,19 +63,16 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
     private LockManagerService lockManager;
     private NotificationPublishService notificationPublishService;
     private NotificationService notificationService;
-    private NeutronFloatingToFixedIpMappingChangeListener floatingIpMapListener;
 
 
     public NeutronPortChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr,NeutronvpnNatManager nVpnNatMgr,
-                                     NotificationPublishService notiPublishService, NotificationService notiService,
-                                     NeutronFloatingToFixedIpMappingChangeListener neutronFloatingToFixedIpMappingChangeListener) {
+                                     NotificationPublishService notiPublishService, NotificationService notiService) {
         super(Port.class);
         broker = db;
         nvpnManager = nVpnMgr;
         nvpnNatManager = nVpnNatMgr;
         notificationPublishService = notiPublishService;
         notificationService = notiService;
-        floatingIpMapListener = neutronFloatingToFixedIpMappingChangeListener;
         registerListener(db);
     }
 
@@ -274,7 +271,7 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
 
     private void handleNeutronPortDeleted(Port port) {
         //dissociate fixedIP from floatingIP if associated
-        floatingIpMapListener.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
+        nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
         LOG.debug("Remove port from subnet");
         // remove port from local Subnets DS
         Uuid vpnId = removePortFromSubnets(port);
index 2b0d5b605dee76b91dd6218245a56d5bb44e927a..fc10dc3d978cca71220069281a69c628b1bd1484 100644 (file)
@@ -124,6 +124,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     IMdsalApiManager mdsalUtil;
     private NotificationPublishService notificationPublishService;
     private NotificationService notificationService;
+    private NeutronFloatingToFixedIpMappingChangeListener floatingIpMapListener;
     Boolean isExternalVpn;
 
     /**
@@ -131,12 +132,14 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
      * @param mdsalManager - MDSAL Util API access
      */
     public NeutronvpnManager(final DataBroker db, IMdsalApiManager mdsalManager,NotificationPublishService notiPublishService,
-                             NotificationService notiService, NeutronvpnNatManager vpnNatMgr) {
+                             NotificationService notiService, NeutronvpnNatManager vpnNatMgr,
+                             NeutronFloatingToFixedIpMappingChangeListener neutronFloatingToFixedIpMappingChangeListener) {
         broker = db;
         mdsalUtil = mdsalManager;
         nvpnNatManager = vpnNatMgr;
         notificationPublishService = notiPublishService;
         notificationService = notiService;
+        floatingIpMapListener = neutronFloatingToFixedIpMappingChangeListener;
     }
 
     public void setLockManager(LockManagerService lockManager) {
@@ -1157,6 +1160,10 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
+    protected void dissociatefixedIPFromFloatingIP(String fixedNeutronPortName) {
+        floatingIpMapListener.dissociatefixedIPFromFloatingIP(fixedNeutronPortName);
+    }
+
     protected void associateRouterToInternalVpn(Uuid vpnId, Uuid routerId) {
         List<Uuid> routerSubnets = NeutronvpnUtils.getNeutronRouterSubnetIds(broker, routerId);
         logger.debug("Adding subnets to internal vpn {}", vpnId.getValue());
index 4352175361514499670d6e1b51a4fd0dc65ad254..7dadb5fc66d5205483ae1c8bf65261d6433df822 100644 (file)
@@ -81,17 +81,17 @@ public class NeutronvpnProvider implements BindingAwareProvider, INeutronVpnMana
         try {
             final DataBroker dbx = session.getSALService(DataBroker.class);
             nvNatManager = new NeutronvpnNatManager(dbx, mdsalManager);
+            floatingIpMapListener = new NeutronFloatingToFixedIpMappingChangeListener(dbx);
             nvManager = new NeutronvpnManager(dbx, mdsalManager,notificationPublishService,notificationService,
-                    nvNatManager);
+                    nvNatManager, floatingIpMapListener);
             final BindingAwareBroker.RpcRegistration<NeutronvpnService> rpcRegistration =
                     getRpcProviderRegistry().addRpcImplementation(NeutronvpnService.class, nvManager);
             bgpvpnListener = new NeutronBgpvpnChangeListener(dbx, nvManager);
             networkListener = new NeutronNetworkChangeListener(dbx, nvManager, nvNatManager);
             subnetListener = new NeutronSubnetChangeListener(dbx, nvManager);
             routerListener = new NeutronRouterChangeListener(dbx, nvManager, nvNatManager);
-            floatingIpMapListener = new NeutronFloatingToFixedIpMappingChangeListener(dbx);
             portListener = new NeutronPortChangeListener(dbx, nvManager, nvNatManager,
-                    notificationPublishService,notificationService, floatingIpMapListener);
+                    notificationPublishService,notificationService);
             portListener.setLockManager(lockManager);
             portListener.setLockManager(lockManager);
             nvManager.setLockManager(lockManager);
index 306f2fe12bf2c36d5f5f713389528ea7cbe1a5e7..8ce5155e929dfbb6c451c7f01f43739ae3e32426 100644 (file)
@@ -76,7 +76,7 @@ public class NeutronPortChangeListenerTest {
             thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNetwork)));
 
         neutronPortChangeListener = new NeutronPortChangeListener(dataBroker, nVpnMgr, nVpnNatMgr,
-                notiPublishService, notiService, floatingIpMapListener);
+                notiPublishService, notiService);
     }
 
     @Test