blob: d87fff01aaa5a4d87c4bdc2a148a00939bf99df2 [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;
tom10262dd2014-09-19 10:51:19 -070017
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -070018import org.onlab.util.GuavaCollectors;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.event.Event;
20import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.Link;
23import org.onosproject.net.Path;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070024import org.onosproject.net.DisjointPath;
Brian O'Connorabafb502014-12-02 22:26:20 -080025import org.onosproject.net.provider.ProviderId;
26import org.onosproject.store.Store;
tom10262dd2014-09-19 10:51:19 -070027
28import java.util.List;
29import java.util.Set;
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -070030import java.util.stream.Stream;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070031import java.util.Map;
tom10262dd2014-09-19 10:51:19 -070032
33/**
tome4729872014-09-23 00:37:37 -070034 * Manages inventory of topology snapshots; not intended for direct use.
tom10262dd2014-09-19 10:51:19 -070035 */
tomc78acee2014-09-24 15:16:55 -070036public interface TopologyStore extends Store<TopologyEvent, TopologyStoreDelegate> {
tom10262dd2014-09-19 10:51:19 -070037
38 /**
39 * Returns the current topology snapshot.
40 *
41 * @return current topology descriptor
42 */
43 Topology currentTopology();
44
45 /**
46 * Indicates whether the topology is the latest.
47 *
48 * @param topology topology descriptor
49 * @return true if topology is the most recent one
50 */
51 boolean isLatest(Topology topology);
52
53 /**
54 * Returns the immutable graph view of the current topology.
55 *
56 * @param topology topology descriptor
57 * @return graph view
58 */
59 TopologyGraph getGraph(Topology topology);
60
61 /**
62 * Returns the set of topology SCC clusters.
63 *
64 * @param topology topology descriptor
65 * @return set of clusters
66 */
67 Set<TopologyCluster> getClusters(Topology topology);
68
69 /**
70 * Returns the cluster of the specified topology.
71 *
72 * @param topology topology descriptor
73 * @param clusterId cluster identity
74 * @return topology cluster
75 */
76 TopologyCluster getCluster(Topology topology, ClusterId clusterId);
77
78 /**
79 * Returns the cluster of the specified topology.
80 *
81 * @param topology topology descriptor
82 * @param cluster topology cluster
83 * @return set of cluster links
84 */
85 Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster);
86
87 /**
88 * Returns the cluster of the specified topology.
89 *
90 * @param topology topology descriptor
91 * @param cluster topology cluster
92 * @return set of cluster links
93 */
94 Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster);
95
96 /**
97 * Returns the set of pre-computed shortest paths between src and dest.
98 *
99 * @param topology topology descriptor
100 * @param src source device
101 * @param dst destination device
102 * @return set of shortest paths
103 */
104 Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst);
105
106 /**
107 * Computes and returns the set of shortest paths between src and dest.
108 *
109 * @param topology topology descriptor
110 * @param src source device
111 * @param dst destination device
112 * @param weight link weight function
113 * @return set of shortest paths
Andrey Komarov2398d962016-09-26 15:11:23 +0300114 *
115 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
tom10262dd2014-09-19 10:51:19 -0700116 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300117 @Deprecated
tom10262dd2014-09-19 10:51:19 -0700118 Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
119 LinkWeight weight);
120
121 /**
Andrey Komarov2398d962016-09-26 15:11:23 +0300122 * Computes and returns the set of shortest paths between src and dest.
123 *
124 * @param topology topology descriptor
125 * @param src source device
126 * @param dst destination device
127 * @param weigher link weight function
128 * @return set of shortest paths
129 */
130 Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
131 LinkWeigher weigher);
132
133 /**
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -0700134 * Computes and returns the k-shortest paths between source and
135 * destination devices.
136 *
137 * The first {@code maxPaths} paths will be returned
138 * in ascending order according to the provided {@code weigher}
139 *
140 * @param topology topology descriptor
141 * @param src source device
142 * @param dst destination device
143 * @param weigher edge-weight entity
144 * @param maxPaths maximum number of paths (k)
145 * @return set of k-shortest paths
146 */
147 default Set<Path> getKShortestPaths(Topology topology,
148 DeviceId src, DeviceId dst,
149 LinkWeigher weigher,
150 int maxPaths) {
151 return getKShortestPaths(topology, src, dst, weigher)
152 .limit(maxPaths)
153 .collect(GuavaCollectors.toImmutableSet());
154 }
155
156 /**
157 * Computes and returns the k-shortest paths between source and
158 * destination devices.
159 *
160 * @param topology topology descriptor
161 * @param src source device
162 * @param dst destination device
163 * @param weigher edge-weight entity
164 * @return stream of k-shortest paths
165 */
166 default Stream<Path> getKShortestPaths(Topology topology,
167 DeviceId src, DeviceId dst,
168 LinkWeigher weigher) {
169 return getPaths(topology, src, dst, weigher).stream();
170 }
171
172 /**
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700173 * Computes and returns the set of disjoint shortest path pairs
174 * between src and dst.
175 *
176 * @param topology topology descriptor
177 * @param src source device
178 * @param dst destination device
179 * @param weight link weight function
180 * @return set of shortest paths
Andrey Komarov2398d962016-09-26 15:11:23 +0300181 *
182 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700183 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300184 @Deprecated
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700185 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
186 LinkWeight weight);
187
188 /**
189 * Computes and returns the set of disjoint shortest path pairs
190 * between src and dst.
191 *
192 * @param topology topology descriptor
193 * @param src source device
194 * @param dst destination device
Andrey Komarov2398d962016-09-26 15:11:23 +0300195 * @param weigher link weight function
196 * @return set of shortest paths
197 */
198 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
199 LinkWeigher weigher);
200
201 /**
202 * Computes and returns the set of disjoint shortest path pairs
203 * between src and dst.
204 *
205 * @param topology topology descriptor
206 * @param src source device
207 * @param dst destination device
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700208 * @return set of shortest paths
209 */
210 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst);
211
212 /**
213 * Computes and returns the set of SRLG disjoint shortest path pairs between source
214 * and dst, given a mapping of edges to SRLG risk groups.
215 *
Andrey Komarov2398d962016-09-26 15:11:23 +0300216 * @param topology topology descriptor
217 * @param src source device
218 * @param dst destination device
219 * @param weight link weight function
220 * @param riskProfile map of edges to objects. Edges that map to the same object will
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700221 * be treated as if they were in the same risk group.
222 * @return set of shortest paths
Andrey Komarov2398d962016-09-26 15:11:23 +0300223 *
224 * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700225 */
Andrey Komarov2398d962016-09-26 15:11:23 +0300226 @Deprecated
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700227 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
228 LinkWeight weight, Map<Link, Object> riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700229
230 /**
Andrey Komarov2398d962016-09-26 15:11:23 +0300231 * Computes and returns the set of SRLG disjoint shortest path pairs between source
232 * and dst, given a mapping of edges to SRLG risk groups.
233 *
234 * @param topology topology descriptor
235 * @param src source device
236 * @param dst destination device
237 * @param weigher link weight function
238 * @param riskProfile map of edges to objects. Edges that map to the same object will
239 * be treated as if they were in the same risk group.
240 * @return set of shortest paths
241 */
242 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
243 LinkWeigher weigher, Map<Link, Object> riskProfile);
244
245 /**
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700246 * Returns the set of pre-computed SRLG shortest paths between src and dest.
247 *
Andrey Komarov2398d962016-09-26 15:11:23 +0300248 * @param topology topology descriptor
249 * @param src source device
250 * @param dst destination device
251 * @param riskProfile map of edges to objects. Edges that map to the same object will
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700252 * be treated as if they were in the same risk group.
253 * @return set of shortest paths
254 */
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700255 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
256 Map<Link, Object> riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700257
258
259 /**
tom10262dd2014-09-19 10:51:19 -0700260 * Indicates whether the given connect point is part of the network fabric.
261 *
262 * @param topology topology descriptor
263 * @param connectPoint connection point
264 * @return true if infrastructure; false otherwise
265 */
266 boolean isInfrastructure(Topology topology, ConnectPoint connectPoint);
267
268 /**
269 * Indicates whether broadcast is allowed for traffic received on the
270 * given connection point.
271 *
272 * @param topology topology descriptor
273 * @param connectPoint connection point
274 * @return true if broadcast allowed; false otherwise
275 */
276 boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint);
277
278 /**
279 * Generates a new topology snapshot from the specified description.
280 *
281 * @param providerId provider identification
282 * @param graphDescription topology graph description
283 * @param reasons list of events that triggered the update
284 * @return topology update event or null if the description is old
285 */
286 TopologyEvent updateTopology(ProviderId providerId,
287 GraphDescription graphDescription,
288 List<Event> reasons);
289}