Search in sources :

Example 1 with Path

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;
}
Also used : Path(org.onosproject.imr.data.Path) ApplicationId(org.onosproject.core.ApplicationId) HostId(org.onosproject.net.HostId) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Key(org.onosproject.net.intent.Key) Link(org.onosproject.net.Link)

Aggregations

ApplicationId (org.onosproject.core.ApplicationId)1 Path (org.onosproject.imr.data.Path)1 HostId (org.onosproject.net.HostId)1 Link (org.onosproject.net.Link)1 ConnectivityIntent (org.onosproject.net.intent.ConnectivityIntent)1 Key (org.onosproject.net.intent.Key)1