blob: 17957e180fab28fbe9c358076950cc14f352530f [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;
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
Andrey Komarov2398d962016-09-26 15:11:23 +0300112 * @param weigher link weight function
113 * @return set of shortest paths
114 */
115 Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
116 LinkWeigher weigher);
117
118 /**
Yuta HIGUCHIac8b2292017-03-30 19:21:57 -0700119 * Computes and returns the k-shortest paths between source and
120 * destination devices.
121 *
122 * The first {@code maxPaths} paths will be returned
123 * in ascending order according to the provided {@code weigher}
124 *
125 * @param topology topology descriptor
126 * @param src source device
127 * @param dst destination device
128 * @param weigher edge-weight entity
129 * @param maxPaths maximum number of paths (k)
130 * @return set of k-shortest paths
131 */
132 default Set<Path> getKShortestPaths(Topology topology,
133 DeviceId src, DeviceId dst,
134 LinkWeigher weigher,
135 int maxPaths) {
136 return getKShortestPaths(topology, src, dst, weigher)
137 .limit(maxPaths)
138 .collect(GuavaCollectors.toImmutableSet());
139 }
140
141 /**
142 * Computes and returns the k-shortest paths between source and
143 * destination devices.
144 *
145 * @param topology topology descriptor
146 * @param src source device
147 * @param dst destination device
148 * @param weigher edge-weight entity
149 * @return stream of k-shortest paths
150 */
151 default Stream<Path> getKShortestPaths(Topology topology,
152 DeviceId src, DeviceId dst,
153 LinkWeigher weigher) {
154 return getPaths(topology, src, dst, weigher).stream();
155 }
156
157 /**
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700158 * Computes and returns the set of disjoint shortest path pairs
159 * between src and dst.
160 *
161 * @param topology topology descriptor
162 * @param src source device
163 * @param dst destination device
Andrey Komarov2398d962016-09-26 15:11:23 +0300164 * @param weigher link weight function
165 * @return set of shortest paths
166 */
167 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
168 LinkWeigher weigher);
169
170 /**
171 * Computes and returns the set of disjoint shortest path pairs
172 * between src and dst.
173 *
174 * @param topology topology descriptor
175 * @param src source device
176 * @param dst destination device
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700177 * @return set of shortest paths
178 */
179 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst);
180
181 /**
182 * Computes and returns the set of SRLG disjoint shortest path pairs between source
183 * and dst, given a mapping of edges to SRLG risk groups.
184 *
Andrey Komarov2398d962016-09-26 15:11:23 +0300185 * @param topology topology descriptor
186 * @param src source device
187 * @param dst destination device
Andrey Komarov2398d962016-09-26 15:11:23 +0300188 * @param weigher link weight function
189 * @param riskProfile map of edges to objects. Edges that map to the same object will
190 * be treated as if they were in the same risk group.
191 * @return set of shortest paths
192 */
193 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
194 LinkWeigher weigher, Map<Link, Object> riskProfile);
195
196 /**
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700197 * Returns the set of pre-computed SRLG shortest paths between src and dest.
198 *
Andrey Komarov2398d962016-09-26 15:11:23 +0300199 * @param topology topology descriptor
200 * @param src source device
201 * @param dst destination device
202 * @param riskProfile map of edges to objects. Edges that map to the same object will
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700203 * be treated as if they were in the same risk group.
204 * @return set of shortest paths
205 */
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700206 Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
207 Map<Link, Object> riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700208
209
210 /**
tom10262dd2014-09-19 10:51:19 -0700211 * Indicates whether the given connect point is part of the network fabric.
212 *
213 * @param topology topology descriptor
214 * @param connectPoint connection point
215 * @return true if infrastructure; false otherwise
216 */
217 boolean isInfrastructure(Topology topology, ConnectPoint connectPoint);
218
219 /**
220 * Indicates whether broadcast is allowed for traffic received on the
221 * given connection point.
222 *
223 * @param topology topology descriptor
224 * @param connectPoint connection point
225 * @return true if broadcast allowed; false otherwise
226 */
227 boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint);
228
229 /**
230 * Generates a new topology snapshot from the specified description.
231 *
232 * @param providerId provider identification
233 * @param graphDescription topology graph description
234 * @param reasons list of events that triggered the update
235 * @return topology update event or null if the description is old
236 */
237 TopologyEvent updateTopology(ProviderId providerId,
238 GraphDescription graphDescription,
239 List<Event> reasons);
240}