Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.topology; |
tom | 10262dd | 2014-09-19 10:51:19 -0700 | [diff] [blame] | 17 | |
Yuta HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 18 | import org.onlab.util.GuavaCollectors; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 19 | import org.onosproject.event.Event; |
| 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.Link; |
| 23 | import org.onosproject.net.Path; |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 24 | import org.onosproject.net.DisjointPath; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 25 | import org.onosproject.net.provider.ProviderId; |
| 26 | import org.onosproject.store.Store; |
tom | 10262dd | 2014-09-19 10:51:19 -0700 | [diff] [blame] | 27 | |
| 28 | import java.util.List; |
| 29 | import java.util.Set; |
Yuta HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 30 | import java.util.stream.Stream; |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 31 | import java.util.Map; |
tom | 10262dd | 2014-09-19 10:51:19 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 34 | * Manages inventory of topology snapshots; not intended for direct use. |
tom | 10262dd | 2014-09-19 10:51:19 -0700 | [diff] [blame] | 35 | */ |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 36 | public interface TopologyStore extends Store<TopologyEvent, TopologyStoreDelegate> { |
tom | 10262dd | 2014-09-19 10:51:19 -0700 | [diff] [blame] | 37 | |
| 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 Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 112 | * @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 HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 119 | * 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 Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 158 | * 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 Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 164 | * @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 Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 177 | * @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 Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 185 | * @param topology topology descriptor |
| 186 | * @param src source device |
| 187 | * @param dst destination device |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 188 | * @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 Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 197 | * Returns the set of pre-computed SRLG shortest paths between src and dest. |
| 198 | * |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 199 | * @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 Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 203 | * be treated as if they were in the same risk group. |
| 204 | * @return set of shortest paths |
| 205 | */ |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 206 | Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, |
| 207 | Map<Link, Object> riskProfile); |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 208 | |
| 209 | |
| 210 | /** |
tom | 10262dd | 2014-09-19 10:51:19 -0700 | [diff] [blame] | 211 | * 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 | } |