use of org.onosproject.imr.data.Path in project onos by opennetworkinglab.
the class IntentMonitorAndRerouteManager method applyPath.
@Override
public boolean applyPath(Route route) {
checkNotNull(route, "Route to apply must be not null");
checkNotNull(route.appId(), "Application id must be not null");
checkNotNull(route.key(), "Intent key to apply must be not null");
checkNotNull(route.paths(), "New path must be not null");
checkArgument(route.paths().size() >= 1);
ApplicationId appId = route.appId();
Key key = route.key();
// check if the app and the intent key are monitored
if (!monitoredIntents.containsKey(appId)) {
return false;
}
if (!monitoredIntents.get(appId).containsKey(key)) {
return false;
}
// TODO: now we manage only the unsplittable routing
Path currentPath = route.paths().stream().max(Comparator.comparing(Path::weight)).get();
// in this case remove them from the list
if (currentPath.path().get(0) instanceof HostId) {
currentPath.path().remove(0);
}
if (currentPath.path().get(currentPath.path().size() - 1) instanceof HostId) {
currentPath.path().remove(currentPath.path().size() - 1);
}
List<Link> links = createPathFromDeviceList(currentPath.path());
// Generate the new Link collection intent, if not possible it will return the old intent
ConnectivityIntent intent = generateLinkCollectionIntent(links, key, appId);
storeMonitoredIntent(intent);
intentService.submit(intent);
return true;
}
Aggregations