Search in sources :

Example 1 with TopologyEdge

use of org.onosproject.net.topology.TopologyEdge in project onos by opennetworkinglab.

the class DefaultTopology method findInfrastructurePoints.

// Collects and returns an set of all infrastructure link end-points.
private ImmutableSet<ConnectPoint> findInfrastructurePoints() {
    ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder();
    for (TopologyEdge edge : graph.getEdges()) {
        if (edge.link().type() == Type.EDGE) {
            // - Device <-> remote domain Device
            continue;
        }
        builder.add(edge.link().src());
        builder.add(edge.link().dst());
    }
    return builder.build();
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ConnectPoint(org.onosproject.net.ConnectPoint) TopologyEdge(org.onosproject.net.topology.TopologyEdge)

Example 2 with TopologyEdge

use of org.onosproject.net.topology.TopologyEdge in project onos by opennetworkinglab.

the class DefaultTopology method disjointPaths.

/**
 * Computes on-demand the set of shortest disjoint risk groups path pairs
 * between source and destination devices.
 *
 * @param src         source device
 * @param dst         destination device
 * @param weigher     edge weight object
 * @param riskProfile map representing risk groups for each edge
 * @return set of shortest disjoint paths
 */
private Set<DisjointPath> disjointPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, Map<TopologyEdge, Object> riskProfile) {
    DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
    DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
    Set<TopologyVertex> vertices = graph.getVertexes();
    if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
        // src or dst not part of the current graph
        return ImmutableSet.of();
    }
    SrlgGraphSearch<TopologyVertex, TopologyEdge> srlg = new SrlgGraphSearch<>(riskProfile);
    GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = srlg.search(graph, srcV, dstV, weigher, defaultMaxPaths);
    ImmutableSet.Builder<DisjointPath> builder = ImmutableSet.builder();
    for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
        DisjointPath disjointPath = networkDisjointPath((DisjointPathPair<TopologyVertex, TopologyEdge>) path);
        if (disjointPath.backup() != null) {
            builder.add(disjointPath);
        }
    }
    return builder.build();
}
Also used : DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) TopologyEdge(org.onosproject.net.topology.TopologyEdge) GraphPathSearch(org.onlab.graph.GraphPathSearch) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) SrlgGraphSearch(org.onlab.graph.SrlgGraphSearch) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) DisjointPath(org.onosproject.net.DisjointPath)

Example 3 with TopologyEdge

use of org.onosproject.net.topology.TopologyEdge in project onos by opennetworkinglab.

the class DefaultTopology method buildTopologyClusters.

// Builds the topology clusters and returns the id-cluster bindings.
private ImmutableMap<ClusterId, TopologyCluster> buildTopologyClusters() {
    ImmutableMap.Builder<ClusterId, TopologyCluster> clusterBuilder = ImmutableMap.builder();
    SccResult<TopologyVertex, TopologyEdge> results = clusterResults.get();
    // Extract both vertexes and edges from the results; the lists form
    // pairs along the same index.
    List<Set<TopologyVertex>> clusterVertexes = results.clusterVertexes();
    List<Set<TopologyEdge>> clusterEdges = results.clusterEdges();
    // Scan over the lists and create a cluster from the results.
    for (int i = 0, n = results.clusterCount(); i < n; i++) {
        Set<TopologyVertex> vertexSet = clusterVertexes.get(i);
        Set<TopologyEdge> edgeSet = clusterEdges.get(i);
        ClusterId cid = ClusterId.clusterId(i);
        DefaultTopologyCluster cluster = new DefaultTopologyCluster(cid, vertexSet.size(), edgeSet.size(), findRoot(vertexSet));
        clusterBuilder.put(cid, cluster);
    }
    return clusterBuilder.build();
}
Also used : DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ClusterId(org.onosproject.net.topology.ClusterId) TopologyCluster(org.onosproject.net.topology.TopologyCluster) DefaultTopologyCluster(org.onosproject.net.topology.DefaultTopologyCluster) TopologyEdge(org.onosproject.net.topology.TopologyEdge) ImmutableMap(com.google.common.collect.ImmutableMap) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultTopologyCluster(org.onosproject.net.topology.DefaultTopologyCluster)

Example 4 with TopologyEdge

use of org.onosproject.net.topology.TopologyEdge in project onos by opennetworkinglab.

the class DefaultTopology method getDisjointPaths.

/**
 * Computes on-demand the set of shortest disjoint path pairs between
 * source and destination devices.
 *
 * @param src     source device
 * @param dst     destination device
 * @param weigher link weight function
 * @return set of disjoint shortest path pairs
 */
public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, LinkWeigher weigher) {
    DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
    DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
    Set<TopologyVertex> vertices = graph.getVertexes();
    if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
        // src or dst not part of the current graph
        return ImmutableSet.of();
    }
    GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = SUURBALLE.search(graph, srcV, dstV, weigher, defaultMaxPaths);
    ImmutableSet.Builder<DisjointPath> builder = ImmutableSet.builder();
    for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
        DisjointPath disjointPath = networkDisjointPath((DisjointPathPair<TopologyVertex, TopologyEdge>) path);
        if (disjointPath.backup() != null) {
            builder.add(disjointPath);
        }
    }
    return builder.build();
}
Also used : DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyEdge(org.onosproject.net.topology.TopologyEdge) GraphPathSearch(org.onlab.graph.GraphPathSearch) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) DisjointPath(org.onosproject.net.DisjointPath)

Example 5 with TopologyEdge

use of org.onosproject.net.topology.TopologyEdge in project onos by opennetworkinglab.

the class MockLinkService method addLink.

public void addLink(String device, long port, String device2, long port2) {
    ElementId d1;
    if (device.charAt(0) == 'H') {
        device = device.substring(1, device.length());
        d1 = HostId.hostId(device);
    } else {
        d1 = DeviceId.deviceId(device);
    }
    ElementId d2;
    if (device2.charAt(0) == 'H') {
        d2 = HostId.hostId(device2.substring(1, device2.length()));
    } else {
        d2 = DeviceId.deviceId(device2);
    }
    ConnectPoint src = new ConnectPoint(d1, PortNumber.portNumber(port));
    ConnectPoint dst = new ConnectPoint(d2, PortNumber.portNumber(port2));
    Link curLink;
    curLink = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).build();
    links.add(curLink);
    if (d1 instanceof DeviceId && d2 instanceof DeviceId) {
        TopologyVertex v1 = () -> (DeviceId) d1, v2 = () -> (DeviceId) d2;
        createdGraph.addVertex(v1);
        createdGraph.addVertex(v2);
        createdGraph.addEdge(new TopologyEdge() {

            @Override
            public Link link() {
                return curLink;
            }

            @Override
            public TopologyVertex src() {
                return v1;
            }

            @Override
            public TopologyVertex dst() {
                return v2;
            }
        });
    }
}
Also used : TopologyVertex(org.onosproject.net.topology.TopologyVertex) DeviceId(org.onosproject.net.DeviceId) ConnectPoint(org.onosproject.net.ConnectPoint) TopologyEdge(org.onosproject.net.topology.TopologyEdge) ElementId(org.onosproject.net.ElementId) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link)

Aggregations

TopologyEdge (org.onosproject.net.topology.TopologyEdge)10 TopologyVertex (org.onosproject.net.topology.TopologyVertex)7 ImmutableSet (com.google.common.collect.ImmutableSet)6 ConnectPoint (org.onosproject.net.ConnectPoint)6 DefaultTopologyVertex (org.onosproject.net.topology.DefaultTopologyVertex)6 Link (org.onosproject.net.Link)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 GraphPathSearch (org.onlab.graph.GraphPathSearch)3 DefaultDisjointPath (org.onosproject.net.DefaultDisjointPath)3 DeviceId (org.onosproject.net.DeviceId)3 DisjointPath (org.onosproject.net.DisjointPath)3 Set (java.util.Set)2 DefaultLink (org.onosproject.net.DefaultLink)2 DefaultPath (org.onosproject.net.DefaultPath)2 Path (org.onosproject.net.Path)2 DefaultTopologyCluster (org.onosproject.net.topology.DefaultTopologyCluster)2 LinkWeigher (org.onosproject.net.topology.LinkWeigher)2 Topology (org.onosproject.net.topology.Topology)2 TopologyCluster (org.onosproject.net.topology.TopologyCluster)2 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)1