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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations