Jonathan Hart
Committed by Gerrit Code Review

Move multicast CLI commands into the core with the core mcast system.

Change-Id: If442803cf530cfeb949e7fbce34f74db082f30c1
1 -/**
2 - * Sample Multicast forwarding framework using intents.
3 - */
4 -package org.onosproject.mfwd.cli;
5 -
1 -<!--
2 - ~ Copyright 2014 Open Networking Laboratory
3 - ~
4 - ~ Licensed under the Apache License, Version 2.0 (the "License");
5 - ~ you may not use this file except in compliance with the License.
6 - ~ You may obtain a copy of the License at
7 - ~
8 - ~ http://www.apache.org/licenses/LICENSE-2.0
9 - ~
10 - ~ Unless required by applicable law or agreed to in writing, software
11 - ~ distributed under the License is distributed on an "AS IS" BASIS,
12 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - ~ See the License for the specific language governing permissions and
14 - ~ limitations under the License.
15 - -->
16 -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
17 -
18 - <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
19 - <command>
20 - <action class="org.onosproject.mfwd.cli.McastJoinCommand"/>
21 - </command>
22 - <command>
23 - <action class="org.onosproject.mfwd.cli.McastDeleteCommand"/>
24 - </command>
25 - <command>
26 - <action class="org.onosproject.mfwd.cli.McastShowCommand"/>
27 - </command>
28 - </command-bundle>
29 -
30 -</blueprint>
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,14 +13,12 @@ ...@@ -13,14 +13,12 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.mfwd.cli; 16 +package org.onosproject.cli.net;
17 17
18 -import org.apache.felix.scr.annotations.Reference;
19 -import org.apache.felix.scr.annotations.ReferenceCardinality;
20 import org.apache.karaf.shell.commands.Argument; 18 import org.apache.karaf.shell.commands.Argument;
21 import org.apache.karaf.shell.commands.Command; 19 import org.apache.karaf.shell.commands.Command;
20 +import org.onlab.packet.IpAddress;
22 import org.onosproject.cli.AbstractShellCommand; 21 import org.onosproject.cli.AbstractShellCommand;
23 -import org.onosproject.mfwd.impl.McastForwarding;
24 import org.onosproject.net.ConnectPoint; 22 import org.onosproject.net.ConnectPoint;
25 import org.onosproject.net.mcast.McastRoute; 23 import org.onosproject.net.mcast.McastRoute;
26 import org.onosproject.net.mcast.MulticastRouteService; 24 import org.onosproject.net.mcast.MulticastRouteService;
...@@ -32,9 +30,6 @@ import org.onosproject.net.mcast.MulticastRouteService; ...@@ -32,9 +30,6 @@ import org.onosproject.net.mcast.MulticastRouteService;
32 description = "Delete a multicast route flow") 30 description = "Delete a multicast route flow")
33 public class McastDeleteCommand extends AbstractShellCommand { 31 public class McastDeleteCommand extends AbstractShellCommand {
34 32
35 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
36 - MulticastRouteService mcastRouteManager = AbstractShellCommand.get(MulticastRouteService.class);
37 -
38 @Argument(index = 0, name = "sAddr", 33 @Argument(index = 0, name = "sAddr",
39 description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry", 34 description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
40 required = true, multiValued = false) 35 required = true, multiValued = false)
...@@ -53,8 +48,10 @@ public class McastDeleteCommand extends AbstractShellCommand { ...@@ -53,8 +48,10 @@ public class McastDeleteCommand extends AbstractShellCommand {
53 48
54 @Override 49 @Override
55 protected void execute() { 50 protected void execute() {
51 + MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
56 52
57 - McastRoute mRoute = McastForwarding.createStaticRoute(sAddr, gAddr); 53 + McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr),
54 + IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
58 55
59 if (egressList == null) { 56 if (egressList == null) {
60 mcastRouteManager.remove(mRoute); 57 mcastRouteManager.remove(mRoute);
......
1 /* 1 /*
2 - * Copyright 2014-2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,14 +13,12 @@ ...@@ -13,14 +13,12 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.mfwd.cli; 16 +package org.onosproject.cli.net;
17 17
18 -import org.apache.felix.scr.annotations.Reference;
19 -import org.apache.felix.scr.annotations.ReferenceCardinality;
20 import org.apache.karaf.shell.commands.Argument; 18 import org.apache.karaf.shell.commands.Argument;
21 import org.apache.karaf.shell.commands.Command; 19 import org.apache.karaf.shell.commands.Command;
20 +import org.onlab.packet.IpAddress;
22 import org.onosproject.cli.AbstractShellCommand; 21 import org.onosproject.cli.AbstractShellCommand;
23 -import org.onosproject.mfwd.impl.McastForwarding;
24 import org.onosproject.net.ConnectPoint; 22 import org.onosproject.net.ConnectPoint;
25 import org.onosproject.net.mcast.McastRoute; 23 import org.onosproject.net.mcast.McastRoute;
26 import org.onosproject.net.mcast.MulticastRouteService; 24 import org.onosproject.net.mcast.MulticastRouteService;
...@@ -32,9 +30,6 @@ import org.onosproject.net.mcast.MulticastRouteService; ...@@ -32,9 +30,6 @@ import org.onosproject.net.mcast.MulticastRouteService;
32 description = "Installs a source, multicast group flow") 30 description = "Installs a source, multicast group flow")
33 public class McastJoinCommand extends AbstractShellCommand { 31 public class McastJoinCommand extends AbstractShellCommand {
34 32
35 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
36 - MulticastRouteService mcastRouteManager = AbstractShellCommand.get(MulticastRouteService.class);
37 -
38 @Argument(index = 0, name = "sAddr", 33 @Argument(index = 0, name = "sAddr",
39 description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry", 34 description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
40 required = true, multiValued = false) 35 required = true, multiValued = false)
...@@ -57,19 +52,26 @@ public class McastJoinCommand extends AbstractShellCommand { ...@@ -57,19 +52,26 @@ public class McastJoinCommand extends AbstractShellCommand {
57 52
58 @Override 53 @Override
59 protected void execute() { 54 protected void execute() {
55 + MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
60 56
61 - McastRoute mRoute = McastForwarding.createStaticRoute(sAddr, gAddr); 57 + //McastRoute mRoute = McastForwarding.createStaticRoute(sAddr, gAddr);
58 + McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr),
59 + IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
62 mcastRouteManager.add(mRoute); 60 mcastRouteManager.add(mRoute);
63 61
64 - ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressPort); 62 + if (ingressPort != null) {
65 - mcastRouteManager.addSource(mRoute, ingress); 63 + ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressPort);
64 + mcastRouteManager.addSource(mRoute, ingress);
65 + }
66 66
67 - for (String egCP : ports) { 67 + if (ports != null) {
68 - log.debug("Egress port provided: " + egCP); 68 + for (String egCP : ports) {
69 - ConnectPoint egress = ConnectPoint.deviceConnectPoint(egCP); 69 + log.debug("Egress port provided: " + egCP);
70 - mcastRouteManager.addSink(mRoute, egress); 70 + ConnectPoint egress = ConnectPoint.deviceConnectPoint(egCP);
71 + mcastRouteManager.addSink(mRoute, egress);
71 72
73 + }
72 } 74 }
73 - print("Added the mcast route"); 75 + print("Added the mcast route: %s", mRoute);
74 } 76 }
75 } 77 }
......
1 /* 1 /*
2 - * Copyright 2014-2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,17 +13,15 @@ ...@@ -13,17 +13,15 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.mfwd.cli; 16 +package org.onosproject.cli.net;
17 17
18 -import org.apache.felix.scr.annotations.Reference;
19 -import org.apache.felix.scr.annotations.ReferenceCardinality;
20 import org.apache.karaf.shell.commands.Command; 18 import org.apache.karaf.shell.commands.Command;
21 -
22 import org.onosproject.cli.AbstractShellCommand; 19 import org.onosproject.cli.AbstractShellCommand;
23 - 20 +import org.onosproject.net.ConnectPoint;
21 +import org.onosproject.net.mcast.McastRoute;
24 import org.onosproject.net.mcast.MulticastRouteService; 22 import org.onosproject.net.mcast.MulticastRouteService;
25 -import org.slf4j.Logger; 23 +
26 -import static org.slf4j.LoggerFactory.getLogger; 24 +import java.util.Set;
27 25
28 /** 26 /**
29 * Displays the source, multicast group flows entries. 27 * Displays the source, multicast group flows entries.
...@@ -31,15 +29,20 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -31,15 +29,20 @@ import static org.slf4j.LoggerFactory.getLogger;
31 @Command(scope = "onos", name = "mcast-show", description = "Displays the source, multicast group flows") 29 @Command(scope = "onos", name = "mcast-show", description = "Displays the source, multicast group flows")
32 public class McastShowCommand extends AbstractShellCommand { 30 public class McastShowCommand extends AbstractShellCommand {
33 31
34 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 32 + private static final String FORMAT = "route=%s, source=%s, sinks=%s";
35 - MulticastRouteService mcastRouteManager = AbstractShellCommand.get(MulticastRouteService.class);
36 -
37 - private final Logger log = getLogger(getClass());
38 - private static final String MCAST_GROUP = "mcastgroup";
39 33
40 @Override 34 @Override
41 protected void execute() { 35 protected void execute() {
42 - //TODO 36 + MulticastRouteService mcastService = get(MulticastRouteService.class);
37 +
38 + Set<McastRoute> routes = mcastService.getRoutes();
39 +
40 + for (McastRoute route : routes) {
41 + Set<ConnectPoint> sinks = mcastService.fetchSinks(route);
42 + ConnectPoint source = mcastService.fetchSource(route);
43 +
44 + print(FORMAT, route, source, sinks);
45 + }
43 } 46 }
44 47
45 } 48 }
......
...@@ -93,6 +93,16 @@ ...@@ -93,6 +93,16 @@
93 </command> 93 </command>
94 94
95 <command> 95 <command>
96 + <action class="org.onosproject.cli.net.McastShowCommand"/>
97 + </command>
98 + <command>
99 + <action class="org.onosproject.cli.net.McastJoinCommand"/>
100 + </command>
101 + <command>
102 + <action class="org.onosproject.cli.net.McastDeleteCommand"/>
103 + </command>
104 +
105 + <command>
96 <action class="org.onosproject.cli.net.DriversListCommand"/> 106 <action class="org.onosproject.cli.net.DriversListCommand"/>
97 <completers> 107 <completers>
98 <ref component-id="driverNameCompleter"/> 108 <ref component-id="driverNameCompleter"/>
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.store.serializers; 16 package org.onosproject.store.serializers;
17 17
18 +import com.esotericsoftware.kryo.serializers.JavaSerializer;
18 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.ImmutableMap; 20 import com.google.common.collect.ImmutableMap;
20 import com.google.common.collect.ImmutableSet; 21 import com.google.common.collect.ImmutableSet;
...@@ -251,7 +252,7 @@ public final class KryoNamespaces { ...@@ -251,7 +252,7 @@ public final class KryoNamespaces {
251 .register(HashMap.class) 252 .register(HashMap.class)
252 .register(ConcurrentHashMap.class) 253 .register(ConcurrentHashMap.class)
253 .register(CopyOnWriteArraySet.class) 254 .register(CopyOnWriteArraySet.class)
254 - .register(Sets.newConcurrentHashSet().getClass()) 255 + .register(new JavaSerializer(), Sets.newConcurrentHashSet().getClass())
255 .register(ArrayList.class, 256 .register(ArrayList.class,
256 LinkedList.class, 257 LinkedList.class,
257 HashSet.class, 258 HashSet.class,
......
...@@ -62,7 +62,7 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD ...@@ -62,7 +62,7 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD
62 McastRoute.Type.class, 62 McastRoute.Type.class,
63 ConnectPoint.class 63 ConnectPoint.class
64 ).build())) 64 ).build()))
65 - .withRelaxedReadConsistency() 65 + //.withRelaxedReadConsistency()
66 .build(); 66 .build();
67 67
68 mcastRoutes = mcastRib.asJavaMap(); 68 mcastRoutes = mcastRib.asJavaMap();
......