Moving Multicast subsystem into app and refactoring APIs to support multihomed sources and sinks
Change-Id: I95d07b163c619b018ff106159b134ff214aa2ffd
diff --git a/apps/mcast/BUCK b/apps/mcast/BUCK
new file mode 100644
index 0000000..58f3dd7
--- /dev/null
+++ b/apps/mcast/BUCK
@@ -0,0 +1,15 @@
+BUNDLES = [
+ '//apps/mcast/cli:onos-apps-mcast-cli',
+ '//apps/mcast/impl:onos-apps-mcast-impl',
+ '//apps/mcast/web:onos-apps-mcast-web',
+ '//apps/mcast/api:onos-apps-mcast-api',
+]
+
+onos_app(
+ title = 'Multicast traffic control',
+ origin = 'ONF',
+ description = 'Provides handling of multicast traffic.',
+ category = 'Traffic Engineering',
+ url = 'https://wiki.onosproject.org/',
+ included_bundles = BUNDLES,
+)
diff --git a/apps/mcast/api/BUCK b/apps/mcast/api/BUCK
new file mode 100644
index 0000000..db499cc
--- /dev/null
+++ b/apps/mcast/api/BUCK
@@ -0,0 +1,15 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:KRYO',
+ '//core/store/serializers:onos-core-serializers',
+]
+
+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/api/pom.xml b/apps/mcast/api/pom.xml
new file mode 100644
index 0000000..370d992
--- /dev/null
+++ b/apps/mcast/api/pom.xml
@@ -0,0 +1,72 @@
+<?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-api</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>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/api/src/main/java/org/onosproject/mcast/api/McastEvent.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastEvent.java
new file mode 100644
index 0000000..9230736
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastEvent.java
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.api;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.event.AbstractEvent;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * An entity representing a multicast event. Event either add or remove
+ * sinks or sources.
+ */
+@Beta
+public class McastEvent extends AbstractEvent<McastEvent.Type, McastRouteUpdate> {
+
+ /**
+ * Mcast Event type enum.
+ */
+ public enum Type {
+ /**
+ * A new mcast route has been added.
+ */
+ ROUTE_ADDED,
+
+ /**
+ * A mcast route has been removed.
+ */
+ ROUTE_REMOVED,
+
+ /**
+ * A set of sources for a mcast route (ie. the subject) has been added.
+ */
+ SOURCES_ADDED,
+
+ /**
+ * A set of sources for a mcast route has been removed.
+ */
+ SOURCES_REMOVED,
+
+ /**
+ * A set of sinks for a mcast route (ie. the subject) has been added.
+ */
+ SINKS_ADDED,
+
+ /**
+ * A set of sinks for a mcast route (ie. the subject) has been removed.
+ */
+ SINKS_REMOVED
+ }
+
+ private McastRouteUpdate prevSubject;
+
+ /**
+ * Creates a McastEvent of a given type using the subject.
+ *
+ * @param type the event type
+ * @param prevSubject the previous mcast information
+ * @param subject the current mcast information
+ */
+ public McastEvent(McastEvent.Type type, McastRouteUpdate prevSubject, McastRouteUpdate subject) {
+ super(type, subject);
+ this.prevSubject = prevSubject;
+ }
+
+ /**
+ * Gets the previous subject in this Mcast event.
+ *
+ * @return the previous subject, or null if previous subject is not
+ * specified.
+ */
+ public McastRouteUpdate prevSubject() {
+ return this.prevSubject;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type(), subject(), prevSubject());
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof McastEvent)) {
+ return false;
+ }
+
+ McastEvent that = (McastEvent) other;
+
+ return Objects.equals(this.subject(), that.subject()) &&
+ Objects.equals(this.type(), that.type()) &&
+ Objects.equals(this.prevSubject(), that.prevSubject());
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("type", type())
+ .add("prevSubject", prevSubject())
+ .add("subject", subject())
+ .toString();
+ }
+}
diff --git a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastListener.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastListener.java
new file mode 100644
index 0000000..980e23c
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastListener.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.api;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * A listener interface for multicast events.
+ */
+public interface McastListener extends EventListener<McastEvent> {
+}
diff --git a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRoute.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRoute.java
new file mode 100644
index 0000000..9d5afeb
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRoute.java
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.api;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import org.onlab.packet.IpAddress;
+
+import java.util.Optional;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * An entity representing a multicast route consisting of a source ip
+ * and a multicast group address.
+ */
+@Beta
+public class McastRoute {
+
+ /**
+ * Possible route types.
+ */
+ public enum Type {
+ /**
+ * Route originates from PIM.
+ */
+ PIM,
+
+ /**
+ * Route originates from IGMP.
+ */
+ IGMP,
+
+ /**
+ * Route originates from other config (ie. REST, CLI).
+ */
+ STATIC
+ }
+
+ private final IpAddress source;
+ private final IpAddress group;
+ private final Type type;
+
+ /**
+ * Creates the McastRoute object. The source Ip can be null if this route is intent for ASM.
+ * @param source source Ip. Null if ASM route. Will translate in Optional.empty.
+ * @param group the multicast group
+ * @param type the route type.
+ */
+ public McastRoute(IpAddress source, IpAddress group, Type type) {
+ checkNotNull(group, "Multicast route must specify a group address");
+ this.source = source;
+ this.group = group;
+ this.type = type;
+ }
+
+ /**
+ * Fetches the source address of this route.
+ *
+ * @return an optional ip address.
+ */
+ public Optional<IpAddress> source() {
+ return Optional.ofNullable(source);
+ }
+
+ /**
+ * Fetches the group address of this route.
+ *
+ * @return an ip address
+ */
+ public IpAddress group() {
+ return group;
+ }
+
+
+ /**
+ * Type of this route.
+ *
+ * @return type
+ */
+ public Type type() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("source", source)
+ .add("group", group)
+ .add("type", type())
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ McastRoute that = (McastRoute) o;
+ return Objects.equal(source, that.source) &&
+ Objects.equal(group, that.group) &&
+ Objects.equal(type, that.type());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(source, group, type);
+ }
+
+}
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
new file mode 100644
index 0000000..9965818
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRouteData.java
@@ -0,0 +1,219 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.api;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Data regarding a multicast route, comprised of a type, multiple sources and multiple sinks.
+ */
+@Beta
+public final class McastRouteData {
+
+ private final ConcurrentHashMap<ConnectPoint, Boolean> sources = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<HostId, Set<ConnectPoint>> sinks = new ConcurrentHashMap<>();
+
+ private McastRouteData() {
+ }
+
+ /**
+ * Sources contained in the associated route.
+ *
+ * @return set of sources
+ */
+ public Set<ConnectPoint> sources() {
+ return ImmutableSet.copyOf(sources.keySet());
+ }
+
+ /**
+ * Sources contained in the associated route.
+ *
+ * @return map of hostIds and associated sinks
+ */
+ public Map<HostId, Set<ConnectPoint>> sinks() {
+ return ImmutableMap.copyOf(sinks);
+ }
+
+ /**
+ * Sources contained in the associated route.
+ *
+ * @return map of hostIds and associated sinks
+ */
+ public Set<ConnectPoint> allSinks() {
+ return sinks.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
+ }
+
+ /**
+ * Sinks contained in the associated route for the given host.
+ *
+ * @param hostId the host
+ * @return set of sinks
+ */
+ public Set<ConnectPoint> sinks(HostId hostId) {
+ return sinks.get(hostId);
+ }
+
+ /**
+ * Sinks contained in the associated route that are not bound to any host.
+ *
+ * @return set of sinks
+ */
+ public Set<ConnectPoint> nonHostSinks() {
+ return sinks.get(HostId.NONE);
+ }
+
+ /**
+ * Add the sources for the associated route.
+ *
+ * @param sources set of sources
+ */
+ public void addSources(Set<ConnectPoint> sources) {
+ checkArgument(!sources.contains(null));
+ sources.forEach(source -> {
+ this.sources.put(source, true);
+ });
+ }
+
+ /**
+ * Removes all the sources contained in the associated route.
+ */
+ public void removeSources() {
+ sources.clear();
+ }
+
+ /**
+ * Removes the given sources contained in the associated route.
+ *
+ * @param sources the sources to remove
+ */
+ public void removeSources(Set<ConnectPoint> sources) {
+ checkArgument(!sources.contains(null));
+ sources.forEach(this.sources::remove);
+ }
+
+ /**
+ * Adds sinks for a given host Id. If the Host Id is {@link HostId#NONE} the sinks are intended to be
+ * used at all times independently of the attached host.
+ *
+ * @param hostId the host
+ * @param sinks the sinks
+ */
+ public void addSinks(HostId hostId, Set<ConnectPoint> sinks) {
+ checkNotNull(hostId);
+ checkArgument(!sinks.contains(null));
+ this.sinks.put(hostId, sinks);
+ }
+
+ /**
+ * Adds sink for this route that are not associated directly with a given host.
+ *
+ * @param sinks the sinks
+ */
+ public void addNonHostSinks(Set<ConnectPoint> sinks) {
+ checkArgument(!sinks.contains(null));
+ this.sinks.put(HostId.NONE, sinks);
+ }
+
+ /**
+ * Removes all the sinks for this route.
+ */
+ public void removeSinks() {
+ sinks.clear();
+ }
+
+ /**
+ * Removes all the sinks for the given host for this route.
+ *
+ * @param hostId the host
+ */
+ public void removeSinks(HostId hostId) {
+ checkNotNull(hostId);
+ this.sinks.remove(hostId);
+ }
+
+ /**
+ * Removes all the given sinks for the given host for this route.
+ *
+ * @param hostId the host
+ * @param sinks the sinks to remove
+ */
+ public void removeSinks(HostId hostId, Set<ConnectPoint> sinks) {
+ checkNotNull(hostId);
+ checkArgument(!sinks.contains(null));
+ this.sinks.get(hostId).removeAll(sinks);
+ }
+
+ /**
+ * Returns if the route has no sinks.
+ *
+ * @return true if no sinks
+ */
+ public boolean isEmpty() {
+ return sinks.isEmpty();
+ }
+
+ /**
+ * Creates an empty route object.
+ *
+ * @return an empty muticast rout data object.
+ */
+ public static McastRouteData empty() {
+ return new McastRouteData();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), sources, sinks);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof McastRouteData)) {
+ return false;
+ }
+ final McastRouteData other = (McastRouteData) obj;
+
+ return super.equals(obj) &&
+ Objects.equals(sources(), other.sources()) &&
+ Objects.equals(sinks(), other.sinks());
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("sources", sources())
+ .add("sinks", sinks())
+ .toString();
+ }
+}
diff --git a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRouteUpdate.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRouteUpdate.java
new file mode 100644
index 0000000..4333465
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastRouteUpdate.java
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.api;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Utility class to propagate updates to multicast route information stored in the store.
+ */
+@Beta
+public final class McastRouteUpdate {
+
+ private static final String ROUTE_NOT_NULL = "Route cannot be null";
+ private static final String SOURCE_NOT_NULL = "Source cannot be null";
+ private static final String SINK_NOT_NULL = "Sink cannot be null";
+
+ private final McastRoute route;
+ private final Set<ConnectPoint> sources;
+ private final Map<HostId, Set<ConnectPoint>> sinks;
+
+ private McastRouteUpdate(McastRoute route, Set<ConnectPoint> source, Map<HostId, Set<ConnectPoint>> sinks) {
+ this.route = checkNotNull(route, ROUTE_NOT_NULL);
+ this.sources = checkNotNull(source, SOURCE_NOT_NULL);
+ this.sinks = checkNotNull(sinks, SINK_NOT_NULL);
+ }
+
+ /**
+ * Static method to create an McastRoutUpdate object.
+ *
+ * @param route the route updated
+ * @param sources the different sources
+ * @param sinks the different sinks
+ * @return the McastRouteUpdate object.
+ */
+ public static McastRouteUpdate mcastRouteUpdate(McastRoute route,
+ Set<ConnectPoint> sources,
+ Map<HostId, Set<ConnectPoint>> sinks) {
+ return new McastRouteUpdate(route, sources, sinks);
+ }
+
+ /**
+ * The route associated with this multicast information.
+ *
+ * @return a mulicast route
+ */
+ public McastRoute route() {
+ return route;
+ }
+
+ /**
+ * The sources.
+ *
+ * @return an optional connect point
+ */
+ public Set<ConnectPoint> sources() {
+ return sources;
+ }
+
+ /**
+ * The sinks.
+ *
+ * @return a set of connect points
+ */
+ public Map<HostId, Set<ConnectPoint>> sinks() {
+ return sinks;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ McastRouteUpdate that = (McastRouteUpdate) o;
+ return Objects.equals(route, that.route) &&
+ Objects.equals(sources, that.sources) &&
+ Objects.equals(sinks, that.sinks);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(route, sources, sinks);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("route", route())
+ .add("sources", sources)
+ .add("sinks", sinks)
+ .toString();
+ }
+}
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
new file mode 100644
index 0000000..53d444b
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastStore.java
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.api;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
+import org.onosproject.store.Store;
+
+import java.util.Set;
+
+/**
+ * Entity responsible for storing multicast state information.
+ */
+@Beta
+public interface McastStore extends Store<McastEvent, McastStoreDelegate> {
+
+ /**
+ * Updates the store with the route information.
+ *
+ * @param route a multicast route
+ */
+ void storeRoute(McastRoute route);
+
+ /**
+ * Updates the store with the route information.
+ *
+ * @param route a multicast route
+ */
+ void removeRoute(McastRoute route);
+
+ /**
+ * Add to the store with source information for the given route.
+ *
+ * @param route a multicast route
+ * @param sources a set of sources
+ */
+ void storeSources(McastRoute route, Set<ConnectPoint> sources);
+
+ /**
+ * Removes from the store all the sources information for a given route.
+ *
+ * @param route a multicast route
+ */
+ void removeSources(McastRoute route);
+
+ /**
+ * Removes from the store the source information for the given route.
+ * value.
+ *
+ * @param route a multicast route
+ * @param sources a set of sources
+ */
+ void removeSources(McastRoute route, Set<ConnectPoint> sources);
+
+ /**
+ * Updates the store with a host based sink information for a given route. There may be
+ * multiple sink connect points for the given host.
+ *
+ * @param route a multicast route
+ * @param hostId the host sink
+ * @param sinks the sinks
+ */
+ void addSink(McastRoute route, HostId hostId, Set<ConnectPoint> sinks);
+
+ /**
+ * Updates the store with sinks information for a given route.
+ * The sinks stored with this method are not tied with any host.
+ * Traffic will be sent to all of them.
+ *
+ * @param route a multicast route
+ * @param sinks set of specific connect points
+ */
+ void addSinks(McastRoute route, Set<ConnectPoint> sinks);
+
+ /**
+ * Removes from the store all the sink information for a given route.
+ *
+ * @param route a multicast route
+ */
+ void removeSinks(McastRoute route);
+
+ /**
+ * Removes from the store the complete set of sink information for a given host for a given route.
+ *
+ * @param route a multicast route
+ * @param hostId a specific host
+ */
+ void removeSink(McastRoute route, HostId hostId);
+
+ /**
+ * Removes from the store the given set of sink information for a given host for a given route.
+ *
+ * @param route a multicast route
+ * @param hostId the host
+ * @param sinks a set of multicast sink connect points
+ */
+ void removeSinks(McastRoute route, HostId hostId, Set<ConnectPoint> sinks);
+
+ /**
+ * Removes from the store the set of non host bind sink information for a given route.
+ *
+ * @param route a multicast route
+ * @param sinks a set of multicast sinks
+ */
+ void removeSinks(McastRoute route, Set<ConnectPoint> sinks);
+
+ /**
+ * Obtains the sources for a multicast route.
+ *
+ * @param route a multicast route
+ * @return a connect point
+ */
+ Set<ConnectPoint> sourcesFor(McastRoute route);
+
+ /**
+ * Obtains the sinks for a multicast route.
+ *
+ * @param route a multicast route
+ * @return a set of sinks
+ */
+ Set<ConnectPoint> sinksFor(McastRoute route);
+
+ /**
+ * Obtains the sinks for a given host for a given multicast route.
+ *
+ * @param route a multicast route
+ * @param hostId the host
+ * @return a set of sinks
+ */
+ Set<ConnectPoint> sinksFor(McastRoute route, HostId hostId);
+
+
+ /**
+ * Gets the set of all known multicast routes.
+ *
+ * @return set of multicast routes.
+ */
+ Set<McastRoute> getRoutes();
+
+ /**
+ * Gets the multicast data for a given route.
+ *
+ * @param route the route
+ * @return set of multicast routes.
+ */
+ McastRouteData getRouteData(McastRoute route);
+}
diff --git a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastStoreDelegate.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastStoreDelegate.java
new file mode 100644
index 0000000..49e894d
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/McastStoreDelegate.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.api;
+
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * Mcast store delegate abstraction.
+ */
+public interface McastStoreDelegate extends StoreDelegate<McastEvent> {
+}
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
new file mode 100644
index 0000000..d9b1721
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/MulticastRouteService.java
@@ -0,0 +1,183 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.api;
+
+import com.google.common.annotations.Beta;
+import org.onlab.packet.IpAddress;
+import org.onosproject.event.ListenerService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * A service interface for maintaining multicast information.
+ */
+@Beta
+public interface MulticastRouteService
+ extends ListenerService<McastEvent, McastListener> {
+
+ /**
+ * Adds an empty route to the information base for the given group IP.
+ *
+ * @param route a multicast route
+ */
+ void add(McastRoute route);
+
+ /**
+ * Removes a route from the information base.
+ *
+ * @param route a multicast route
+ */
+ void remove(McastRoute route);
+
+ /**
+ * Gets all multicast routes in the system.
+ *
+ * @return set of multicast routes
+ */
+ Set<McastRoute> getRoutes();
+
+ /**
+ * Gets a multicast route in the system.
+ *
+ * @param groupIp multicast group IP address
+ * @param sourceIp multicasto source Ip address
+ * @return set of multicast routes
+ */
+ Optional<McastRoute> getRoute(IpAddress groupIp, IpAddress sourceIp);
+
+ /**
+ * Adds a set of source to the route from where the
+ * data stream is originating.
+ *
+ * @param route the multicast route
+ * @param sources a set of sources
+ */
+ void addSources(McastRoute route, Set<ConnectPoint> sources);
+
+ /**
+ * Removes all the sources from the route.
+ *
+ * @param route the multicast route
+ */
+ void removeSources(McastRoute route);
+
+ /**
+ * Removes a set of sources from the route.
+ *
+ * @param route the multicast route
+ * @param sources a set of sources
+ */
+ void removeSources(McastRoute route, Set<ConnectPoint> sources);
+
+ /**
+ * Adds a set of sink to the route to which a data stream should be
+ * sent to.
+ *
+ * @param route a multicast route
+ * @param hostId a sink host
+ */
+ void addSink(McastRoute route, HostId hostId);
+
+ /**
+ * Adds a set of sink to the route to which a data stream should be
+ * sent to. If this method is used this the connect points will all
+ * be used a sink for that Mcast Tree. For dual-homed sinks please use
+ * {@link #addSink(McastRoute route, HostId hostId) addSink}.
+ *
+ * @param route a multicast route
+ * @param sinks a set of sink connect point
+ */
+ void addSink(McastRoute route, Set<ConnectPoint> sinks);
+
+ /**
+ * Removes all the sinks from the route.
+ *
+ * @param route the multicast route
+ */
+ void removeSinks(McastRoute route);
+
+ /**
+ * Removes a sink host from the route.
+ *
+ * @param route the multicast route
+ * @param hostId a sink host
+ */
+ void removeSink(McastRoute route, HostId hostId);
+
+ /**
+ * Removes a set of sink connect points for a given host the route.
+ *
+ * @param route the multicast route
+ * @param hostId a sink host
+ * @param connectPoints a given set of connect points to remove
+ */
+ void removeSinks(McastRoute route, HostId hostId, Set<ConnectPoint> connectPoints);
+
+ /**
+ * Removes a set of sinks to the route to which a data stream should be
+ * sent to. If this method is used the mcast tree does not work
+ * for any other sink until it's added. For dual-homed sinks please use
+ * {@link #removeSink(McastRoute route, HostId hostId) removeSink}.
+ *
+ * @param route a multicast route
+ * @param sink a sink connect point
+ */
+ void removeSinks(McastRoute route, Set<ConnectPoint> sink);
+
+ /**
+ * Return the Data for this route.
+ *
+ * @param route route
+ * @return the mcast route data
+ */
+ McastRouteData routeData(McastRoute route);
+
+ /**
+ * Find the data source association for this multicast route.
+ *
+ * @param route a multicast route
+ * @return a connect point
+ */
+ Set<ConnectPoint> sources(McastRoute route);
+
+ /**
+ * Find the list of sinks for this route.
+ *
+ * @param route a multicast route
+ * @return a list of connect points
+ */
+ Set<ConnectPoint> sinks(McastRoute route);
+
+ /**
+ * Find the list of sinks for a given host for this route.
+ *
+ * @param route a multicast route
+ * @param hostId the host
+ * @return a list of connect points
+ */
+ Set<ConnectPoint> sinks(McastRoute route, HostId hostId);
+
+ /**
+ * Obtains all the non host specific sinks for a multicast route.
+ *
+ * @param route a multicast route
+ * @return a set of sinks
+ */
+ Set<ConnectPoint> nonHostSinks(McastRoute route);
+}
diff --git a/apps/mcast/api/src/main/java/org/onosproject/mcast/api/package-info.java b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/package-info.java
new file mode 100644
index 0000000..bf4a398
--- /dev/null
+++ b/apps/mcast/api/src/main/java/org/onosproject/mcast/api/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 & related services API definitions.
+ */
+package org.onosproject.mcast.api;
diff --git a/apps/mcast/app/app.xml b/apps/mcast/app/app.xml
new file mode 100644
index 0000000..fabf8e2
--- /dev/null
+++ b/apps/mcast/app/app.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<app name="org.onosproject.mcast" origin="ONF" version="${project.version}"
+ category="Traffic Engineering" url="" title="Multicast App"
+ featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
+ features="${project.artifactId}">
+ <description>${project.description}</description>
+ <artifact>mvn:${project.groupId}/onos-app-mcast-api/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-app-mcast-impl/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-app-mcast-web/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-app-mcast-cli/${project.version}</artifact>
+</app>
diff --git a/apps/mcast/app/features.xml b/apps/mcast/app/features.xml
new file mode 100644
index 0000000..2e850ee
--- /dev/null
+++ b/apps/mcast/app/features.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ~ 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.
+ -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
+ <feature name="${project.artifactId}" version="${project.version}"
+ description="${project.description}">
+ <feature>onos-api</feature>
+ <feature>onos-drivers-default</feature>
+ <bundle>mvn:${project.groupId}/onos-app-mcast-api/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-app-mcast-impl/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-app-mcast-web/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-app-mcast-cli/${project.version}</bundle>
+ </feature>
+</features>
diff --git a/apps/mcast/app/pom.xml b/apps/mcast/app/pom.xml
new file mode 100644
index 0000000..48addc6
--- /dev/null
+++ b/apps/mcast/app/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <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-pkg</artifactId>
+ <packaging>pom</packaging>
+
+ <description>ONOS Multicast handling application</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-mcast-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-mcast-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-mcast-web</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-mcast-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/apps/mcast/cli/BUCK b/apps/mcast/cli/BUCK
new file mode 100644
index 0000000..df9991a
--- /dev/null
+++ b/apps/mcast/cli/BUCK
@@ -0,0 +1,16 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:org.apache.karaf.shell.console',
+ '//cli:onos-cli',
+ '//utils/rest:onlab-rest',
+ '//lib:javax.ws.rs-api',
+ '//utils/osgi:onlab-osgi',
+ '//core/store/serializers:onos-core-serializers',
+ '//apps/mcast/api:onos-apps-mcast-api'
+]
+
+
+osgi_jar_with_tests (
+ deps = COMPILE_DEPS,
+ import_packages = '*,org.onosproject.cli.net',
+)
diff --git a/apps/mcast/cli/pom.xml b/apps/mcast/cli/pom.xml
new file mode 100644
index 0000000..7af05c6
--- /dev/null
+++ b/apps/mcast/cli/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ 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-cli</artifactId>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</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-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastHostDeleteCommand.java b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastHostDeleteCommand.java
new file mode 100644
index 0000000..6d872e8
--- /dev/null
+++ b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastHostDeleteCommand.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2016-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.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.onlab.packet.IpAddress;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.mcast.api.McastRoute;
+import org.onosproject.mcast.api.MulticastRouteService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Deletes a multicast route.
+ */
+@Command(scope = "onos", name = "mcast-host-delete",
+ description = "Delete a multicast route flow")
+public class McastHostDeleteCommand extends AbstractShellCommand {
+
+ // Delete format for group line
+ private static final String D_FORMAT_MAPPING = "Deleted the mcast route: " +
+ "origin=%s, group=%s, source=%s";
+
+ // Update format for group line
+ private static final String U_FORMAT_MAPPING = "Updated the mcast route: " +
+ "origin=%s, group=%s, source=%s";
+
+ @Option(name = "-sAddr", aliases = "--sourceAddress",
+ description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
+ valueToShowInHelp = "1.1.1.1",
+ required = true, multiValued = false)
+ String sAddr = null;
+
+ @Option(name = "-gAddr", aliases = "--groupAddress",
+ description = "IP Address of the multicast group",
+ valueToShowInHelp = "224.0.0.0",
+ required = true, multiValued = false)
+ String gAddr = null;
+
+ @Option(name = "-h", aliases = "--host",
+ description = "Host sink format: MAC/VLAN",
+ valueToShowInHelp = "00:00:00:00:00:00/None")
+ String host = null;
+
+ @Option(name = "-cps", aliases = "--connectPoint",
+ description = "Egress port of:XXXXXXXXXX/XX",
+ valueToShowInHelp = "of:0000000000000001/1",
+ multiValued = true)
+ String[] egressList = null;
+
+
+ @Override
+ protected void execute() {
+ MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
+
+ if ("*".equals(sAddr) && "*".equals(gAddr)) {
+ // Clear all routes
+ mcastRouteManager.getRoutes().forEach(mcastRouteManager::remove);
+ return;
+ }
+ if (host != null && host.isEmpty()) {
+ print("Please provide a non-empty host Id");
+ return;
+ }
+ print("%s", host);
+ HostId hostId = HostId.hostId(host);
+ McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr),
+ IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
+ if (!mcastRouteManager.getRoutes().contains(mRoute)) {
+ print("Route is not present, store it first");
+ print(U_FORMAT_MAPPING, mRoute.type(), mRoute.group(), mRoute.source());
+ return;
+ }
+ if (host != null && egressList != null) {
+ Set<ConnectPoint> sinksSet = Arrays.stream(egressList)
+ .map(ConnectPoint::deviceConnectPoint)
+ .collect(Collectors.toSet());
+ mcastRouteManager.removeSinks(mRoute, hostId, sinksSet);
+ } else if (host != null) {
+ mcastRouteManager.removeSink(mRoute, hostId);
+ }
+ print(U_FORMAT_MAPPING, mRoute.type(), mRoute.group(), mRoute.source());
+ print("%s", mcastRouteManager.routeData(mRoute));
+ }
+}
diff --git a/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastHostJoinCommand.java b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastHostJoinCommand.java
new file mode 100644
index 0000000..1391822
--- /dev/null
+++ b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastHostJoinCommand.java
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.onosproject.mcast.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.onlab.packet.IpAddress;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.mcast.api.McastRoute;
+import org.onosproject.mcast.api.McastRouteData;
+import org.onosproject.mcast.api.MulticastRouteService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Installs a source, multicast group flow.
+ */
+@Command(scope = "onos", name = "mcast-host-join",
+ description = "Installs a source, multicast group flow")
+public class McastHostJoinCommand extends AbstractShellCommand {
+
+ // Format for group line
+ private static final String FORMAT_MAPPING = "Added the mcast route: " +
+ "origin=%s, group=%s, source=%s";
+
+ @Option(name = "-sAddr", aliases = "--sourceAddress",
+ description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
+ valueToShowInHelp = "1.1.1.1",
+ required = true, multiValued = false)
+ String sAddr = null;
+
+ @Option(name = "-gAddr", aliases = "--groupAddress",
+ description = "IP Address of the multicast group",
+ valueToShowInHelp = "224.0.0.0",
+ required = true, multiValued = false)
+ String gAddr = null;
+
+ @Option(name = "-srcs", aliases = "--sources",
+ description = "Ingress port of:XXXXXXXXXX/XX",
+ valueToShowInHelp = "of:0000000000000001/1",
+ multiValued = true)
+ String[] sources = null;
+
+ @Option(name = "-sinks",
+ aliases = "--hostsinks",
+ description = "Host sink format: MAC/VLAN",
+ valueToShowInHelp = "00:00:00:00:00:00/None",
+ multiValued = true)
+ String[] hosts = null;
+
+ @Override
+ protected void execute() {
+ MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
+
+ IpAddress sAddrIp = null;
+ //If the source Ip is * we want ASM so we leave it as null and the route will have it as an optional.empty()
+ if (!sAddr.equals("*")) {
+ sAddrIp = IpAddress.valueOf(sAddr);
+ }
+
+ McastRoute mRoute = new McastRoute(sAddrIp, IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
+ log.info("Route {}", mRoute);
+ mcastRouteManager.add(mRoute);
+
+ if (sources != null) {
+ Set<ConnectPoint> sourcesSet = Arrays.stream(sources)
+ .map(ConnectPoint::deviceConnectPoint)
+ .collect(Collectors.toSet());
+ log.info("{}", sourcesSet);
+ mcastRouteManager.addSources(mRoute, sourcesSet);
+ }
+
+ if (hosts != null) {
+ for (String hostId : hosts) {
+ mcastRouteManager.addSink(mRoute, HostId.hostId(hostId));
+
+ }
+ }
+ printMcastRoute(mRoute);
+ printMcastRouteData(mcastRouteManager.routeData(mRoute));
+ }
+
+ private void printMcastRoute(McastRoute mcastRoute) {
+ print(FORMAT_MAPPING, mcastRoute.type(), mcastRoute.group(), mcastRoute.source());
+ }
+
+ private void printMcastRouteData(McastRouteData mcastRouteData) {
+ print("%s", mcastRouteData);
+ }
+}
diff --git a/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastShowHostCommand.java b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastShowHostCommand.java
new file mode 100644
index 0000000..562afad
--- /dev/null
+++ b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastShowHostCommand.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2016-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.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onlab.packet.IpAddress;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.mcast.api.McastRoute;
+import org.onosproject.mcast.api.MulticastRouteService;
+import org.onosproject.net.ConnectPoint;
+
+import java.util.Comparator;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+
+/**
+ * Displays the source, multicast group flows entries.
+ */
+@Command(scope = "onos", name = "mcast-host-show", description = "Displays the source, multicast group flows")
+public class McastShowHostCommand extends AbstractShellCommand {
+
+ // Format for group line
+ private static final String FORMAT_MAPPING = "origin=%s, group=%s, source=%s, sinks=%s";
+
+ @Argument(index = 0, name = "mcastIp", description = "mcast Ip",
+ required = false, multiValued = false)
+ String mcastIp;
+
+ @Override
+ protected void execute() {
+ // Get the service
+ MulticastRouteService mcastService = get(MulticastRouteService.class);
+ // Get the routes
+ Set<McastRoute> routes = mcastService.getRoutes();
+ // Verify mcast group
+ if (!isNullOrEmpty(mcastIp)) {
+ // Let's find the group
+ IpAddress mcastGroup = IpAddress.valueOf(mcastIp);
+ McastRoute mcastRoute = routes.stream()
+ .filter(route -> route.group().equals(mcastGroup))
+ .findAny().orElse(null);
+ // If it exists
+ if (mcastRoute != null) {
+ // Get the sinks and print info
+ Set<ConnectPoint> sinks = mcastService.sinks(mcastRoute);
+ Set<ConnectPoint> sources = mcastService.sources(mcastRoute);
+ print(FORMAT_MAPPING, mcastRoute.type(), mcastRoute.group(),
+ sources, sinks);
+ }
+ return;
+ }
+ // Filter ipv4
+ Set<McastRoute> ipv4Routes = routes.stream()
+ .filter(mcastRoute -> mcastRoute.group().isIp4())
+ .collect(Collectors.toSet());
+ // Print ipv4 first
+ ipv4Routes.stream()
+ .sorted(Comparator.comparing(McastRoute::group))
+ .forEach(route -> {
+ // Get sinks
+ Set<ConnectPoint> sinks = mcastService.sinks(route);
+ Set<ConnectPoint> sources = mcastService.sources(route);
+ print(FORMAT_MAPPING, route.type(), route.group(),
+ sources, sinks);
+ });
+ // Filter ipv6
+ Set<McastRoute> ipv6Routes = routes.stream()
+ .filter(mcastRoute -> mcastRoute.group().isIp6())
+ .collect(Collectors.toSet());
+ // Then print ipv6
+ ipv6Routes.stream()
+ .sorted(Comparator.comparing(McastRoute::group))
+ .forEach(route -> {
+ // Get sinks
+ Set<ConnectPoint> sinks = mcastService.sinks(route);
+ Set<ConnectPoint> sources = mcastService.sources(route);
+ print(FORMAT_MAPPING, route.type(), route.group(),
+ sources, sinks);
+ });
+ }
+
+}
diff --git a/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastSourceDeleteCommand.java b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastSourceDeleteCommand.java
new file mode 100644
index 0000000..d85e155
--- /dev/null
+++ b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/McastSourceDeleteCommand.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2016-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.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.onlab.packet.IpAddress;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.mcast.api.McastRoute;
+import org.onosproject.mcast.api.MulticastRouteService;
+import org.onosproject.net.ConnectPoint;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Deletes a multicast route.
+ */
+@Command(scope = "onos", name = "mcast-source-delete",
+ description = "Delete a multicast route flow")
+public class McastSourceDeleteCommand extends AbstractShellCommand {
+
+ // Delete format for group line
+ private static final String D_FORMAT_MAPPING = "Deleted the mcast route: " +
+ "origin=%s, group=%s, source=%s";
+
+ // Update format for group line
+ private static final String U_FORMAT_MAPPING = "Updated the mcast route: " +
+ "origin=%s, group=%s, source=%s";
+
+ @Option(name = "-sAddr", aliases = "--sourceAddress",
+ description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
+ valueToShowInHelp = "1.1.1.1",
+ required = true, multiValued = false)
+ String sAddr = null;
+
+ @Option(name = "-gAddr", aliases = "--groupAddress",
+ description = "IP Address of the multicast group",
+ valueToShowInHelp = "224.0.0.0",
+ required = true, multiValued = false)
+ String gAddr = null;
+
+ @Option(name = "-src", aliases = "--connectPoint",
+ description = "Source port of:XXXXXXXXXX/XX",
+ valueToShowInHelp = "of:0000000000000001/1",
+ multiValued = true)
+ String[] sourceList = null;
+
+
+ @Override
+ protected void execute() {
+ MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
+
+ if ("*".equals(sAddr) && "*".equals(gAddr)) {
+ // Clear all routes
+ mcastRouteManager.getRoutes().forEach(mcastRouteManager::remove);
+ return;
+ }
+
+ McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr),
+ IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
+ if (!mcastRouteManager.getRoutes().contains(mRoute)) {
+ print("Route is not present, store it first");
+ print("origin=%s, group=%s, source=%s", mRoute.type(), mRoute.group(), mRoute.source());
+ return;
+ }
+ if (sourceList == null) {
+ mcastRouteManager.remove(mRoute);
+ print(D_FORMAT_MAPPING, mRoute.type(), mRoute.group(), mRoute.source());
+ return;
+ }
+
+ Set<ConnectPoint> sourcesSet = Arrays.stream(sourceList)
+ .map(ConnectPoint::deviceConnectPoint)
+ .collect(Collectors.toSet());
+ mcastRouteManager.removeSources(mRoute, sourcesSet);
+ print(U_FORMAT_MAPPING, mRoute.type(), mRoute.group(), mRoute.source());
+ print("%s", mcastRouteManager.routeData(mRoute));
+ }
+}
diff --git a/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/package-info.java b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/package-info.java
new file mode 100644
index 0000000..7cedb77
--- /dev/null
+++ b/apps/mcast/cli/src/main/java/org/onosproject/mcast/cli/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.
+ */
+
+/**
+ * CLI implementation for mcast.
+ */
+package org.onosproject.mcast.cli;
diff --git a/apps/mcast/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/mcast/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 0000000..7ab4273
--- /dev/null
+++ b/apps/mcast/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,49 @@
+<!--
+~ 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+
+ <command>
+ <action class="org.onosproject.mcast.cli.McastHostJoinCommand"/>
+ <optional-completers>
+ <entry key="-srcs" value-ref="deviceIdCompleter"/>
+ <entry key="-sinks" value-ref="hostIdCompleter"/>
+ </optional-completers>
+ </command>
+ <command>
+ <action class="org.onosproject.mcast.cli.McastShowHostCommand"/>
+ </command>
+ <command>
+ <action class="org.onosproject.mcast.cli.McastHostDeleteCommand"/>
+ <optional-completers>
+ <entry key="-cps" value-ref="deviceIdCompleter"/>
+ <entry key="-h" value-ref="hostIdCompleter"/>
+ </optional-completers>
+ </command>
+ <command>
+ <action class="org.onosproject.mcast.cli.McastSourceDeleteCommand"/>
+ <optional-completers>
+ <entry key="-src" value-ref="deviceIdCompleter"/>
+ </optional-completers>
+ </command>
+
+ </command-bundle>
+
+ <bean id="hostIdCompleter" class="org.onosproject.cli.net.HostIdCompleter"/>
+ <bean id="deviceIdCompleter" class="org.onosproject.cli.net.DeviceIdCompleter"/>
+
+</blueprint>
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;
diff --git a/apps/mcast/pom.xml b/apps/mcast/pom.xml
new file mode 100644
index 0000000..d80bdec
--- /dev/null
+++ b/apps/mcast/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ 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 xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.12.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-app-mcast</artifactId>
+ <packaging>pom</packaging>
+
+ <description>ONOS multicast applications</description>
+
+ <modules>
+ <module>impl</module>
+ <module>web</module>
+ <module>cli</module>
+ <module>api</module>
+ <module>app</module>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava-testlib</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/apps/mcast/web/BUCK b/apps/mcast/web/BUCK
new file mode 100644
index 0000000..c036dc0
--- /dev/null
+++ b/apps/mcast/web/BUCK
@@ -0,0 +1,19 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:JACKSON',
+ '//utils/rest:onlab-rest',
+ '//lib:javax.ws.rs-api',
+]
+
+TEST_DEPS = [
+ '//lib:TEST_ADAPTERS',
+ '//lib:jersey-test-framework-core',
+ '//lib:jersey-test-framework-jetty',
+ '//utils/osgi:onlab-osgi-tests',
+ '//web/api:onos-rest-tests',
+]
+
+osgi_jar_with_tests (
+ deps = COMPILE_DEPS,
+ test_deps = TEST_DEPS,
+)
diff --git a/apps/mcast/web/pom.xml b/apps/mcast/web/pom.xml
new file mode 100644
index 0000000..27eb9d8
--- /dev/null
+++ b/apps/mcast/web/pom.xml
@@ -0,0 +1,118 @@
+<?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-web</artifactId>
+ <packaging>bundle</packaging>
+ <properties>
+ <web.context>/onos/v1/mcast</web.context>
+ <api.version>1.0.0</api.version>
+ <api.title>ONOS Multicast Application REST API</api.title>
+ <api.description>
+ APIs for interacting with the Multicast application.
+ </api.description>
+ <api.package>org.onosproject.mcast.web</api.package>
+ </properties>
+
+ <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-incubator-api</artifactId>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-common</artifactId>
+ <scope>test</scope>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-rest</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-rest</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.test-framework</groupId>
+ <artifactId>jersey-test-framework-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_wab>src/main/webapp/</_wab>
+ <Include-Resource>
+ WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
+ {maven-resources}
+ </Include-Resource>
+ <Bundle-SymbolicName>
+ ${project.groupId}.${project.artifactId}
+ </Bundle-SymbolicName>
+ <Import-Package>
+ *,org.glassfish.jersey.servlet
+ </Import-Package>
+ <Web-ContextPath>${web.context}</Web-ContextPath>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/apps/mcast/web/src/main/java/org/onosproject/mcast/web/McastRouteWebResource.java b/apps/mcast/web/src/main/java/org/onosproject/mcast/web/McastRouteWebResource.java
new file mode 100644
index 0000000..c198a66
--- /dev/null
+++ b/apps/mcast/web/src/main/java/org/onosproject/mcast/web/McastRouteWebResource.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017-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.web;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.rest.AbstractWebResource;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * Manage the multicast routing information.
+ */
+@Beta
+@Path("mcast")
+public class McastRouteWebResource extends AbstractWebResource {
+
+ /**
+ * Get all multicast routes.
+ * Returns array of all known multicast routes.
+ *
+ * @return 200 OK with array of all known multicast routes
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getRoutes() {
+ return Response.noContent().build();
+ }
+
+}
diff --git a/apps/mcast/web/src/main/java/org/onosproject/mcast/web/package-info.java b/apps/mcast/web/src/main/java/org/onosproject/mcast/web/package-info.java
new file mode 100644
index 0000000..6b4bfa1
--- /dev/null
+++ b/apps/mcast/web/src/main/java/org/onosproject/mcast/web/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 web support.
+ */
+package org.onosproject.mcast.web;
diff --git a/apps/mcast/web/src/main/webapp/WEB-INF/web.xml b/apps/mcast/web/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..27b89ec
--- /dev/null
+++ b/apps/mcast/web/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Copyright 2017-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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="ONOS" version="2.5">
+ <display-name>Mcast REST API v1.0</display-name>
+
+ <servlet>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>jersey.config.server.provider.classnames</param-name>
+ <param-value>
+ org.onosproject.mcast.web.McastRouteWebResource</param-value>
+ </init-param>
+ <load-on-startup>10</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
diff --git a/apps/pom.xml b/apps/pom.xml
index 714021f..9712971 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -101,6 +101,7 @@
<module>routeradvertisement</module>
<module>simplefabric</module>
<module>odtn</module>
+ <module>mcast</module>
</modules>
<properties>
diff --git a/modules.defs b/modules.defs
index f995044..9611f17 100644
--- a/modules.defs
+++ b/modules.defs
@@ -239,6 +239,7 @@
'//apps/kafka-integration:onos-apps-kafka-integration-oar',
'//apps/rabbitmq:onos-apps-rabbitmq-oar',
'//apps/odtn:onos-apps-odtn-oar',
+ '//apps/mcast:onos-apps-mcast-oar',
]
PROTOCOL_APPS = [