use of org.onosproject.mcast.api.MulticastRouteService in project onos by opennetworkinglab.
the class McastRouteWebResource method addHostSinks.
/**
* Adds a new sink for an existing host in a given multicast route.
*
* @param group group IP address
* @param srcIp source IP address
* @param hostId the host Id
* @param stream sink connect points JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel McastHostSinksAdd
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("sinks/{group}/{srcIp}/{hostId}")
public Response addHostSinks(@PathParam("group") String group, @PathParam("srcIp") String srcIp, @PathParam("hostId") String hostId, InputStream stream) {
MulticastRouteService service = get(MulticastRouteService.class);
Optional<McastRoute> route = getMcastRoute(group, srcIp);
if (route.isPresent()) {
ArrayNode jsonTree;
try {
jsonTree = (ArrayNode) mapper().readTree(stream).get(SINKS);
Set<ConnectPoint> sinks = new HashSet<>();
jsonTree.elements().forEachRemaining(src -> {
sinks.add(ConnectPoint.deviceConnectPoint(src.asText()));
});
if (!sinks.isEmpty()) {
service.addSinks(route.get(), HostId.hostId(hostId), sinks);
}
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
return Response.ok().build();
}
return Response.noContent().build();
}
use of org.onosproject.mcast.api.MulticastRouteService in project onos by opennetworkinglab.
the class McastRouteWebResource method addHostSource.
/**
* Adds a new set of connect points for an existing host source in a given multicast route.
*
* @param group group IP address
* @param srcIp source IP address
* @param hostId the host Id
* @param stream source connect points JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel McastHostSourcesAdd
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("source/{group}/{srcIp}/{hostId}")
public Response addHostSource(@PathParam("group") String group, @PathParam("srcIp") String srcIp, @PathParam("hostId") String hostId, InputStream stream) {
MulticastRouteService service = get(MulticastRouteService.class);
Optional<McastRoute> route = getMcastRoute(group, srcIp);
if (route.isPresent()) {
ArrayNode jsonTree;
try {
jsonTree = (ArrayNode) mapper().readTree(stream).get(SOURCES);
Set<ConnectPoint> sources = new HashSet<>();
jsonTree.elements().forEachRemaining(src -> {
sources.add(ConnectPoint.deviceConnectPoint(src.asText()));
});
if (!sources.isEmpty()) {
service.addSources(route.get(), HostId.hostId(hostId), sources);
}
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
return Response.ok().build();
}
return Response.noContent().build();
}
use of org.onosproject.mcast.api.MulticastRouteService in project onos by opennetworkinglab.
the class McastRouteWebResource method deleteRoutes.
/**
* Removes all the multicast routes.
*
* @return 204 NO CONTENT
*/
@DELETE
public Response deleteRoutes() {
MulticastRouteService service = get(MulticastRouteService.class);
service.getRoutes().forEach(service::remove);
return Response.noContent().build();
}
Aggregations