use of org.onosproject.net.TributarySlot in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompiler method availableSlotResources.
private List<Resource> availableSlotResources(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) {
OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(signalType);
int requestedTsNum = oduSignalType.tributarySlots();
Set<TributarySlot> commonTributarySlots = findCommonTributarySlotsOnCps(src, dst);
if (commonTributarySlots.isEmpty()) {
return Collections.emptyList();
}
if (commonTributarySlots.size() < requestedTsNum) {
return Collections.emptyList();
}
Set<TributarySlot> tributarySlots = commonTributarySlots.stream().limit(requestedTsNum).collect(Collectors.toSet());
final List<ConnectPoint> portsList = ImmutableList.of(src, dst);
List<Resource> tributarySlotResources = portsList.stream().flatMap(cp -> tributarySlots.stream().map(ts -> Resources.discrete(cp.deviceId(), cp.port()).resource().child(ts))).collect(Collectors.toList());
if (!tributarySlotResources.stream().allMatch(resourceService::isAvailable)) {
log.debug("Resource allocation for {} on {} and {} failed (resource request: {})", signalType, src, dst, tributarySlotResources);
return Collections.emptyList();
}
return tributarySlotResources;
}
use of org.onosproject.net.TributarySlot in project onos by opennetworkinglab.
the class OpticalOduIntentCompiler method findTributarySlots.
private Map<LinkKey, Set<TributarySlot>> findTributarySlots(OpticalOduIntent intent, Set<LinkKey> links) {
OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
int requestedTsNum = oduSignalType.tributarySlots();
Map<LinkKey, Set<TributarySlot>> slotsMap = new HashMap<>();
for (LinkKey link : links) {
Set<TributarySlot> common = findCommonTributarySlotsOnCps(link.src(), link.dst());
if (common.isEmpty() || (common.size() < requestedTsNum)) {
log.debug("Failed to find TributarySlots on link {} requestedTsNum={}", link, requestedTsNum);
// failed to find enough available TributarySlots on a link
return Collections.emptyMap();
}
slotsMap.put(link, common.stream().limit(requestedTsNum).collect(Collectors.toSet()));
}
return slotsMap;
}
Aggregations