SEBA-991-A new API needed to remove specific sources from a McastRoute

Change-Id: Ia7e6cf6939c517743d5adc6bc3869decdf64609f
diff --git a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRouteData.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRouteData.java
index ce81ea9..a343c39 100644
--- a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRouteData.java
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRouteData.java
@@ -121,8 +121,8 @@
      * Adds sources for a given host Id. If the Host Id is {@link HostId#NONE} the sources are intended to be
      * used at all times independently of the attached host.
      *
-     * @param hostId the host
-     * @param sources  the sources
+     * @param hostId  the host
+     * @param sources the sources
      */
     public void addSources(HostId hostId, Set<ConnectPoint> sources) {
         checkNotNull(hostId);
diff --git a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastStore.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastStore.java
index 484f32ec..5e2c1e6 100644
--- a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastStore.java
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastStore.java
@@ -57,7 +57,7 @@
      * The source stored with this method are not tied with any host.
      * Traffic will be sent from all of them.
      *
-     * @param route a Multicast route
+     * @param route   a Multicast route
      * @param sources set of specific connect points
      */
     void storeSources(McastRoute route, Set<ConnectPoint> sources);
@@ -78,6 +78,15 @@
     void removeSource(McastRoute route, HostId source);
 
     /**
+     * Removes a set of source connect points for a given route.
+     * This method is not tied with any host.
+     *
+     * @param route   a Multicast route
+     * @param sources set of specific connect points
+     */
+    void removeSources(McastRoute route, Set<ConnectPoint> sources);
+
+    /**
      * Removes a set of source connect points for a given host the route.
      *
      * @param route         the multicast route
diff --git a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/MulticastRouteService.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/MulticastRouteService.java
index bd32363..2e34a4b 100644
--- a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/MulticastRouteService.java
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/MulticastRouteService.java
@@ -86,7 +86,7 @@
      * used as different sources for that Mcast Tree. For dual-homed sources
      * please use {@link #addSource(McastRoute route, HostId hostId) addSource}.
      *
-     * @param route a Multicast route
+     * @param route   a Multicast route
      * @param sources a set of source connect points
      */
     void addSources(McastRoute route, Set<ConnectPoint> sources);
@@ -107,6 +107,26 @@
     void removeSource(McastRoute route, HostId source);
 
     /**
+     * Removes a set of sources from the route.
+     * If this method is used the connect points will all be
+     * used as different sources for that Mcast Tree. For dual-homed sources
+     * please use {@link #removeSource(McastRoute, HostId)}.
+     *
+     * @param route   the multicast route
+     * @param sources set of sources
+     */
+    void removeSources(McastRoute route, Set<ConnectPoint> sources);
+
+    /**
+     * Removes a set of source connect points for a given host source from the route.
+     *
+     * @param route         a multicast route
+     * @param hostId        a source host
+     * @param connectPoints the source for the specific connect points
+     */
+    void removeSources(McastRoute route, HostId hostId, Set<ConnectPoint> connectPoints);
+
+    /**
      * Adds a sink to the route to which a data stream should be
      * sent to.
      *
diff --git a/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/DistributedMcastRoutesStore.java b/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/DistributedMcastRoutesStore.java
index e3526c4..2d86104 100644
--- a/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/DistributedMcastRoutesStore.java
+++ b/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/DistributedMcastRoutesStore.java
@@ -145,6 +145,14 @@
     }
 
     @Override
+    public void removeSources(McastRoute route, Set<ConnectPoint> sources) {
+        mcastRoutes.compute(route, (k, v) -> {
+            v.removeSources(HostId.NONE, sources);
+            return v;
+        });
+    }
+
+    @Override
     public void removeSources(McastRoute route, HostId hostId, Set<ConnectPoint> sources) {
         mcastRoutes.compute(route, (k, v) -> {
             v.removeSources(hostId, sources);
diff --git a/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/MulticastRouteManager.java b/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/MulticastRouteManager.java
index a004c8d..51d4207 100644
--- a/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/MulticastRouteManager.java
+++ b/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/MulticastRouteManager.java
@@ -172,6 +172,25 @@
     }
 
     @Override
+    public void removeSources(McastRoute route, Set<ConnectPoint> connectPoints) {
+        checkNotNull(route, "Route cannot be null");
+        checkNotNull(connectPoints, "ConnectPoints cannot be null");
+        if (checkRoute(route)) {
+            store.removeSources(route, connectPoints);
+        }
+    }
+
+    @Override
+    public void removeSources(McastRoute route, HostId hostId, Set<ConnectPoint> connectPoints) {
+        checkNotNull(route, "Route cannot be null");
+        checkNotNull(hostId, "HostId cannot be null");
+        checkNotNull(connectPoints, "ConnectPoints cannot be null");
+        if (checkRoute(route)) {
+            store.removeSources(route, hostId, connectPoints);
+        }
+    }
+
+    @Override
     public void addSink(McastRoute route, HostId hostId) {
         if (checkRoute(route)) {
             Set<ConnectPoint> sinks = new HashSet<>();
@@ -303,7 +322,7 @@
                         if ((event.prevSubject() != null && event.subject() != null)) {
                             //we compute the difference between old locations and new ones and remove the previous
                             Set<HostLocation> removedConnectPoint = Sets.difference(event.prevSubject().locations(),
-                                event.subject().locations()).immutableCopy();
+                                    event.subject().locations()).immutableCopy();
                             if (!removedConnectPoint.isEmpty()) {
                                 if (!routesForSource.isEmpty()) {
                                     eventRemoveSources(hostId, removedConnectPoint, routesForSource);
@@ -313,7 +332,7 @@
                                 }
                             }
                             Set<HostLocation> addedConnectPoints = Sets.difference(event.subject().locations(),
-                                event.prevSubject().locations()).immutableCopy();
+                                    event.prevSubject().locations()).immutableCopy();
                             //if the host now has some new locations we add them to the sinks set
                             if (!addedConnectPoints.isEmpty()) {
                                 if (!routesForSource.isEmpty()) {