use of org.onosproject.routeservice.RouteTableId in project onos by opennetworkinglab.
the class RoutesListCommand method doExecute.
@Override
protected void doExecute() {
RouteService service = AbstractShellCommand.get(RouteService.class);
if (outputJson()) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode result = mapper.createObjectNode();
result.set("routes4", json(service.getRoutes(new RouteTableId("ipv4"))));
result.set("routes6", json(service.getRoutes(new RouteTableId("ipv6"))));
print("%s", result);
} else {
print("B: Best route, R: Resolved route\n");
service.getRouteTables().forEach(id -> {
Collection<RouteInfo> tableRoutes = service.getRoutes(id);
String format = tableRoutes.stream().anyMatch(route -> route.prefix().isIp6()) ? FORMAT_ROUTE6 : FORMAT_ROUTE;
// Print header
print(FORMAT_TABLE, id);
print(format, "B", "R", NETWORK, NEXTHOP, SOURCE, NODE);
// Print routing entries
tableRoutes.stream().sorted(Comparator.comparing(r -> r.prefix().address())).forEach(route -> this.print(format, route));
print(FORMAT_TOTAL, tableRoutes.size());
print("");
});
}
}
use of org.onosproject.routeservice.RouteTableId in project onos by opennetworkinglab.
the class DistributedRouteStore method activate.
/**
* Sets up distributed route store.
*/
public void activate() {
routeTables = new ConcurrentHashMap<>();
executor = Executors.newSingleThreadExecutor(groupedThreads("onos/route", "store", log));
KryoNamespace masterRouteTableSerializer = KryoNamespace.newBuilder().register(RouteTableId.class).build();
masterRouteTable = storageService.<RouteTableId>setBuilder().withName("onos-master-route-table").withSerializer(Serializer.using(masterRouteTableSerializer)).build().asDistributedSet();
masterRouteTable.addListener(masterRouteTableListener);
// Add default tables (add is idempotent)
masterRouteTable.add(IPV4);
masterRouteTable.add(IPV6);
masterRouteTable.forEach(this::createRouteTable);
log.info("Started");
}
use of org.onosproject.routeservice.RouteTableId in project onos by opennetworkinglab.
the class LocalRouteStore method computeRouteTablesFromIps.
private Map<RouteTableId, Set<IpAddress>> computeRouteTablesFromIps(Collection<IpAddress> ipAddresses) {
Map<RouteTableId, Set<IpAddress>> computedTables = new HashMap<>();
ipAddresses.forEach(ipAddress -> {
RouteTableId routeTableId = (ipAddress.isIp4()) ? IPV4 : IPV6;
Set<IpAddress> tempIpAddresses = computedTables.computeIfAbsent(routeTableId, k -> Sets.newHashSet());
tempIpAddresses.add(ipAddress);
});
return computedTables;
}
use of org.onosproject.routeservice.RouteTableId in project onos by opennetworkinglab.
the class LocalRouteStore method computeRouteTablesFromRoutes.
private Map<RouteTableId, Set<Route>> computeRouteTablesFromRoutes(Collection<Route> routes) {
Map<RouteTableId, Set<Route>> computedTables = new HashMap<>();
routes.forEach(route -> {
RouteTableId routeTableId = (route.prefix().address().isIp4()) ? IPV4 : IPV6;
Set<Route> tempRoutes = computedTables.computeIfAbsent(routeTableId, k -> Sets.newHashSet());
tempRoutes.add(route);
});
return computedTables;
}
use of org.onosproject.routeservice.RouteTableId in project onos by opennetworkinglab.
the class DistributedRouteStore method computeRouteTablesFromRoutes.
private Map<RouteTableId, Set<Route>> computeRouteTablesFromRoutes(Collection<Route> routes) {
Map<RouteTableId, Set<Route>> computedTables = new HashMap<>();
routes.forEach(route -> {
RouteTableId routeTableId = (route.prefix().address().isIp4()) ? IPV4 : IPV6;
Set<Route> tempRoutes = computedTables.computeIfAbsent(routeTableId, k -> Sets.newHashSet());
tempRoutes.add(route);
});
return computedTables;
}
Aggregations