Search in sources :

Example 56 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class OpticalOduIntentCompiler method createRules.

/**
 * Create rules for the forward (or the reverse) path of the intent.
 *
 * @param intent OpticalOduIntent intent
 * @param path path found for intent
 * @param slotsMap Map of LinkKey and TributarySlots resources
 * @return list of flow rules
 */
private List<FlowRule> createRules(OpticalOduIntent intent, ConnectPoint src, ConnectPoint dst, Path path, Map<LinkKey, Set<TributarySlot>> slotsMap, boolean reverse) {
    // Build the ingress OTN rule
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchInPort(src.port());
    OduSignalType oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
    selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
    List<FlowRule> rules = new LinkedList<>();
    ConnectPoint current = src;
    List<Link> links = ((!reverse) ? path.links() : Lists.reverse(path.links()));
    for (Link link : links) {
        Set<TributarySlot> slots = slotsMap.get(linkKey(link));
        OtuPort otuPort = (OtuPort) (deviceService.getPort(link.src().deviceId(), link.src().port()));
        OduSignalType otuPortOduSignalType = OduSignalUtils.mappingOtuSignalTypeToOduSignalType(otuPort.signalType());
        TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
        OduSignalId oduSignalId = null;
        // use Instruction of OduSignalId only in case of ODU Multiplexing
        if (oduCltPortOduSignalType != otuPortOduSignalType) {
            oduSignalId = OduSignalUtils.buildOduSignalId(otuPortOduSignalType, slots);
            treat.add(Instructions.modL1OduSignalId(oduSignalId));
        }
        ConnectPoint next = ((!reverse) ? link.src() : link.dst());
        treat.setOutput(next.port());
        FlowRule rule = createFlowRule(intent, current.deviceId(), selector.build(), treat.build());
        rules.add(rule);
        current = ((!reverse) ? link.dst() : link.src());
        selector = DefaultTrafficSelector.builder();
        selector.matchInPort(current.port());
        selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
        // use Criteria of OduSignalId only in case of ODU Multiplexing
        if (oduCltPortOduSignalType != otuPortOduSignalType) {
            selector.add(Criteria.matchOduSignalId(oduSignalId));
        }
    }
    // Build the egress OTN rule
    TrafficTreatment.Builder treatLast = DefaultTrafficTreatment.builder();
    treatLast.setOutput(dst.port());
    FlowRule rule = createFlowRule(intent, dst.deviceId(), selector.build(), treatLast.build());
    rules.add(rule);
    return rules;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) OtuPort(org.onosproject.net.optical.OtuPort) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) LinkedList(java.util.LinkedList) TributarySlot(org.onosproject.net.TributarySlot) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) OduSignalId(org.onosproject.net.OduSignalId) Link(org.onosproject.net.Link)

Example 57 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class WaypointConstraint method validate.

private boolean validate(Path path) {
    LinkedList<DeviceId> waypoints = new LinkedList<>(this.waypoints);
    DeviceId current = waypoints.poll();
    // This is safe because Path class ensures the number of links are more than 0
    Link firstLink = path.links().get(0);
    if (firstLink.src().elementId().equals(current)) {
        current = waypoints.poll();
    }
    for (Link link : path.links()) {
        if (link.dst().elementId().equals(current)) {
            current = waypoints.poll();
            // Empty waypoints means passing through all waypoints in the specified order
            if (current == null) {
                return true;
            }
        }
    }
    return false;
}
Also used : DeviceId(org.onosproject.net.DeviceId) LinkedList(java.util.LinkedList) Link(org.onosproject.net.Link)

Example 58 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class StatisticManager method min.

@Override
public Link min(Path path) {
    checkPermission(STATISTIC_READ);
    if (path.links().isEmpty()) {
        return null;
    }
    Load minLoad = new DefaultLoad();
    Link minLink = null;
    for (Link link : path.links()) {
        Load load = loadInternal(link.src());
        if (load.rate() < minLoad.rate()) {
            minLoad = load;
            minLink = link;
        }
    }
    return minLink;
}
Also used : DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Link(org.onosproject.net.Link)

Example 59 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class StatisticManager method max.

@Override
public Link max(Path path) {
    checkPermission(STATISTIC_READ);
    if (path.links().isEmpty()) {
        return null;
    }
    Load maxLoad = new DefaultLoad();
    Link maxLink = null;
    for (Link link : path.links()) {
        Load load = loadInternal(link.src());
        if (load.rate() > maxLoad.rate()) {
            maxLoad = load;
            maxLink = link;
        }
    }
    return maxLink;
}
Also used : DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Link(org.onosproject.net.Link)

Example 60 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class ECLinkStore method refreshLinkCache.

private LinkEvent refreshLinkCache(LinkKey linkKey) {
    AtomicReference<LinkEvent.Type> eventType = new AtomicReference<>();
    Link link = links.compute(linkKey, (key, existingLink) -> {
        Link newLink = composeLink(linkKey);
        if (newLink == null) {
            return null;
        }
        if (existingLink == null) {
            eventType.set(LINK_ADDED);
            return newLink;
        } else if (existingLink.state() != newLink.state() || existingLink.isExpected() != newLink.isExpected() || (existingLink.type() != newLink.type()) || !AnnotationsUtil.isEqual(existingLink.annotations(), newLink.annotations())) {
            eventType.set(LINK_UPDATED);
            return newLink;
        } else {
            return existingLink;
        }
    });
    return eventType.get() != null ? new LinkEvent(eventType.get(), link) : null;
}
Also used : Type(org.onosproject.net.Link.Type) LinkEvent(org.onosproject.net.link.LinkEvent) AtomicReference(java.util.concurrent.atomic.AtomicReference) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink)

Aggregations

Link (org.onosproject.net.Link)172 ConnectPoint (org.onosproject.net.ConnectPoint)75 Test (org.junit.Test)66 DefaultLink (org.onosproject.net.DefaultLink)44 Intent (org.onosproject.net.intent.Intent)40 DeviceId (org.onosproject.net.DeviceId)39 TrafficSelector (org.onosproject.net.flow.TrafficSelector)27 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)26 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)26 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)26 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)26 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)26 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)24 List (java.util.List)23 LinkKey (org.onosproject.net.LinkKey)23 Set (java.util.Set)22 DefaultPath (org.onosproject.net.DefaultPath)20 FlowRule (org.onosproject.net.flow.FlowRule)20 Collectors (java.util.stream.Collectors)19 PathIntent (org.onosproject.net.intent.PathIntent)18