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();
}
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();
}
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();
}
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();
}
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;
}
});
}
}
Aggregations