Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.topology; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 17 | |
Yuta HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 18 | import org.onlab.util.GuavaCollectors; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 19 | import org.onosproject.event.ListenerService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.DeviceId; |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 22 | import org.onosproject.net.DisjointPath; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.net.Link; |
| 24 | import org.onosproject.net.Path; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 25 | |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 26 | import java.util.Map; |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 27 | import java.util.Set; |
Yuta HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 28 | import java.util.stream.Stream; |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 29 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 30 | /** |
| 31 | * Service for providing network topology information. |
| 32 | */ |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 33 | public interface TopologyService |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 34 | extends ListenerService<TopologyEvent, TopologyListener> { |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Returns the current topology descriptor. |
| 38 | * |
| 39 | * @return current topology |
| 40 | */ |
| 41 | Topology currentTopology(); |
| 42 | |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 43 | /** |
tom | dc361b6 | 2014-09-09 20:36:52 -0700 | [diff] [blame] | 44 | * Indicates whether the specified topology is the latest or not. |
tom | e52ce70 | 2014-09-11 00:12:54 -0700 | [diff] [blame] | 45 | * |
tom | dc361b6 | 2014-09-09 20:36:52 -0700 | [diff] [blame] | 46 | * @param topology topology descriptor |
| 47 | * @return true if the topology is the most recent; false otherwise |
| 48 | */ |
| 49 | boolean isLatest(Topology topology); |
| 50 | |
| 51 | /** |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 52 | * Returns the graph view of the specified topology. |
| 53 | * |
| 54 | * @param topology topology descriptor |
| 55 | * @return topology graph view |
| 56 | */ |
| 57 | TopologyGraph getGraph(Topology topology); |
| 58 | |
| 59 | /** |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 60 | * Returns the set of clusters in the specified topology. |
| 61 | * |
| 62 | * @param topology topology descriptor |
| 63 | * @return set of topology clusters |
| 64 | */ |
| 65 | Set<TopologyCluster> getClusters(Topology topology); |
| 66 | |
| 67 | /** |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 68 | * Returns the cluster with the specified ID. |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 69 | * |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 70 | * @param topology topology descriptor |
| 71 | * @param clusterId cluster identifier |
| 72 | * @return topology cluster |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 73 | */ |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 74 | TopologyCluster getCluster(Topology topology, ClusterId clusterId); |
| 75 | |
| 76 | /** |
| 77 | * Returns the set of devices that belong to the specified cluster. |
| 78 | * |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 79 | * @param topology topology descriptor |
| 80 | * @param cluster topology cluster |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 81 | * @return set of cluster devices |
| 82 | */ |
| 83 | Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster); |
| 84 | |
| 85 | /** |
| 86 | * Returns the set of links that form the specified cluster. |
| 87 | * |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 88 | * @param topology topology descriptor |
| 89 | * @param cluster topology cluster |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 90 | * @return set of cluster links |
| 91 | */ |
| 92 | Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster); |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 93 | |
| 94 | /** |
tom | cfde062 | 2014-09-09 11:02:42 -0700 | [diff] [blame] | 95 | * Returns the set of all shortest paths, precomputed in terms of hop-count, |
| 96 | * between the specified source and destination devices. |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 97 | * |
| 98 | * @param topology topology descriptor |
| 99 | * @param src source device |
| 100 | * @param dst destination device |
| 101 | * @return set of all shortest paths between the two devices |
| 102 | */ |
| 103 | Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst); |
| 104 | |
| 105 | /** |
| 106 | * Returns the set of all shortest paths, computed using the supplied |
| 107 | * edge-weight entity, between the specified source and destination devices. |
| 108 | * |
| 109 | * @param topology topology descriptor |
| 110 | * @param src source device |
| 111 | * @param dst destination device |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 112 | * @param weight edge-weight entity |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 113 | * @return set of all shortest paths between the two devices |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 114 | * |
| 115 | * @deprecated in Junco (1.9.0), use version with LinkWeigher instead |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 116 | */ |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 117 | @Deprecated |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 118 | Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, |
| 119 | LinkWeight weight); |
| 120 | |
| 121 | /** |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 122 | * Returns the set of all shortest paths, computed using the supplied |
| 123 | * edge-weight entity, between the specified source and destination devices. |
| 124 | * |
| 125 | * @param topology topology descriptor |
| 126 | * @param src source device |
| 127 | * @param dst destination device |
| 128 | * @param weigher edge-weight entity |
| 129 | * @return set of all shortest paths between the two devices |
| 130 | */ |
| 131 | Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, |
| 132 | LinkWeigher weigher); |
| 133 | |
| 134 | /** |
Yuta HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 135 | * Returns the k-shortest paths between source and |
| 136 | * destination devices. |
| 137 | * |
| 138 | * The first {@code maxPaths} paths will be returned |
| 139 | * in ascending order according to the provided {@code weigher} |
| 140 | * |
| 141 | * @param topology topology descriptor |
| 142 | * @param src source device |
| 143 | * @param dst destination device |
| 144 | * @param weigher edge-weight entity |
| 145 | * @param maxPaths maximum number of paths (k) |
| 146 | * @return set of k-shortest paths |
| 147 | */ |
| 148 | default Set<Path> getKShortestPaths(Topology topology, |
| 149 | DeviceId src, DeviceId dst, |
| 150 | LinkWeigher weigher, |
| 151 | int maxPaths) { |
| 152 | return getKShortestPaths(topology, src, dst, weigher) |
| 153 | .limit(maxPaths) |
| 154 | .collect(GuavaCollectors.toImmutableSet()); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Returns the k-shortest paths between source and |
| 159 | * destination devices. |
| 160 | * |
| 161 | * The first {@code maxPaths} paths will be returned |
| 162 | * in ascending order according to the provided {@code weigher} |
| 163 | * |
| 164 | * @param topology topology descriptor |
| 165 | * @param src source device |
| 166 | * @param dst destination device |
| 167 | * @param weigher edge-weight entity |
| 168 | * @return stream of k-shortest paths |
| 169 | */ |
| 170 | default Stream<Path> getKShortestPaths(Topology topology, |
| 171 | DeviceId src, DeviceId dst, |
| 172 | LinkWeigher weigher) { |
| 173 | return getPaths(topology, src, dst, weigher).stream(); |
| 174 | } |
| 175 | |
| 176 | /** |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 177 | * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, |
| 178 | * between the specified source and destination devices. |
| 179 | * |
| 180 | * @param topology topology descriptor |
| 181 | * @param src source device |
| 182 | * @param dst destination device |
| 183 | * @return set of all shortest paths between the two devices |
| 184 | */ |
| 185 | Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst); |
| 186 | |
| 187 | /** |
| 188 | * Returns the set of all disjoint shortest path pairs, computed using the supplied |
| 189 | * edge-weight entity, between the specified source and destination devices. |
| 190 | * |
| 191 | * @param topology topology descriptor |
| 192 | * @param src source device |
| 193 | * @param dst destination device |
| 194 | * @param weight edge-weight entity |
| 195 | * @return set of all shortest paths between the two devices |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 196 | * |
| 197 | * @deprecated in Junco (1.9.0), use version with LinkWeigher instead |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 198 | */ |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 199 | @Deprecated |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 200 | Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, |
| 201 | LinkWeight weight); |
| 202 | |
| 203 | /** |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 204 | * Returns the set of all disjoint shortest path pairs, computed using the supplied |
| 205 | * edge-weight entity, between the specified source and destination devices. |
| 206 | * |
| 207 | * @param topology topology descriptor |
| 208 | * @param src source device |
| 209 | * @param dst destination device |
| 210 | * @param weigher edge-weight entity |
| 211 | * @return set of all shortest paths between the two devices |
| 212 | */ |
| 213 | Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, |
| 214 | LinkWeigher weigher); |
| 215 | |
| 216 | /** |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 217 | * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, |
| 218 | * between the specified source and destination devices. |
| 219 | * |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 220 | * @param topology topology descriptor |
| 221 | * @param src source device |
| 222 | * @param dst destination device |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 223 | * @param riskProfile map of edges to risk profiles |
| 224 | * @return set of all shortest paths between the two devices |
| 225 | */ |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 226 | Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, |
| 227 | Map<Link, Object> riskProfile); |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 228 | |
| 229 | /** |
| 230 | * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, |
| 231 | * between the specified source and destination devices. |
| 232 | * |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 233 | * @param topology topology descriptor |
| 234 | * @param src source device |
| 235 | * @param dst destination device |
| 236 | * @param weight edge-weight entity |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 237 | * @param riskProfile map of edges to risk profiles |
| 238 | * @return set of all shortest paths between the two devices |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 239 | * |
| 240 | * @deprecated in Junco (1.9.0), use version with LinkWeigher instead |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 241 | */ |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 242 | @Deprecated |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 243 | Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, |
| 244 | LinkWeight weight, Map<Link, Object> riskProfile); |
| 245 | |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 246 | /** |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 247 | * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, |
| 248 | * between the specified source and destination devices. |
| 249 | * |
| 250 | * @param topology topology descriptor |
| 251 | * @param src source device |
| 252 | * @param dst destination device |
| 253 | * @param weigher edge-weight entity |
| 254 | * @param riskProfile map of edges to risk profiles |
| 255 | * @return set of all shortest paths between the two devices |
| 256 | */ |
| 257 | Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, |
| 258 | LinkWeigher weigher, Map<Link, Object> riskProfile); |
| 259 | |
| 260 | /** |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 261 | * Indicates whether the specified connection point is part of the network |
| 262 | * infrastructure or part of network edge. |
| 263 | * |
| 264 | * @param topology topology descriptor |
| 265 | * @param connectPoint connection point |
| 266 | * @return true of connection point is in infrastructure; false if edge |
| 267 | */ |
| 268 | boolean isInfrastructure(Topology topology, ConnectPoint connectPoint); |
| 269 | |
| 270 | |
| 271 | /** |
tom | 4d0dd3a | 2014-09-14 23:12:28 -0700 | [diff] [blame] | 272 | * Indicates whether broadcast is allowed for traffic received on the |
| 273 | * specified connection point. |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 274 | * |
| 275 | * @param topology topology descriptor |
| 276 | * @param connectPoint connection point |
| 277 | * @return true if broadcast is permissible |
| 278 | */ |
tom | 4d0dd3a | 2014-09-14 23:12:28 -0700 | [diff] [blame] | 279 | boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint); |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 280 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 281 | } |