blob: 70a38f9e427e6d3b27ac9bf0aa5bb79bd99e5540 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.topology;
tomedf06bb2014-08-27 16:22:15 -070017
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -070018import org.onlab.util.GuavaCollectors;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070019import org.onosproject.event.ListenerService;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.DeviceId;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070022import org.onosproject.net.DisjointPath;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.Link;
24import org.onosproject.net.Path;
tomedf06bb2014-08-27 16:22:15 -070025
Yuta HIGUCHIa684b6e2017-05-18 22:29:22 -070026import static org.onosproject.net.topology.HopCountLinkWeigher.DEFAULT_HOP_COUNT_WEIGHER;
27
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070028import java.util.Map;
tom568581d2014-09-08 20:13:36 -070029import java.util.Set;
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -070030import java.util.stream.Stream;
tom568581d2014-09-08 20:13:36 -070031
tomedf06bb2014-08-27 16:22:15 -070032/**
33 * Service for providing network topology information.
34 */
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070035public interface TopologyService
Thomas Vachuska48e64e42015-09-22 15:32:55 -070036 extends ListenerService<TopologyEvent, TopologyListener> {
tomedf06bb2014-08-27 16:22:15 -070037
38 /**
39 * Returns the current topology descriptor.
40 *
41 * @return current topology
42 */
43 Topology currentTopology();
44
tom568581d2014-09-08 20:13:36 -070045 /**
tomdc361b62014-09-09 20:36:52 -070046 * Indicates whether the specified topology is the latest or not.
tome52ce702014-09-11 00:12:54 -070047 *
tomdc361b62014-09-09 20:36:52 -070048 * @param topology topology descriptor
49 * @return true if the topology is the most recent; false otherwise
50 */
51 boolean isLatest(Topology topology);
52
53 /**
tom13cb4852014-09-11 12:44:17 -070054 * 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 /**
tom568581d2014-09-08 20:13:36 -070062 * 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 /**
tom13cb4852014-09-11 12:44:17 -070070 * Returns the cluster with the specified ID.
tom568581d2014-09-08 20:13:36 -070071 *
tom13cb4852014-09-11 12:44:17 -070072 * @param topology topology descriptor
73 * @param clusterId cluster identifier
74 * @return topology cluster
tom568581d2014-09-08 20:13:36 -070075 */
tom13cb4852014-09-11 12:44:17 -070076 TopologyCluster getCluster(Topology topology, ClusterId clusterId);
77
78 /**
79 * Returns the set of devices that belong to the specified cluster.
80 *
Thomas Vachuska48e64e42015-09-22 15:32:55 -070081 * @param topology topology descriptor
82 * @param cluster topology cluster
tom13cb4852014-09-11 12:44:17 -070083 * @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 Vachuska48e64e42015-09-22 15:32:55 -070090 * @param topology topology descriptor
91 * @param cluster topology cluster
tom13cb4852014-09-11 12:44:17 -070092 * @return set of cluster links
93 */
94 Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster);
tom568581d2014-09-08 20:13:36 -070095
96 /**
tomcfde0622014-09-09 11:02:42 -070097 * Returns the set of all shortest paths, precomputed in terms of hop-count,
98 * between the specified source and destination devices.
tom568581d2014-09-08 20:13:36 -070099 *
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 HIGUCHI5c947272014-11-03 21:39:21 -0800114 * @param weight edge-weight entity
tom568581d2014-09-08 20:13:36 -0700115 * @return set of all shortest paths between the two devices
Andrey Komarov2398d962016-09-26 15:11:23 +0300116 *
117 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
tom568581d2014-09-08 20:13:36 -0700118 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300119 @Deprecated
tom568581d2014-09-08 20:13:36 -0700120 Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
121 LinkWeight weight);
122
123 /**
Andrey Komarov2398d962016-09-26 15:11:23 +0300124 * 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 HIGUCHIac8b2292017-03-30 19:21:57 -0700137 * 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 HIGUCHIa684b6e2017-05-18 22:29:22 -0700163 * @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 HIGUCHIac8b2292017-03-30 19:21:57 -0700176 *
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 Cheerla2ec191f2015-07-09 12:34:54 -0700190 * 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 Komarov2398d962016-09-26 15:11:23 +0300209 *
210 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700211 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300212 @Deprecated
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700213 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
214 LinkWeight weight);
215
216 /**
Andrey Komarov2398d962016-09-26 15:11:23 +0300217 * 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 Cheerla2ec191f2015-07-09 12:34:54 -0700230 * 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 Vachuska48e64e42015-09-22 15:32:55 -0700233 * @param topology topology descriptor
234 * @param src source device
235 * @param dst destination device
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700236 * @param riskProfile map of edges to risk profiles
237 * @return set of all shortest paths between the two devices
238 */
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700239 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
240 Map<Link, Object> riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700241
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 Vachuska48e64e42015-09-22 15:32:55 -0700246 * @param topology topology descriptor
247 * @param src source device
248 * @param dst destination device
249 * @param weight edge-weight entity
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700250 * @param riskProfile map of edges to risk profiles
251 * @return set of all shortest paths between the two devices
Andrey Komarov2398d962016-09-26 15:11:23 +0300252 *
253 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700254 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300255 @Deprecated
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700256 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
257 LinkWeight weight, Map<Link, Object> riskProfile);
258
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700259 /**
Andrey Komarov2398d962016-09-26 15:11:23 +0300260 * 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 /**
tom568581d2014-09-08 20:13:36 -0700274 * 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 /**
tom4d0dd3a2014-09-14 23:12:28 -0700285 * Indicates whether broadcast is allowed for traffic received on the
286 * specified connection point.
tom568581d2014-09-08 20:13:36 -0700287 *
288 * @param topology topology descriptor
289 * @param connectPoint connection point
290 * @return true if broadcast is permissible
291 */
tom4d0dd3a2014-09-14 23:12:28 -0700292 boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint);
tomedf06bb2014-08-27 16:22:15 -0700293
tomedf06bb2014-08-27 16:22:15 -0700294}