blob: 76ae91eb29f4822aeda623566cff0339a8912ee1 [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
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070026import java.util.Map;
tom568581d2014-09-08 20:13:36 -070027import java.util.Set;
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -070028import java.util.stream.Stream;
tom568581d2014-09-08 20:13:36 -070029
tomedf06bb2014-08-27 16:22:15 -070030/**
31 * Service for providing network topology information.
32 */
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070033public interface TopologyService
Thomas Vachuska48e64e42015-09-22 15:32:55 -070034 extends ListenerService<TopologyEvent, TopologyListener> {
tomedf06bb2014-08-27 16:22:15 -070035
36 /**
37 * Returns the current topology descriptor.
38 *
39 * @return current topology
40 */
41 Topology currentTopology();
42
tom568581d2014-09-08 20:13:36 -070043 /**
tomdc361b62014-09-09 20:36:52 -070044 * Indicates whether the specified topology is the latest or not.
tome52ce702014-09-11 00:12:54 -070045 *
tomdc361b62014-09-09 20:36:52 -070046 * @param topology topology descriptor
47 * @return true if the topology is the most recent; false otherwise
48 */
49 boolean isLatest(Topology topology);
50
51 /**
tom13cb4852014-09-11 12:44:17 -070052 * 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 /**
tom568581d2014-09-08 20:13:36 -070060 * 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 /**
tom13cb4852014-09-11 12:44:17 -070068 * Returns the cluster with the specified ID.
tom568581d2014-09-08 20:13:36 -070069 *
tom13cb4852014-09-11 12:44:17 -070070 * @param topology topology descriptor
71 * @param clusterId cluster identifier
72 * @return topology cluster
tom568581d2014-09-08 20:13:36 -070073 */
tom13cb4852014-09-11 12:44:17 -070074 TopologyCluster getCluster(Topology topology, ClusterId clusterId);
75
76 /**
77 * Returns the set of devices that belong to the specified cluster.
78 *
Thomas Vachuska48e64e42015-09-22 15:32:55 -070079 * @param topology topology descriptor
80 * @param cluster topology cluster
tom13cb4852014-09-11 12:44:17 -070081 * @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 Vachuska48e64e42015-09-22 15:32:55 -070088 * @param topology topology descriptor
89 * @param cluster topology cluster
tom13cb4852014-09-11 12:44:17 -070090 * @return set of cluster links
91 */
92 Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster);
tom568581d2014-09-08 20:13:36 -070093
94 /**
tomcfde0622014-09-09 11:02:42 -070095 * Returns the set of all shortest paths, precomputed in terms of hop-count,
96 * between the specified source and destination devices.
tom568581d2014-09-08 20:13:36 -070097 *
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 HIGUCHI5c947272014-11-03 21:39:21 -0800112 * @param weight edge-weight entity
tom568581d2014-09-08 20:13:36 -0700113 * @return set of all shortest paths between the two devices
Andrey Komarov2398d962016-09-26 15:11:23 +0300114 *
115 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
tom568581d2014-09-08 20:13:36 -0700116 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300117 @Deprecated
tom568581d2014-09-08 20:13:36 -0700118 Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
119 LinkWeight weight);
120
121 /**
Andrey Komarov2398d962016-09-26 15:11:23 +0300122 * 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 HIGUCHIac8b2292017-03-30 19:21:57 -0700135 * 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 Cheerla2ec191f2015-07-09 12:34:54 -0700177 * 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 Komarov2398d962016-09-26 15:11:23 +0300196 *
197 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700198 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300199 @Deprecated
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700200 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
201 LinkWeight weight);
202
203 /**
Andrey Komarov2398d962016-09-26 15:11:23 +0300204 * 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 Cheerla2ec191f2015-07-09 12:34:54 -0700217 * 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 Vachuska48e64e42015-09-22 15:32:55 -0700220 * @param topology topology descriptor
221 * @param src source device
222 * @param dst destination device
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700223 * @param riskProfile map of edges to risk profiles
224 * @return set of all shortest paths between the two devices
225 */
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700226 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
227 Map<Link, Object> riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700228
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 Vachuska48e64e42015-09-22 15:32:55 -0700233 * @param topology topology descriptor
234 * @param src source device
235 * @param dst destination device
236 * @param weight edge-weight entity
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700237 * @param riskProfile map of edges to risk profiles
238 * @return set of all shortest paths between the two devices
Andrey Komarov2398d962016-09-26 15:11:23 +0300239 *
240 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700241 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300242 @Deprecated
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700243 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
244 LinkWeight weight, Map<Link, Object> riskProfile);
245
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700246 /**
Andrey Komarov2398d962016-09-26 15:11:23 +0300247 * 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 /**
tom568581d2014-09-08 20:13:36 -0700261 * 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 /**
tom4d0dd3a2014-09-14 23:12:28 -0700272 * Indicates whether broadcast is allowed for traffic received on the
273 * specified connection point.
tom568581d2014-09-08 20:13:36 -0700274 *
275 * @param topology topology descriptor
276 * @param connectPoint connection point
277 * @return true if broadcast is permissible
278 */
tom4d0dd3a2014-09-14 23:12:28 -0700279 boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint);
tomedf06bb2014-08-27 16:22:15 -0700280
tomedf06bb2014-08-27 16:22:15 -0700281}