Search in sources :

Example 6 with TributarySlot

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;
}
Also used : Arrays(java.util.Arrays) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) ResourceService(org.onosproject.net.resource.ResourceService) DriverService(org.onosproject.net.driver.DriverService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) TributarySlotQuery(org.onosproject.net.behaviour.TributarySlotQuery) ApplicationId(org.onosproject.core.ApplicationId) OchPort(org.onosproject.net.optical.OchPort) Driver(org.onosproject.net.driver.Driver) OduSignalUtils(org.onosproject.net.OduSignalUtils) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Resources(org.onosproject.net.resource.Resources) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Resource(org.onosproject.net.resource.Resource) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ResourceAllocation(org.onosproject.net.resource.ResourceAllocation) CltSignalType(org.onosproject.net.CltSignalType) List(java.util.List) OduCltPort(org.onosproject.net.optical.OduCltPort) Stream(java.util.stream.Stream) OduSignalId(org.onosproject.net.OduSignalId) FlowRule(org.onosproject.net.flow.FlowRule) IntentCompiler(org.onosproject.net.intent.IntentCompiler) Optional(java.util.Optional) Dictionary(java.util.Dictionary) IntentSetMultimap(org.onosproject.net.intent.IntentSetMultimap) Tools(org.onlab.util.Tools) ComponentContext(org.osgi.service.component.ComponentContext) AnnotationKeys(org.onosproject.net.AnnotationKeys) Strings(com.google.common.base.Strings) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) IntentService(org.onosproject.net.intent.IntentService) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) Criteria(org.onosproject.net.flow.criteria.Criteria) LinkedList(java.util.LinkedList) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OduSignalType(org.onosproject.net.OduSignalType) IntentId(org.onosproject.net.intent.IntentId) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PathIntent(org.onosproject.net.intent.PathIntent) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) TributarySlot(org.onosproject.net.TributarySlot) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) MAX_CAPACITY(org.onosproject.net.optical.intent.impl.compiler.OsgiPropertyConstants.MAX_CAPACITY) OpticalDeviceServiceView.opticalView(org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView) Modified(org.osgi.service.component.annotations.Modified) MAX_CAPACITY_DEFAULT(org.onosproject.net.optical.intent.impl.compiler.OsgiPropertyConstants.MAX_CAPACITY_DEFAULT) Reference(org.osgi.service.component.annotations.Reference) Comparator(java.util.Comparator) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Collections(java.util.Collections) OduSignalType(org.onosproject.net.OduSignalType) TributarySlot(org.onosproject.net.TributarySlot) Resource(org.onosproject.net.resource.Resource) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 7 with TributarySlot

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;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) LinkKey(org.onosproject.net.LinkKey) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashMap(java.util.HashMap) TributarySlot(org.onosproject.net.TributarySlot) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

TributarySlot (org.onosproject.net.TributarySlot)7 ConnectPoint (org.onosproject.net.ConnectPoint)5 OduSignalId (org.onosproject.net.OduSignalId)4 OduSignalType (org.onosproject.net.OduSignalType)4 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)4 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)4 FlowRule (org.onosproject.net.flow.FlowRule)4 TrafficSelector (org.onosproject.net.flow.TrafficSelector)4 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)4 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)3 Intent (org.onosproject.net.intent.Intent)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Set (java.util.Set)2 Test (org.junit.Test)2 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)2 OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)2 Resource (org.onosproject.net.resource.Resource)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Strings (com.google.common.base.Strings)1