Moving Multicast subsystem into app and refactoring APIs to support multihomed sources and sinks
Change-Id: I95d07b163c619b018ff106159b134ff214aa2ffd
diff --git a/apps/mcast/impl/BUCK b/apps/mcast/impl/BUCK
new file mode 100644
index 0000000..c3d67ff
--- /dev/null
+++ b/apps/mcast/impl/BUCK
@@ -0,0 +1,16 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:KRYO',
+ '//core/store/serializers:onos-core-serializers',
+ '//apps/mcast/api:onos-apps-mcast-api'
+]
+
+TEST_DEPS = [
+ '//lib:TEST_ADAPTERS',
+ '//utils/osgi:onlab-osgi-tests',
+]
+
+osgi_jar_with_tests(
+ deps = COMPILE_DEPS,
+ test_deps = TEST_DEPS,
+)
diff --git a/apps/mcast/impl/pom.xml b/apps/mcast/impl/pom.xml
new file mode 100644
index 0000000..4fe6094
--- /dev/null
+++ b/apps/mcast/impl/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+<!--
+ ~ Copyright 2018-present Open Networking Foundation
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-mcast</artifactId>
+ <version>1.12.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-app-mcast-impl</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-mcast-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-common</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
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
new file mode 100644
index 0000000..8bdf42e
--- /dev/null
+++ b/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/DistributedMcastRoutesStore.java
@@ -0,0 +1,283 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.mcast.impl;
+
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.mcast.api.McastEvent;
+import org.onosproject.mcast.api.McastRoute;
+import org.onosproject.mcast.api.McastRouteData;
+import org.onosproject.mcast.api.McastStore;
+import org.onosproject.mcast.api.McastStoreDelegate;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
+import org.onosproject.store.AbstractStore;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.MapEvent;
+import org.onosproject.store.service.MapEventListener;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.Versioned;
+import org.slf4j.Logger;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.mcast.api.McastRouteUpdate.mcastRouteUpdate;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * New distributed mcast route store implementation. Routes are stored consistently
+ * across the cluster.
+ */
+@Component(immediate = true)
+@Service
+public class DistributedMcastRoutesStore
+ extends AbstractStore<McastEvent, McastStoreDelegate>
+ implements McastStore {
+
+ private static final String MCASTRIB = "onos-mcast-route-table";
+ private Logger log = getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected StorageService storageService;
+
+ private Map<McastRoute, McastRouteData> mcastRoutes;
+ private ConsistentMap<McastRoute, McastRouteData> mcastRib;
+ private MapEventListener<McastRoute, McastRouteData> mcastRouteListener =
+ new McastRouteListener();
+
+ private ScheduledExecutorService executor;
+
+
+ @Activate
+ public void activate() {
+ mcastRib = storageService.<McastRoute, McastRouteData>consistentMapBuilder()
+ .withName(MCASTRIB)
+ .withSerializer(Serializer.using(KryoNamespace.newBuilder()
+ .register(KryoNamespaces.API)
+ .register(
+ McastRoute.class,
+ AtomicReference.class,
+ McastRouteData.class,
+ McastRoute.Type.class
+ ).build()))
+ .build();
+
+ mcastRoutes = mcastRib.asJavaMap();
+ mcastRib.addListener(mcastRouteListener);
+
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ mcastRib.removeListener(mcastRouteListener);
+ mcastRib.destroy();
+ log.info("Stopped");
+ }
+
+ @Override
+ public void storeRoute(McastRoute route) {
+ mcastRoutes.put(route, McastRouteData.empty());
+ }
+
+ @Override
+ public void removeRoute(McastRoute route) {
+ mcastRoutes.remove(route);
+ }
+
+ @Override
+ public void storeSources(McastRoute route, Set<ConnectPoint> sources) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.addSources(sources);
+ return v;
+ });
+ }
+
+ @Override
+ public void removeSources(McastRoute route) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.removeSources();
+ return v;
+ });
+ }
+
+ @Override
+ public void removeSources(McastRoute route, Set<ConnectPoint> sources) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.removeSources(sources);
+ return v;
+ });
+
+ }
+
+ @Override
+ public void addSink(McastRoute route, HostId hostId, Set<ConnectPoint> sinks) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.addSinks(hostId, sinks);
+ return v;
+ });
+ }
+
+ @Override
+ public void addSinks(McastRoute route, Set<ConnectPoint> sinks) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.addSinks(HostId.NONE, sinks);
+ return v;
+ });
+ }
+
+
+ @Override
+ public void removeSinks(McastRoute route) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.removeSinks();
+ return v;
+ });
+ }
+
+ @Override
+ public void removeSink(McastRoute route, HostId hostId) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.removeSinks(hostId);
+ return v;
+ });
+ }
+
+ @Override
+ public void removeSinks(McastRoute route, HostId hostId, Set<ConnectPoint> sinks) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.removeSinks(hostId, sinks);
+ return v;
+ });
+ }
+
+ @Override
+ public void removeSinks(McastRoute route, Set<ConnectPoint> sinks) {
+ McastRouteData data = mcastRoutes.compute(route, (k, v) -> {
+ v.removeSinks(HostId.NONE, sinks);
+ return v;
+ });
+ }
+
+ @Override
+ public Set<ConnectPoint> sourcesFor(McastRoute route) {
+ McastRouteData data = mcastRoutes.getOrDefault(route, null);
+ return data == null ? ImmutableSet.of() : ImmutableSet.copyOf(data.sources());
+ }
+
+ @Override
+ public Set<ConnectPoint> sinksFor(McastRoute route) {
+ McastRouteData data = mcastRoutes.getOrDefault(route, null);
+ return data == null ? ImmutableSet.of() : ImmutableSet.copyOf(data.sinks().values().stream()
+ .flatMap(Collection::stream).collect(Collectors.toSet()));
+ }
+
+ @Override
+ public Set<ConnectPoint> sinksFor(McastRoute route, HostId hostId) {
+ McastRouteData data = mcastRoutes.getOrDefault(route, null);
+ return data == null ? ImmutableSet.of() : ImmutableSet.copyOf(data.sinks(hostId));
+ }
+
+ @Override
+ public Set<McastRoute> getRoutes() {
+ return ImmutableSet.copyOf(mcastRoutes.keySet());
+ }
+
+ @Override
+ public McastRouteData getRouteData(McastRoute route) {
+ return mcastRoutes.get(route);
+ }
+
+ private class McastRouteListener implements MapEventListener<McastRoute, McastRouteData> {
+ @Override
+ public void event(MapEvent<McastRoute, McastRouteData> event) {
+ final McastRoute route = event.key();
+ final McastRouteData newData =
+ Optional.ofNullable(event.newValue()).map(Versioned::value).orElse(null);
+ final McastRouteData oldData =
+ Optional.ofNullable(event.oldValue()).map(Versioned::value).orElse(null);
+
+ switch (event.type()) {
+ case INSERT:
+ checkNotNull(newData);
+ McastEvent.Type type;
+ if (!newData.sources().isEmpty() || !newData.sinks().isEmpty()) {
+ type = McastEvent.Type.SOURCES_ADDED;
+ } else if (!newData.sinks().isEmpty()) {
+ type = McastEvent.Type.SINKS_ADDED;
+ } else {
+ type = McastEvent.Type.ROUTE_ADDED;
+ }
+ notifyDelegate(new McastEvent(type, null,
+ mcastRouteUpdate(route, newData.sources(), newData.sinks())));
+ break;
+ case UPDATE:
+ checkNotNull(newData);
+ checkNotNull(oldData);
+
+ if (!Sets.difference(newData.sources(), oldData.sources()).isEmpty()) {
+ notifyDelegate(new McastEvent(McastEvent.Type.SOURCES_ADDED,
+ mcastRouteUpdate(route, oldData.sources(), oldData.sinks()),
+ mcastRouteUpdate(route, newData.sources(), newData.sinks())));
+ }
+ if (!Sets.difference(oldData.sources(), newData.sources()).isEmpty()) {
+ notifyDelegate(new McastEvent(McastEvent.Type.SOURCES_REMOVED,
+ mcastRouteUpdate(route, oldData.sources(), oldData.sinks()),
+ mcastRouteUpdate(route, newData.sources(), newData.sinks())));
+ }
+ if (newData.allSinks().size() > oldData.allSinks().size()) {
+ notifyDelegate(new McastEvent(McastEvent.Type.SINKS_ADDED,
+ mcastRouteUpdate(route, oldData.sources(), oldData.sinks()),
+ mcastRouteUpdate(route, newData.sources(), newData.sinks())));
+ } else if (newData.allSinks().size() < oldData.allSinks().size()) {
+ log.info("Removed");
+ notifyDelegate(new McastEvent(McastEvent.Type.SINKS_REMOVED,
+ mcastRouteUpdate(route, oldData.sources(), oldData.sinks()),
+ mcastRouteUpdate(route, newData.sources(), newData.sinks())));
+ }
+ break;
+ case REMOVE:
+ // Verify old data is not null
+ checkNotNull(oldData);
+ // Create a route removed event with just the route
+ // and the source connect point
+ notifyDelegate(new McastEvent(McastEvent.Type.ROUTE_REMOVED,
+ mcastRouteUpdate(route, oldData.sources(), oldData.sinks()),
+ null));
+ break;
+ default:
+ log.warn("Unknown mcast operation type: {}", event.type());
+ }
+ }
+ }
+}
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
new file mode 100644
index 0000000..6ed8b4b
--- /dev/null
+++ b/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/MulticastRouteManager.java
@@ -0,0 +1,284 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.mcast.impl;
+
+import com.google.common.collect.ImmutableSet;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.packet.IpAddress;
+import org.onosproject.event.AbstractListenerManager;
+import org.onosproject.mcast.api.McastEvent;
+import org.onosproject.mcast.api.McastListener;
+import org.onosproject.mcast.api.McastRoute;
+import org.onosproject.mcast.api.McastRouteData;
+import org.onosproject.mcast.api.McastStore;
+import org.onosproject.mcast.api.McastStoreDelegate;
+import org.onosproject.mcast.api.MulticastRouteService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.Host;
+import org.onosproject.net.HostId;
+import org.onosproject.net.host.HostEvent;
+import org.onosproject.net.host.HostListener;
+import org.onosproject.net.host.HostService;
+import org.slf4j.Logger;
+
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * An implementation of a multicast route table.
+ */
+@Component(immediate = true)
+@Service
+public class MulticastRouteManager
+ extends AbstractListenerManager<McastEvent, McastListener>
+ implements MulticastRouteService {
+ //TODO: add MulticastRouteAdminService
+
+ private Logger log = getLogger(getClass());
+
+ private final McastStoreDelegate delegate = new InternalMcastStoreDelegate();
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected McastStore store;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected HostService hostService;
+
+ private HostListener hostListener = new InternalHostListener();
+
+ @Activate
+ public void activate() {
+ hostService.addListener(hostListener);
+ eventDispatcher.addSink(McastEvent.class, listenerRegistry);
+ store.setDelegate(delegate);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ hostService.removeListener(hostListener);
+ store.unsetDelegate(delegate);
+ eventDispatcher.removeSink(McastEvent.class);
+ log.info("Stopped");
+ }
+
+ @Override
+ public void add(McastRoute route) {
+ checkNotNull(route, "Route cannot be null");
+ store.storeRoute(route);
+ }
+
+ @Override
+ public void remove(McastRoute route) {
+ checkNotNull(route, "Route cannot be null");
+ if (checkRoute(route)) {
+ store.removeRoute(route);
+ }
+ }
+
+ @Override
+ public Set<McastRoute> getRoutes() {
+ return store.getRoutes();
+ }
+
+ @Override
+ public Optional<McastRoute> getRoute(IpAddress groupIp, IpAddress sourceIp) {
+ return store.getRoutes().stream().filter(route ->
+ route.group().equals(groupIp) &&
+ route.source().isPresent() &&
+ route.source().get().equals(sourceIp)).findAny();
+ }
+
+ @Override
+ public void addSources(McastRoute route, Set<ConnectPoint> connectPoints) {
+ checkNotNull(route, "Route cannot be null");
+ checkNotNull(connectPoints, "Source cannot be null");
+ if (checkRoute(route)) {
+ store.storeSources(route, connectPoints);
+ }
+ }
+
+ @Override
+ public void removeSources(McastRoute route) {
+ checkNotNull(route, "Route cannot be null");
+ if (checkRoute(route)) {
+ store.removeSources(route);
+ }
+ }
+
+ @Override
+ public void removeSources(McastRoute route, Set<ConnectPoint> sources) {
+ checkNotNull(route, "Route cannot be null");
+ checkNotNull(sources, "Source cannot be null");
+ if (checkRoute(route)) {
+ store.removeSources(route, sources);
+ }
+ }
+
+ @Override
+ public void addSink(McastRoute route, HostId hostId) {
+ if (checkRoute(route)) {
+ Set<ConnectPoint> sinks = new HashSet<>();
+ Host host = hostService.getHost(hostId);
+ if (host != null) {
+ host.locations().forEach(hostLocation -> sinks.add(
+ ConnectPoint.deviceConnectPoint(hostLocation.deviceId() + "/" + hostLocation.port())));
+ }
+ store.addSink(route, hostId, sinks);
+ }
+
+ }
+
+ @Override
+ public void addSink(McastRoute route, Set<ConnectPoint> sinks) {
+ checkNotNull(route, "Route cannot be null");
+ checkNotNull(sinks, "Sinks cannot be null");
+ if (checkRoute(route)) {
+ store.addSinks(route, sinks);
+ }
+ }
+
+ @Override
+ public void removeSinks(McastRoute route) {
+ checkNotNull(route, "Route cannot be null");
+ if (checkRoute(route)) {
+ store.removeSinks(route);
+ }
+ }
+
+ @Override
+ public void removeSink(McastRoute route, HostId hostId) {
+ checkNotNull(route, "Route cannot be null");
+ checkNotNull(hostId, "Host cannot be null");
+ if (checkRoute(route)) {
+ store.removeSink(route, hostId);
+ }
+ }
+
+ @Override
+ public void removeSinks(McastRoute route, HostId hostId, Set<ConnectPoint> connectPoints) {
+ checkNotNull(route, "Route cannot be null");
+ if (checkRoute(route)) {
+ store.removeSinks(route, hostId, connectPoints);
+ }
+
+ }
+
+ @Override
+ public void removeSinks(McastRoute route, Set<ConnectPoint> connectPoints) {
+ checkNotNull(route, "Route cannot be null");
+ if (checkRoute(route)) {
+ store.removeSinks(route, HostId.NONE, connectPoints);
+ }
+ }
+
+ @Override
+ public McastRouteData routeData(McastRoute route) {
+ checkNotNull(route, "Route cannot be null");
+ return checkRoute(route) ? store.getRouteData(route) : null;
+ }
+
+ @Override
+ public Set<ConnectPoint> sources(McastRoute route) {
+ checkNotNull(route, "Route cannot be null");
+ return checkRoute(route) ? store.sourcesFor(route) : ImmutableSet.of();
+ }
+
+ @Override
+ public Set<ConnectPoint> sinks(McastRoute route) {
+ checkNotNull(route, "Route cannot be null");
+ return checkRoute(route) ? store.sinksFor(route) : ImmutableSet.of();
+ }
+
+ @Override
+ public Set<ConnectPoint> sinks(McastRoute route, HostId hostId) {
+ checkNotNull(route, "Route cannot be null");
+ return checkRoute(route) ? store.sinksFor(route, hostId) : ImmutableSet.of();
+ }
+
+ @Override
+ public Set<ConnectPoint> nonHostSinks(McastRoute route) {
+ checkNotNull(route, "Route cannot be null");
+ return checkRoute(route) ? store.sinksFor(route, HostId.NONE) : ImmutableSet.of();
+ }
+
+ private class InternalMcastStoreDelegate implements McastStoreDelegate {
+ @Override
+ public void notify(McastEvent event) {
+ log.debug("Event: {}", event);
+ post(event);
+ }
+ }
+
+ private boolean checkRoute(McastRoute route) {
+ if (store.getRoutes().contains(route)) {
+ return true;
+ } else {
+ log.warn("Route {} is not present in the store, please add it", route);
+ }
+ return false;
+ }
+
+ private class InternalHostListener implements HostListener {
+
+ @Override
+ public void event(HostEvent event) {
+ HostId hostId = event.subject().id();
+ Set<ConnectPoint> sinks = new HashSet<>();
+ log.debug("{} event", event);
+ //FIXME ther must be a better way
+ event.subject().locations().forEach(hostLocation -> sinks.add(
+ ConnectPoint.deviceConnectPoint(hostLocation.deviceId() + "/" + hostLocation.port())));
+ switch (event.type()) {
+ case HOST_ADDED:
+ case HOST_UPDATED:
+ case HOST_MOVED:
+ if ((event.prevSubject() == null && event.subject() != null)
+ || (event.prevSubject().locations().size() > event.subject().locations().size())) {
+ store.getRoutes().stream().filter(mcastRoute -> {
+ return store.getRouteData(mcastRoute).sinks().get(hostId) != null;
+ }).forEach(route -> {
+ store.removeSinks(route, hostId, sinks);
+ });
+ } else if (event.prevSubject().locations().size() < event.subject().locations().size()) {
+ store.getRoutes().stream().filter(mcastRoute -> {
+ return store.getRouteData(mcastRoute).sinks().get(hostId) != null;
+ }).forEach(route -> {
+ store.addSink(route, hostId, sinks);
+ });
+ }
+ break;
+ case HOST_REMOVED:
+ store.getRoutes().stream().filter(mcastRoute -> {
+ return store.getRouteData(mcastRoute).sinks().get(hostId) != null;
+ }).forEach(route -> {
+ store.removeSink(route, hostId);
+ });
+ default:
+ log.debug("Host event {} not supported", event.type());
+ }
+ }
+ }
+}
diff --git a/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/package-info.java b/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/package-info.java
new file mode 100644
index 0000000..7b18561
--- /dev/null
+++ b/apps/mcast/impl/src/main/java/org/onosproject/mcast/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Multicast routes store and manager implementation & related services implementation.
+ */
+package org.onosproject.mcast.impl;