Search in sources :

Example 1 with TributarySlot

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

the class OpticalOduIntentCompiler method isAvailableTributarySlots.

private boolean isAvailableTributarySlots(OpticalOduIntent intent, Link link) {
    OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
    int requestedTsNum = oduSignalType.tributarySlots();
    Set<TributarySlot> common = findCommonTributarySlotsOnCps(link.src(), link.dst());
    if (common.isEmpty() || (common.size() < requestedTsNum)) {
        log.debug("Not enough available TributarySlots on link {} requestedTsNum={}", link, requestedTsNum);
        return false;
    }
    return true;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) TributarySlot(org.onosproject.net.TributarySlot) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 2 with TributarySlot

use of org.onosproject.net.TributarySlot 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 3 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)

Example 4 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 5 with TributarySlot

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

the class OpticalOduIntentCompilerTest method test1GbeMultiplexOverOdu2.

/**
 * Tests compile of OpticalOduIntent with allocation of TributarySlots.
 * Compile two ODUCLT ports (with CLT_1GBE), over OTU ports (with OTU2):
 *   - only one TributarySlot is used
 */
@Test
public void test1GbeMultiplexOverOdu2() {
    intent = OpticalOduIntent.builder().appId(APP_ID).key(KEY1).src(d1p1).dst(d3p2).signalType(D1P1.signalType()).bidirectional(false).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    // 1st Device
    FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
    // validate SRC selector
    TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
    selectorBuilder1.matchInPort(d1p1.port());
    selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    assertThat(rule1.selector(), is(selectorBuilder1.build()));
    // validate SRC treatment  (with OduSignalId, where 1 TributarySlot is used)
    TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
    Set<TributarySlot> slots = new HashSet<>();
    slots.add(TributarySlot.of(1));
    OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(OduSignalType.ODU2, slots);
    treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
    treatmentBuilder1.setOutput(d1p2.port());
    assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
    // 2nd Device
    FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
    // validate SRC selector
    TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
    selectorBuilder2.matchInPort(d2p1.port());
    selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
    assertThat(rule2.selector(), is(selectorBuilder2.build()));
    // validate SRC treatment  (with OduSignalId, where 1 TributarySlot is used)
    TrafficTreatment.Builder treatmentBuilder2 = DefaultTrafficTreatment.builder();
    treatmentBuilder2.add(Instructions.modL1OduSignalId(oduSignalId));
    treatmentBuilder2.setOutput(d2p2.port());
    assertThat(rule2.treatment(), is(treatmentBuilder2.build()));
    // 3rd Device
    FlowRule rule3 = rules.stream().filter(x -> x.deviceId().equals(device3.id())).findFirst().get();
    // validate DST selector (with OduSignalId, where the same TributarySlot is used)
    TrafficSelector.Builder selectorBuilder3 = DefaultTrafficSelector.builder();
    selectorBuilder3.matchInPort(d3p1.port());
    selectorBuilder3.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    selectorBuilder3.add(Criteria.matchOduSignalId(oduSignalId));
    assertThat(rule3.selector(), is(selectorBuilder3.build()));
    // validate DST treatment
    assertThat(rule3.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d3p2.port()).build()));
    rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
    sut.deactivate();
}
Also used : FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) OpticalOduIntent(org.onosproject.net.intent.OpticalOduIntent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) TributarySlot(org.onosproject.net.TributarySlot) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) FlowRule(org.onosproject.net.flow.FlowRule) OduSignalId(org.onosproject.net.OduSignalId) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

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