本文整理汇总了Java中org.onosproject.net.mcast.McastRoute类的典型用法代码示例。如果您正苦于以下问题:Java McastRoute类的具体用法?Java McastRoute怎么用?Java McastRoute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
McastRoute类属于org.onosproject.net.mcast包,在下文中一共展示了McastRoute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRoute
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
/**
* Create new multicast route.
* Creates a new route in the multicast RIB.
*
* @onos.rsModel McastRoutePost
* @param stream multicast route JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createRoute(InputStream stream) {
MulticastRouteService service = get(MulticastRouteService.class);
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
McastRoute route = codec(McastRoute.class).decode(jsonTree, this);
service.add(route);
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response
.created(URI.create(""))
.build();
}
示例2: testMcastRoutePopulatedArray
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
/**
* Tests the results of the REST API GET when there are active mcastroutes.
*/
@Test
public void testMcastRoutePopulatedArray() {
initMcastRouteMocks();
final Set<McastRoute> mcastRoutes = ImmutableSet.of(route1, route2, route3);
expect(mockMulticastRouteService.getRoutes()).andReturn(mcastRoutes).anyTimes();
replay(mockMulticastRouteService);
final WebTarget wt = target();
final String response = wt.path("mcast").request().get(String.class);
final JsonObject result = Json.parse(response).asObject();
assertThat(result, notNullValue());
assertThat(result.names(), hasSize(1));
assertThat(result.names().get(0), is("routes"));
final JsonArray jsonMcastRoutes = result.get("routes").asArray();
assertThat(jsonMcastRoutes, notNullValue());
assertThat(jsonMcastRoutes, hasMcastRoute(route1));
assertThat(jsonMcastRoutes, hasMcastRoute(route2));
assertThat(jsonMcastRoutes, hasMcastRoute(route3));
}
示例3: activate
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
@Activate
public void activate() {
mcastRib = storageService.<McastRoute, MulticastData>consistentMapBuilder()
.withName(MCASTRIB)
.withSerializer(Serializer.using(KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(
AtomicReference.class,
MulticastData.class,
McastRoute.class,
McastRoute.Type.class
).build()))
//.withRelaxedReadConsistency()
.build();
mcastRib.addListener(mcastMapListener);
mcastRoutes = mcastRib.asJavaMap();
log.info("Started");
}
示例4: storeSink
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
@Override
public void storeSink(McastRoute route, ConnectPoint sink, Type operation) {
MulticastData data = mcastRoutes.compute(route, (k, v) -> {
switch (operation) {
case ADD:
if (v == null) {
v = MulticastData.empty();
}
v.appendSink(sink);
break;
case REMOVE:
if (v != null) {
v.removeSink(sink);
}
break;
default:
log.warn("Unknown mcast operation type: {}", operation);
}
return v;
});
}
示例5: execute
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
@Override
protected void execute() {
MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
//McastRoute mRoute = McastForwarding.createStaticRoute(sAddr, gAddr);
McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr),
IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
mcastRouteManager.add(mRoute);
if (ingressPort != null) {
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressPort);
mcastRouteManager.addSource(mRoute, ingress);
}
if (ports != null) {
for (String egCP : ports) {
log.debug("Egress port provided: " + egCP);
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egCP);
mcastRouteManager.addSink(mRoute, egress);
}
}
print("Added the mcast route: %s", mRoute);
}
示例6: execute
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
@Override
protected void execute() {
MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
if (sAddr.equals("*") && gAddr.equals("*")) {
// Clear all routes
mcastRouteManager.getRoutes().forEach(mcastRouteManager::remove);
return;
}
McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr),
IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
if (egressList == null) {
mcastRouteManager.remove(mRoute);
} else {
// check list for validity before we begin to delete.
for (String egress : egressList) {
ConnectPoint eCp = ConnectPoint.deviceConnectPoint(egress);
mcastRouteManager.removeSink(mRoute, eCp);
}
}
}
示例7: createRoute
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
/**
* Create new multicast route.
* Creates a new route in the multicast RIB.
*
* @onos.rsModel McastRoutePost
* @param stream multicast route JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createRoute(InputStream stream) {
final String ingressStr = "ingress";
MulticastRouteService service = get(MulticastRouteService.class);
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
McastRoute route = codec(McastRoute.class).decode(jsonTree, this);
service.add(route);
if (jsonTree.has(ingressStr)) {
String ingressPathStr = jsonTree.path(ingressStr).asText();
ConnectPoint ingressConnectPoint = nullIsNotFound(ConnectPoint.deviceConnectPoint(ingressPathStr),
"ingress connection point cannot be null!");
service.addSource(route, ingressConnectPoint);
}
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response
.created(URI.create(""))
.build();
}
示例8: addSinks
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
/**
* Create a sink for a multicast route.
* Creates a new sink for an existing multicast route.
*
* @onos.rsModel McastSinkPost
* @param group group IP address
* @param source source IP address
* @param stream sink JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("sinks/{group}/{source}")
public Response addSinks(@PathParam("group") String group,
@PathParam("source") String source,
InputStream stream) {
MulticastRouteService service = get(MulticastRouteService.class);
try {
McastRoute route = new McastRoute(IpAddress.valueOf(source), IpAddress.valueOf(group),
McastRoute.Type.STATIC);
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
jsonTree.path("sinks").forEach(node -> {
ConnectPoint sink = ConnectPoint.deviceConnectPoint(node.asText());
service.addSink(route, sink);
});
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response
.created(URI.create(""))
.build();
}
示例9: execute
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
@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 (egressList == null) {
mcastRouteManager.remove(mRoute);
} else {
// check list for validity before we begin to delete.
for (String egress : egressList) {
ConnectPoint eCp = ConnectPoint.deviceConnectPoint(egress);
mcastRouteManager.removeSink(mRoute, eCp);
}
}
}
示例10: activate
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
@Activate
public void activate() {
mcastRib = storageService.<McastRoute, MulticastData>consistentMapBuilder()
.withName(MCASTRIB)
.withSerializer(Serializer.using(KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(
AtomicReference.class,
MulticastData.class,
McastRoute.class,
McastRoute.Type.class
).build()))
.build();
mcastRoutes = mcastRib.asJavaMap();
mcastRib.addListener(mcastRouteListener);
log.info("Started");
}
示例11: getRoutes
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
/**
* Get all multicast routes.
* Returns array of all known multicast routes.
*
* @return 200 OK with array of all known multicast routes
* @onos.rsModel McastRoutesGet
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getRoutes() {
Set<McastRoute> routes = get(MulticastRouteService.class).getRoutes();
ObjectNode root = encodeArray(McastRoute.class, "routes", routes);
return ok(root).build();
}
示例12: deleteRoute
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
/**
* Remove a multicast route.
* Removes a route from the multicast RIB.
*
* @param stream multicast route JSON
* @return 204 NO CONTENT
* @onos.rsModel McastRoutePost
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public Response deleteRoute(InputStream stream) {
MulticastRouteService service = get(MulticastRouteService.class);
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
McastRoute route = codec(McastRoute.class).decode(jsonTree, this);
service.remove(route);
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response.noContent().build();
}
示例13: initMcastRouteMocks
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
private void initMcastRouteMocks() {
IpAddress source1 = IpAddress.valueOf("1.1.1.1");
IpAddress source2 = IpAddress.valueOf("2.2.2.2");
IpAddress source3 = IpAddress.valueOf("3.3.3.3");
IpAddress group = IpAddress.valueOf("224.0.0.1");
route1 = new McastRoute(source1, group, McastRoute.Type.PIM);
route2 = new McastRoute(source2, group, McastRoute.Type.IGMP);
route3 = new McastRoute(source3, group, McastRoute.Type.STATIC);
}
示例14: addSink
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
@Override
public void addSink(McastRoute route, ConnectPoint connectPoint) {
checkNotNull(route, "Route cannot be null");
checkNotNull(connectPoint, "Sink cannot be null");
store.storeSink(route, connectPoint, McastStore.Type.ADD);
}
示例15: removeSink
import org.onosproject.net.mcast.McastRoute; //导入依赖的package包/类
@Override
public void removeSink(McastRoute route, ConnectPoint connectPoint) {
checkNotNull(route, "Route cannot be null");
checkNotNull(connectPoint, "Sink cannot be null");
store.storeSink(route, connectPoint, McastStore.Type.REMOVE);
}