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