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 | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 17 | |
Yuta HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 18 | import org.onlab.util.GuavaCollectors; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 19 | import org.onosproject.event.ListenerService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.DeviceId; |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 22 | import org.onosproject.net.DisjointPath; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.net.Link; |
| 24 | import org.onosproject.net.Path; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 25 | |
Yuta HIGUCHI | a684b6e | 2017-05-18 22:29:22 -0700 | [diff] [blame] | 26 | import static org.onosproject.net.topology.HopCountLinkWeigher.DEFAULT_HOP_COUNT_WEIGHER; |
| 27 | |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 28 | import java.util.Map; |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 29 | import java.util.Set; |
Yuta HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 30 | import java.util.stream.Stream; |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 31 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 32 | /** |
| 33 | * Service for providing network topology information. |
| 34 | */ |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 35 | public interface TopologyService |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 36 | extends ListenerService<TopologyEvent, TopologyListener> { |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * Returns the current topology descriptor. |
| 40 | * |
| 41 | * @return current topology |
| 42 | */ |
| 43 | Topology currentTopology(); |
| 44 | |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 45 | /** |
tom | dc361b6 | 2014-09-09 20:36:52 -0700 | [diff] [blame] | 46 | * Indicates whether the specified topology is the latest or not. |
tom | e52ce70 | 2014-09-11 00:12:54 -0700 | [diff] [blame] | 47 | * |
tom | dc361b6 | 2014-09-09 20:36:52 -0700 | [diff] [blame] | 48 | * @param topology topology descriptor |
| 49 | * @return true if the topology is the most recent; false otherwise |
| 50 | */ |
| 51 | boolean isLatest(Topology topology); |
| 52 | |
| 53 | /** |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 54 | * 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 | /** |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 62 | * 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 | /** |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 70 | * Returns the cluster with the specified ID. |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 71 | * |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 72 | * @param topology topology descriptor |
| 73 | * @param clusterId cluster identifier |
| 74 | * @return topology cluster |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 75 | */ |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 76 | TopologyCluster getCluster(Topology topology, ClusterId clusterId); |
| 77 | |
| 78 | /** |
| 79 | * Returns the set of devices that belong to the specified cluster. |
| 80 | * |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 81 | * @param topology topology descriptor |
| 82 | * @param cluster topology cluster |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 83 | * @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 Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 90 | * @param topology topology descriptor |
| 91 | * @param cluster topology cluster |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 92 | * @return set of cluster links |
| 93 | */ |
| 94 | Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster); |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 95 | |
| 96 | /** |
tom | cfde062 | 2014-09-09 11:02:42 -0700 | [diff] [blame] | 97 | * Returns the set of all shortest paths, precomputed in terms of hop-count, |
| 98 | * between the specified source and destination devices. |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 99 | * |
| 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 Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 114 | * @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 HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 121 | * 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 HIGUCHI | a684b6e | 2017-05-18 22:29:22 -0700 | [diff] [blame] | 147 | * @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 HIGUCHI | ac8b229 | 2017-03-30 19:21:57 -0700 | [diff] [blame] | 160 | * |
| 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 Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 174 | * 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 Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 191 | * @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 Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 198 | * 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 Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 201 | * @param topology topology descriptor |
| 202 | * @param src source device |
| 203 | * @param dst destination device |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 204 | * @param riskProfile map of edges to risk profiles |
| 205 | * @return set of all shortest paths between the two devices |
| 206 | */ |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 207 | Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, |
| 208 | Map<Link, Object> riskProfile); |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 209 | |
| 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 Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 214 | * @param topology topology descriptor |
| 215 | * @param src source device |
| 216 | * @param dst destination device |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 217 | * @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 | /** |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 225 | * 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 | /** |
tom | 4d0dd3a | 2014-09-14 23:12:28 -0700 | [diff] [blame] | 236 | * Indicates whether broadcast is allowed for traffic received on the |
| 237 | * specified connection point. |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 238 | * |
| 239 | * @param topology topology descriptor |
| 240 | * @param connectPoint connection point |
| 241 | * @return true if broadcast is permissible |
| 242 | */ |
tom | 4d0dd3a | 2014-09-14 23:12:28 -0700 | [diff] [blame] | 243 | boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint); |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 244 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 245 | } |