Search in sources :

Example 36 with Path

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

the class MultiPointToSinglePointIntentCompiler method compile.

@Override
public List<Intent> compile(MultiPointToSinglePointIntent intent, List<Intent> installable) {
    Map<DeviceId, Link> links = new HashMap<>();
    ConnectPoint egressPoint = intent.egressPoint();
    final boolean allowMissingPaths = intentAllowsPartialFailure(intent);
    boolean hasPaths = false;
    boolean missingSomePaths = false;
    for (ConnectPoint ingressPoint : intent.ingressPoints()) {
        if (ingressPoint.deviceId().equals(egressPoint.deviceId())) {
            if (deviceService.isAvailable(ingressPoint.deviceId())) {
                hasPaths = true;
            } else {
                missingSomePaths = true;
            }
            continue;
        }
        Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId());
        if (path != null) {
            hasPaths = true;
            for (Link link : path.links()) {
                if (links.containsKey(link.dst().deviceId())) {
                    // We've already reached the existing tree with the first
                    // part of this path. Add the merging point with different
                    // incoming port, but don't add the remainder of the path
                    // in case it differs from the path we already have.
                    links.put(link.src().deviceId(), link);
                    break;
                }
                links.put(link.src().deviceId(), link);
            }
        } else {
            missingSomePaths = true;
        }
    }
    // Allocate bandwidth on existing paths if a bandwidth constraint is set
    List<ConnectPoint> ingressCPs = intent.filteredIngressPoints().stream().map(fcp -> fcp.connectPoint()).collect(Collectors.toList());
    ConnectPoint egressCP = intent.filteredEgressPoint().connectPoint();
    List<ConnectPoint> pathCPs = links.values().stream().flatMap(l -> Stream.of(l.src(), l.dst())).collect(Collectors.toList());
    pathCPs.addAll(ingressCPs);
    pathCPs.add(egressCP);
    allocateBandwidth(intent, pathCPs);
    if (!hasPaths) {
        throw new IntentException("Cannot find any path between ingress and egress points.");
    } else if (!allowMissingPaths && missingSomePaths) {
        throw new IntentException("Missing some paths between ingress and egress points.");
    }
    Intent result = LinkCollectionIntent.builder().appId(intent.appId()).key(intent.key()).treatment(intent.treatment()).selector(intent.selector()).links(Sets.newHashSet(links.values())).filteredIngressPoints(intent.filteredIngressPoints()).filteredEgressPoints(ImmutableSet.of(intent.filteredEgressPoint())).priority(intent.priority()).constraints(intent.constraints()).resourceGroup(intent.resourceGroup()).build();
    return Collections.singletonList(result);
}
Also used : Path(org.onosproject.net.Path) ImmutableSet(com.google.common.collect.ImmutableSet) Deactivate(org.osgi.service.component.annotations.Deactivate) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) HashMap(java.util.HashMap) Link(org.onosproject.net.Link) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ConnectPoint(org.onosproject.net.ConnectPoint) PartialFailureConstraint.intentAllowsPartialFailure(org.onosproject.net.intent.constraint.PartialFailureConstraint.intentAllowsPartialFailure) IntentException(org.onosproject.net.intent.IntentException) Component(org.osgi.service.component.annotations.Component) List(java.util.List) Stream(java.util.stream.Stream) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Map(java.util.Map) Intent(org.onosproject.net.intent.Intent) Path(org.onosproject.net.Path) Activate(org.osgi.service.component.annotations.Activate) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) IntentException(org.onosproject.net.intent.IntentException) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link)

Example 37 with Path

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

the class PointToPointIntentCompiler method compile.

@Override
public List<Intent> compile(PointToPointIntent intent, List<Intent> installable) {
    log.trace("compiling {} {}", intent, installable);
    ConnectPoint ingressPoint = intent.filteredIngressPoint().connectPoint();
    ConnectPoint egressPoint = intent.filteredEgressPoint().connectPoint();
    // Idea: use suggested path as primary and another path from path service as protection
    if (intent.suggestedPath() != null && intent.suggestedPath().size() > 0) {
        Path path = new DefaultPath(PID, intent.suggestedPath(), new ScalarWeight(1));
        // Check intent constraints against suggested path and suggested path availability
        if (checkPath(path, intent.constraints()) && pathAvailable(intent)) {
            allocateIntentBandwidth(intent, path);
            return asList(createLinkCollectionIntent(ImmutableSet.copyOf(intent.suggestedPath()), DEFAULT_COST, intent));
        }
    }
    if (ingressPoint.deviceId().equals(egressPoint.deviceId())) {
        return createZeroHopLinkCollectionIntent(intent);
    }
    // proceed with no protected paths
    if (!ProtectionConstraint.requireProtectedPath(intent)) {
        return createUnprotectedLinkCollectionIntent(intent);
    }
    try {
        // attempt to compute and implement backup path
        return createProtectedIntent(ingressPoint, egressPoint, intent, installable);
    } catch (PathNotFoundException e) {
        log.warn("Could not find disjoint Path for {}", intent);
        // no disjoint path extant -- maximum one path exists between devices
        return createSinglePathIntent(ingressPoint, egressPoint, intent, installable);
    }
}
Also used : Path(org.onosproject.net.Path) DefaultPath(org.onosproject.net.DefaultPath) DisjointPath(org.onosproject.net.DisjointPath) DefaultPath(org.onosproject.net.DefaultPath) PathNotFoundException(org.onosproject.net.intent.impl.PathNotFoundException) ConnectPoint(org.onosproject.net.ConnectPoint) ScalarWeight(org.onlab.graph.ScalarWeight)

Example 38 with Path

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

the class PointToPointIntentCompiler method allocateIntentBandwidth.

private void allocateIntentBandwidth(PointToPointIntent intent, Path path) {
    ConnectPoint ingressCP = intent.filteredIngressPoint().connectPoint();
    ConnectPoint egressCP = intent.filteredEgressPoint().connectPoint();
    List<ConnectPoint> pathCPs = path.links().stream().flatMap(l -> Stream.of(l.src(), l.dst())).collect(Collectors.toList());
    pathCPs.add(ingressCP);
    pathCPs.add(egressCP);
    allocateBandwidth(intent, pathCPs);
}
Also used : DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) ListIterator(java.util.ListIterator) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) TimeoutException(java.util.concurrent.TimeoutException) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) GroupListener(org.onosproject.net.group.GroupListener) Arrays.asList(java.util.Arrays.asList) PathNotFoundException(org.onosproject.net.intent.impl.PathNotFoundException) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) FlowRule(org.onosproject.net.flow.FlowRule) GroupBuckets(org.onosproject.net.group.GroupBuckets) LinkService(org.onosproject.net.link.LinkService) Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) IntStream(java.util.stream.IntStream) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) CompletableFuture(java.util.concurrent.CompletableFuture) GroupBucket(org.onosproject.net.group.GroupBucket) GroupKey(org.onosproject.net.group.GroupKey) Group(org.onosproject.net.group.Group) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultPath(org.onosproject.net.DefaultPath) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) EdgeLink(org.onosproject.net.EdgeLink) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IntentId(org.onosproject.net.intent.IntentId) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PathIntent(org.onosproject.net.intent.PathIntent) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupService(org.onosproject.net.group.GroupService) ProtectionConstraint(org.onosproject.net.intent.constraint.ProtectionConstraint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ProviderId(org.onosproject.net.provider.ProviderId) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ScalarWeight(org.onlab.graph.ScalarWeight) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) DisjointPath(org.onosproject.net.DisjointPath) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 39 with Path

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

the class DefaultVirtualNetworkProvider method isTraversable.

@Override
public boolean isTraversable(ConnectPoint src, ConnectPoint dst) {
    final boolean[] foundSrc = new boolean[1];
    final boolean[] foundDst = new boolean[1];
    Topology topology = topologyService.currentTopology();
    Set<Path> paths = topologyService.getPaths(topology, src.deviceId(), dst.deviceId());
    paths.forEach(path -> {
        foundDst[0] = false;
        foundSrc[0] = false;
        // Traverse the links in each path to determine if both the src and dst connection
        // point are in the path, if so then this src/dst pair are traversable.
        path.links().forEach(link -> {
            if (link.src().equals(src)) {
                foundSrc[0] = true;
            }
            if (link.dst().equals(dst)) {
                foundDst[0] = true;
            }
        });
        if (foundSrc[0] && foundDst[0]) {
            return;
        }
    });
    return foundSrc[0] && foundDst[0];
}
Also used : Path(org.onosproject.net.Path) Topology(org.onosproject.net.topology.Topology)

Example 40 with Path

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

the class PathManagerTest method infraToEdge.

@Test
public void infraToEdge() {
    DeviceId src = did("src");
    HostId dst = hid("12:34:56:78:90:ab/1");
    fakeTopoMgr.paths.add(createPath("src", "middle", "edge"));
    fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ab/1", "edge"));
    Set<Path> paths = service.getPaths(src, dst);
    validatePaths(paths, 1, 3, src, dst);
}
Also used : Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) HostId(org.onosproject.net.HostId) Test(org.junit.Test)

Aggregations

Path (org.onosproject.net.Path)60 DeviceId (org.onosproject.net.DeviceId)27 DefaultPath (org.onosproject.net.DefaultPath)24 Link (org.onosproject.net.Link)23 DisjointPath (org.onosproject.net.DisjointPath)22 ConnectPoint (org.onosproject.net.ConnectPoint)18 Test (org.junit.Test)16 ImmutableSet (com.google.common.collect.ImmutableSet)12 ArrayList (java.util.ArrayList)11 List (java.util.List)11 Set (java.util.Set)11 Collectors (java.util.stream.Collectors)10 DefaultLink (org.onosproject.net.DefaultLink)10 Intent (org.onosproject.net.intent.Intent)10 Collections (java.util.Collections)9 Topology (org.onosproject.net.topology.Topology)8 Logger (org.slf4j.Logger)8 Stream (java.util.stream.Stream)7 ScalarWeight (org.onlab.graph.ScalarWeight)7 HostId (org.onosproject.net.HostId)7