Package org.onosproject.common
Class DefaultTopology
- java.lang.Object
-
- org.onosproject.net.AbstractAnnotated
-
- org.onosproject.net.AbstractModel
-
- org.onosproject.common.DefaultTopology
-
public class DefaultTopology extends AbstractModel implements Topology
Default implementation of the topology descriptor. This carries the backing topology data.
-
-
Constructor Summary
Constructors Constructor Description DefaultTopology(ProviderId providerId, GraphDescription description)
Creates a topology descriptor attributed to the specified provider.DefaultTopology(ProviderId providerId, GraphDescription description, com.google.common.base.Function<ConnectPoint,java.lang.Boolean> broadcastFunction)
Creates a topology descriptor attributed to the specified provider.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<ConnectPoint>
broadcastPoints(ClusterId clusterId)
Returns the set of the cluster broadcast points.int
broadcastSetSize(ClusterId clusterId)
Returns the size of the cluster broadcast set.int
clusterCount()
Returns the number of SCCs (strongly connected components) in the topology.long
computeCost()
Returns the time, specified in system nanos of how long the topology took to compute.long
creationTime()
Returns the time, specified in system millis of when the topology became available.int
deviceCount()
Returns the number of infrastructure devices in the topology.TopologyCluster
getCluster(DeviceId deviceId)
Returns the topology cluster that contains the given device.TopologyCluster
getCluster(ClusterId clusterId)
Returns the specified topology cluster.java.util.Set<DeviceId>
getClusterDevices(TopologyCluster cluster)
Returns the set of cluster devices.java.util.Set<Link>
getClusterLinks(TopologyCluster cluster)
Returns the set of cluster links.java.util.Set<TopologyCluster>
getClusters()
Returns the set of topology clusters.java.util.Set<DisjointPath>
getDisjointPaths(DeviceId src, DeviceId dst)
Returns the set of pre-computed shortest disjoint path pairs between source and destination devices.java.util.Set<DisjointPath>
getDisjointPaths(DeviceId src, DeviceId dst, java.util.Map<Link,java.lang.Object> riskProfile)
Computes on-demand the set of shortest disjoint risk groups path pairs between source and destination devices.java.util.Set<DisjointPath>
getDisjointPaths(DeviceId src, DeviceId dst, LinkWeigher weigher)
Computes on-demand the set of shortest disjoint path pairs between source and destination devices.java.util.Set<DisjointPath>
getDisjointPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, java.util.Map<Link,java.lang.Object> riskProfile)
Computes on-demand the set of shortest disjoint risk groups path pairs between source and destination devices.TopologyGraph
getGraph()
Returns the backing topology graph.java.util.stream.Stream<Path>
getKShortestPaths(DeviceId src, DeviceId dst)
Lazily computes on-demand the k-shortest paths between source and destination devices.java.util.Set<Path>
getKShortestPaths(DeviceId src, DeviceId dst, int maxPaths)
Computes on-demand the k-shortest paths between source and destination devices.java.util.stream.Stream<Path>
getKShortestPaths(DeviceId src, DeviceId dst, LinkWeigher weigher)
Lazily computes on-demand the k-shortest paths between source and destination devices.java.util.Set<Path>
getKShortestPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, int maxPaths)
Computes on-demand the k-shortest paths between source and destination devices.java.util.Set<Path>
getPaths(DeviceId src, DeviceId dst)
Returns the set of pre-computed shortest paths between source and destination devices.java.util.Set<Path>
getPaths(DeviceId src, DeviceId dst, LinkWeigher weigher)
Computes on-demand the set of shortest paths between source and destination devices.java.util.Set<Path>
getPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, int maxPaths)
Computes on-demand the set of shortest paths between source and destination devices, the set of returned paths will be no more than, maxPaths in size.boolean
isBroadcastPoint(ConnectPoint connectPoint)
Indicates whether the given point is part of a broadcast set.boolean
isInfrastructure(ConnectPoint connectPoint)
Indicates whether the given point is an infrastructure link end-point.int
linkCount()
Returns the number of infrastructure links in the topology.static void
setDefaultGraphPathSearch(GraphPathSearch<TopologyVertex,TopologyEdge> graphPathSearch)
Sets the default lpath search algorighm to be used when computing paths.static void
setDefaultLinkWeigher(LinkWeigher linkWeigher)
Sets the default link-weight to be used when computing paths.long
time()
Returns the time, specified in system nanos of when the topology became available.java.lang.String
toString()
-
Methods inherited from class org.onosproject.net.AbstractModel
providerId
-
Methods inherited from class org.onosproject.net.AbstractAnnotated
annotations
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.onosproject.net.Provided
providerId
-
-
-
-
Constructor Detail
-
DefaultTopology
public DefaultTopology(ProviderId providerId, GraphDescription description, com.google.common.base.Function<ConnectPoint,java.lang.Boolean> broadcastFunction)
Creates a topology descriptor attributed to the specified provider.- Parameters:
providerId
- identity of the providerdescription
- data describing the new topologybroadcastFunction
- broadcast point function
-
DefaultTopology
public DefaultTopology(ProviderId providerId, GraphDescription description)
Creates a topology descriptor attributed to the specified provider.- Parameters:
providerId
- identity of the providerdescription
- data describing the new topology
-
-
Method Detail
-
setDefaultLinkWeigher
public static void setDefaultLinkWeigher(LinkWeigher linkWeigher)
Sets the default link-weight to be used when computing paths. If null is specified, the builtin default link-weight measuring hop-counts will be used.- Parameters:
linkWeigher
- new default link-weight
-
setDefaultGraphPathSearch
public static void setDefaultGraphPathSearch(GraphPathSearch<TopologyVertex,TopologyEdge> graphPathSearch)
Sets the default lpath search algorighm to be used when computing paths. If null is specified, the builtin default Dijkstra will be used.- Parameters:
graphPathSearch
- new default algorithm
-
time
public long time()
Description copied from interface:Topology
Returns the time, specified in system nanos of when the topology became available.
-
creationTime
public long creationTime()
Description copied from interface:Topology
Returns the time, specified in system millis of when the topology became available.- Specified by:
creationTime
in interfaceTopology
- Returns:
- time in system nanos
-
computeCost
public long computeCost()
Description copied from interface:Topology
Returns the time, specified in system nanos of how long the topology took to compute.- Specified by:
computeCost
in interfaceTopology
- Returns:
- elapsed time in system nanos
-
clusterCount
public int clusterCount()
Description copied from interface:Topology
Returns the number of SCCs (strongly connected components) in the topology.- Specified by:
clusterCount
in interfaceTopology
- Returns:
- number of clusters
-
deviceCount
public int deviceCount()
Description copied from interface:Topology
Returns the number of infrastructure devices in the topology.- Specified by:
deviceCount
in interfaceTopology
- Returns:
- number of devices
-
linkCount
public int linkCount()
Description copied from interface:Topology
Returns the number of infrastructure links in the topology.
-
getGraph
public TopologyGraph getGraph()
Returns the backing topology graph.- Returns:
- topology graph
-
getClusters
public java.util.Set<TopologyCluster> getClusters()
Returns the set of topology clusters.- Returns:
- set of clusters
-
getCluster
public TopologyCluster getCluster(ClusterId clusterId)
Returns the specified topology cluster.- Parameters:
clusterId
- cluster identifier- Returns:
- topology cluster
-
getCluster
public TopologyCluster getCluster(DeviceId deviceId)
Returns the topology cluster that contains the given device.- Parameters:
deviceId
- device identifier- Returns:
- topology cluster
-
getClusterDevices
public java.util.Set<DeviceId> getClusterDevices(TopologyCluster cluster)
Returns the set of cluster devices.- Parameters:
cluster
- topology cluster- Returns:
- cluster devices
-
getClusterLinks
public java.util.Set<Link> getClusterLinks(TopologyCluster cluster)
Returns the set of cluster links.- Parameters:
cluster
- topology cluster- Returns:
- cluster links
-
isInfrastructure
public boolean isInfrastructure(ConnectPoint connectPoint)
Indicates whether the given point is an infrastructure link end-point.- Parameters:
connectPoint
- connection point- Returns:
- true if infrastructure
-
isBroadcastPoint
public boolean isBroadcastPoint(ConnectPoint connectPoint)
Indicates whether the given point is part of a broadcast set.- Parameters:
connectPoint
- connection point- Returns:
- true if in broadcast set
-
broadcastSetSize
public int broadcastSetSize(ClusterId clusterId)
Returns the size of the cluster broadcast set.- Parameters:
clusterId
- cluster identifier- Returns:
- size of the cluster broadcast set
-
broadcastPoints
public java.util.Set<ConnectPoint> broadcastPoints(ClusterId clusterId)
Returns the set of the cluster broadcast points.- Parameters:
clusterId
- cluster identifier- Returns:
- set of cluster broadcast points
-
getPaths
public java.util.Set<Path> getPaths(DeviceId src, DeviceId dst)
Returns the set of pre-computed shortest paths between source and destination devices.- Parameters:
src
- source devicedst
- destination device- Returns:
- set of shortest paths
-
getPaths
public java.util.Set<Path> getPaths(DeviceId src, DeviceId dst, LinkWeigher weigher)
Computes on-demand the set of shortest paths between source and destination devices.- Parameters:
src
- source devicedst
- destination deviceweigher
- link weight function- Returns:
- set of shortest paths
-
getPaths
public java.util.Set<Path> getPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, int maxPaths)
Computes on-demand the set of shortest paths between source and destination devices, the set of returned paths will be no more than, maxPaths in size. The firstmaxPaths
paths will be returned maintaining any ordering guarantees provided by the underlying (default or if no default is specifiedDijkstraGraphSearch
) search. If returning all paths of a given length would exceedmaxPaths
a subset of paths of that length will be returned, which paths will be returned depends on the currently specifiedGraphPathSearch
. SeesetDefaultGraphPathSearch(org.onlab.graph.GraphPathSearch<org.onosproject.net.topology.TopologyVertex, org.onosproject.net.topology.TopologyEdge>)
.- Parameters:
src
- source devicedst
- destination deviceweigher
- link weight functionmaxPaths
- maximum number of paths- Returns:
- set of shortest paths
-
getKShortestPaths
public java.util.Set<Path> getKShortestPaths(DeviceId src, DeviceId dst, int maxPaths)
Computes on-demand the k-shortest paths between source and destination devices.- Parameters:
src
- source devicedst
- destination devicemaxPaths
- maximum number of paths (k)- Returns:
- set of k-shortest paths
-
getKShortestPaths
public java.util.Set<Path> getKShortestPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, int maxPaths)
Computes on-demand the k-shortest paths between source and destination devices. The firstmaxPaths
paths will be returned in ascending order according to the providedweigher
- Parameters:
src
- source devicedst
- destination deviceweigher
- link weight functionmaxPaths
- maximum number of paths (k)- Returns:
- set of k-shortest paths
-
getKShortestPaths
public java.util.stream.Stream<Path> getKShortestPaths(DeviceId src, DeviceId dst)
Lazily computes on-demand the k-shortest paths between source and destination devices.- Parameters:
src
- source devicedst
- destination device- Returns:
- stream of k-shortest paths
-
getKShortestPaths
public java.util.stream.Stream<Path> getKShortestPaths(DeviceId src, DeviceId dst, LinkWeigher weigher)
Lazily computes on-demand the k-shortest paths between source and destination devices.- Parameters:
src
- source devicedst
- destination deviceweigher
- link weight function- Returns:
- stream of k-shortest paths
-
getDisjointPaths
public java.util.Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst)
Returns the set of pre-computed shortest disjoint path pairs between source and destination devices.- Parameters:
src
- source devicedst
- destination device- Returns:
- set of shortest disjoint path pairs
-
getDisjointPaths
public java.util.Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, LinkWeigher weigher)
Computes on-demand the set of shortest disjoint path pairs between source and destination devices.- Parameters:
src
- source devicedst
- destination deviceweigher
- link weight function- Returns:
- set of disjoint shortest path pairs
-
getDisjointPaths
public java.util.Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, java.util.Map<Link,java.lang.Object> riskProfile)
Computes on-demand the set of shortest disjoint risk groups path pairs between source and destination devices.- Parameters:
src
- source devicedst
- destination deviceweigher
- edge weight objectriskProfile
- map representing risk groups for each link- Returns:
- set of shortest disjoint paths
-
getDisjointPaths
public java.util.Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, java.util.Map<Link,java.lang.Object> riskProfile)
Computes on-demand the set of shortest disjoint risk groups path pairs between source and destination devices.- Parameters:
src
- source devicedst
- destination deviceriskProfile
- map representing risk groups for each link- Returns:
- set of shortest disjoint paths
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-