VOL-3343  In connect point mode, IgmpProxy cannot packet-out to the agg.device in slave mode

Change-Id: I6e4a3304a7ee04e101f611c8ebea1e47935c7a30
diff --git a/app/src/main/java/org/opencord/igmpproxy/impl/IgmpManager.java b/app/src/main/java/org/opencord/igmpproxy/impl/IgmpManager.java
index f70dde2..133ff18 100644
--- a/app/src/main/java/org/opencord/igmpproxy/impl/IgmpManager.java
+++ b/app/src/main/java/org/opencord/igmpproxy/impl/IgmpManager.java
@@ -240,7 +240,7 @@
         appId = coreService.registerApplication(APP_NAME);
         coreAppId = coreService.registerApplication(CoreService.CORE_APP_NAME);
         packetService.addProcessor(processor, PacketProcessor.director(4));
-        IgmpSender.init(packetService, igmpLeadershipService, igmpStatisticsManager);
+        IgmpSender.init(packetService, igmpStatisticsManager);
 
         networkConfig.registerConfigFactory(igmpproxySsmConfigFactory);
         networkConfig.registerConfigFactory(igmpproxyConfigFactory);
@@ -1051,7 +1051,11 @@
                         if (vlanConfigChanged || innerVlanConfigChanged) {
                             log.info("igmpproxy vlan config received. {}", config);
                             //at least one of the vlan configs has changed. Call leave before setting new values
-                            groupMemberStore.getAllGroupMembers().forEach(m -> leaveAction(m));
+                            groupMemberStore.getAllGroupMembers().forEach(m -> {
+                                if (igmpLeadershipService.isLocalLeader(m.getDeviceId())) {
+                                    leaveAction(m);
+                                }
+                            });
                             if (vlanConfigChanged) {
                                 mvlan = config.egressVlan().toShort();
                                 IgmpSender.getInstance().setMvlan(mvlan);
diff --git a/app/src/main/java/org/opencord/igmpproxy/impl/IgmpSender.java b/app/src/main/java/org/opencord/igmpproxy/impl/IgmpSender.java
index c71c70a..79aa80e 100644
--- a/app/src/main/java/org/opencord/igmpproxy/impl/IgmpSender.java
+++ b/app/src/main/java/org/opencord/igmpproxy/impl/IgmpSender.java
@@ -65,16 +65,13 @@
     private int maxResp = DEFAULT_MEX_RESP;
     private Logger log = LoggerFactory.getLogger(getClass());
 
-    private IgmpSender(PacketService packetService, IgmpLeadershipService igmpLeadershipService,
-             IgmpStatisticsService igmpStatisticsService) {
+    private IgmpSender(PacketService packetService, IgmpStatisticsService igmpStatisticsService) {
         this.packetService = packetService;
-        this.igmpLeadershipService = igmpLeadershipService;
         this.igmpStatisticsService = igmpStatisticsService;
     }
 
-    public static void init(PacketService packetService, IgmpLeadershipService igmpLeadershipService,
-            IgmpStatisticsService igmpStatisticsService) {
-        instance = new IgmpSender(packetService, igmpLeadershipService, igmpStatisticsService);
+    public static void init(PacketService packetService, IgmpStatisticsService igmpStatisticsService) {
+        instance = new IgmpSender(packetService, igmpStatisticsService);
     }
 
     public static IgmpSender getInstance() {
@@ -254,10 +251,6 @@
     }
 
     public void sendIgmpPacketUplink(Ethernet ethPkt, DeviceId deviceId, PortNumber upLinkPort) {
-        if (!igmpLeadershipService.isLocalLeader(deviceId)) {
-            return;
-        }
-
         if (IgmpManager.connectPointMode) {
             if (IgmpManager.connectPoint == null) {
                 log.warn("cannot find a connectPoint to send the packet uplink");
@@ -270,12 +263,6 @@
     }
 
     public void sendIgmpPacket(Ethernet ethPkt, DeviceId deviceId, PortNumber portNumber) {
-        if (!igmpLeadershipService.isLocalLeader(deviceId)) {
-            log.trace("Instance is not leader for device {}, " +
-                             "not emitting IMGP packet on port {}", deviceId, portNumber);
-            return;
-        }
-
         if (log.isTraceEnabled()) {
             log.trace("Emitting on {}/{} outbound IGMP packet {}", deviceId, portNumber, ethPkt);
         }