blob: ee70ed7a04380432f071fdf0e73be36bab90fdfc [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
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
Andrey Komarov2398d962016-09-26 15:11:23 +0300114 * @param weigher edge-weight entity
115 * @return set of all shortest paths between the two devices
116 */
117 Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
118 LinkWeigher weigher);
119
120 /**
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -0700121 * Returns the k-shortest paths between source and
122 * destination devices.
123 *
124 * The first {@code maxPaths} paths will be returned
125 * in ascending order according to the provided {@code weigher}
126 *
127 * @param topology topology descriptor
128 * @param src source device
129 * @param dst destination device
130 * @param weigher edge-weight entity
131 * @param maxPaths maximum number of paths (k)
132 * @return set of k-shortest paths
133 */
134 default Set<Path> getKShortestPaths(Topology topology,
135 DeviceId src, DeviceId dst,
136 LinkWeigher weigher,
137 int maxPaths) {
138 return getKShortestPaths(topology, src, dst, weigher)
139 .limit(maxPaths)
140 .collect(GuavaCollectors.toImmutableSet());
141 }
142
143 /**
144 * Returns the k-shortest paths between source and
145 * destination devices.
146 *
Yuta HIGUCHIa684b6e2017-05-18 22:29:22 -0700147 * @param topology topology descriptor
148 * @param src source device
149 * @param dst destination device
150 * @return stream of k-shortest paths
151 */
152 default Stream<Path> getKShortestPaths(Topology topology,
153 DeviceId src, DeviceId dst) {
154 return getKShortestPaths(topology, src, dst, DEFAULT_HOP_COUNT_WEIGHER);
155 }
156
157 /**
158 * Returns the k-shortest paths between source and
159 * destination devices.
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -0700160 *
161 * @param topology topology descriptor
162 * @param src source device
163 * @param dst destination device
164 * @param weigher edge-weight entity
165 * @return stream of k-shortest paths
166 */
167 default Stream<Path> getKShortestPaths(Topology topology,
168 DeviceId src, DeviceId dst,
169 LinkWeigher weigher) {
170 return getPaths(topology, src, dst, weigher).stream();
171 }
172
173 /**
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700174 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
175 * between the specified source and destination devices.
176 *
177 * @param topology topology descriptor
178 * @param src source device
179 * @param dst destination device
180 * @return set of all shortest paths between the two devices
181 */
182 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst);
183
184 /**
185 * Returns the set of all disjoint shortest path pairs, computed using the supplied
186 * edge-weight entity, between the specified source and destination devices.
187 *
188 * @param topology topology descriptor
189 * @param src source device
190 * @param dst destination device
Andrey Komarov2398d962016-09-26 15:11:23 +0300191 * @param weigher edge-weight entity
192 * @return set of all shortest paths between the two devices
193 */
194 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
195 LinkWeigher weigher);
196
197 /**
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700198 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
199 * between the specified source and destination devices.
200 *
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700201 * @param topology topology descriptor
202 * @param src source device
203 * @param dst destination device
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700204 * @param riskProfile map of edges to risk profiles
205 * @return set of all shortest paths between the two devices
206 */
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700207 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
208 Map<Link, Object> riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700209
210 /**
211 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
212 * between the specified source and destination devices.
213 *
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700214 * @param topology topology descriptor
215 * @param src source device
216 * @param dst destination device
Andrey Komarov2398d962016-09-26 15:11:23 +0300217 * @param weigher edge-weight entity
218 * @param riskProfile map of edges to risk profiles
219 * @return set of all shortest paths between the two devices
220 */
221 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
222 LinkWeigher weigher, Map<Link, Object> riskProfile);
223
224 /**
tom568581d2014-09-08 20:13:36 -0700225 * Indicates whether the specified connection point is part of the network
226 * infrastructure or part of network edge.
227 *
228 * @param topology topology descriptor
229 * @param connectPoint connection point
230 * @return true of connection point is in infrastructure; false if edge
231 */
232 boolean isInfrastructure(Topology topology, ConnectPoint connectPoint);
233
234
235 /**
tom4d0dd3a2014-09-14 23:12:28 -0700236 * Indicates whether broadcast is allowed for traffic received on the
237 * specified connection point.
tom568581d2014-09-08 20:13:36 -0700238 *
239 * @param topology topology descriptor
240 * @param connectPoint connection point
241 * @return true if broadcast is permissible
242 */
tom4d0dd3a2014-09-14 23:12:28 -0700243 boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint);
tomedf06bb2014-08-27 16:22:15 -0700244
tomedf06bb2014-08-27 16:22:15 -0700245}