Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
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.impl; |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 17 | |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 18 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; |
Yuta HIGUCHI | 90e1229 | 2016-08-02 18:02:53 -0700 | [diff] [blame] | 21 | import org.apache.felix.scr.annotations.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 23 | import org.apache.felix.scr.annotations.Service; |
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.ElementId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 26 | import org.onosproject.net.Link; |
| 27 | import org.onosproject.net.Path; |
Yuta HIGUCHI | 90e1229 | 2016-08-02 18:02:53 -0700 | [diff] [blame] | 28 | import org.onosproject.net.host.HostService; |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 29 | import org.onosproject.net.topology.LinkWeigher; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 30 | import org.onosproject.net.topology.LinkWeight; |
| 31 | import org.onosproject.net.topology.PathService; |
Yuta HIGUCHI | 90e1229 | 2016-08-02 18:02:53 -0700 | [diff] [blame] | 32 | import org.onosproject.net.topology.TopologyService; |
Claudine Chiu | 45920dd | 2016-07-28 19:19:46 +0000 | [diff] [blame] | 33 | import org.onosproject.net.topology.AbstractPathService; |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 34 | import org.slf4j.Logger; |
| 35 | |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 36 | import java.util.Set; |
Yuta HIGUCHI | a684b6e | 2017-05-18 22:29:22 -0700 | [diff] [blame] | 37 | import java.util.stream.Stream; |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 38 | import java.util.Map; |
| 39 | |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 40 | |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 41 | import static org.slf4j.LoggerFactory.getLogger; |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 42 | import static org.onosproject.security.AppGuard.checkPermission; |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 43 | import static org.onosproject.security.AppPermission.Type.*; |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 44 | |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Provides implementation of a path selection service atop the current |
| 48 | * topology and host services. |
| 49 | */ |
| 50 | @Component(immediate = true) |
| 51 | @Service |
Claudine Chiu | 45920dd | 2016-07-28 19:19:46 +0000 | [diff] [blame] | 52 | public class PathManager extends AbstractPathService implements PathService { |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 53 | |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 54 | private final Logger log = getLogger(getClass()); |
| 55 | |
Yuta HIGUCHI | 90e1229 | 2016-08-02 18:02:53 -0700 | [diff] [blame] | 56 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 57 | protected TopologyService topologyService; |
| 58 | |
| 59 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 60 | protected HostService hostService; |
| 61 | |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 62 | @Activate |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 63 | public void activate() { |
Yuta HIGUCHI | 90e1229 | 2016-08-02 18:02:53 -0700 | [diff] [blame] | 64 | // initialize AbstractPathService |
| 65 | super.topologyService = this.topologyService; |
| 66 | super.hostService = this.hostService; |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 67 | log.info("Started"); |
| 68 | } |
| 69 | |
| 70 | @Deactivate |
tom | ca90c46 | 2014-09-22 11:40:58 -0700 | [diff] [blame] | 71 | public void deactivate() { |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 72 | log.info("Stopped"); |
| 73 | } |
| 74 | |
| 75 | @Override |
tom | cbefa23 | 2014-09-16 14:17:20 -0700 | [diff] [blame] | 76 | public Set<Path> getPaths(ElementId src, ElementId dst) { |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 77 | checkPermission(TOPOLOGY_READ); |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 78 | |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 79 | return getPaths(src, dst, (LinkWeigher) null); |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | @Override |
tom | cbefa23 | 2014-09-16 14:17:20 -0700 | [diff] [blame] | 83 | public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) { |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 84 | checkPermission(TOPOLOGY_READ); |
Claudine Chiu | 45920dd | 2016-07-28 19:19:46 +0000 | [diff] [blame] | 85 | return super.getPaths(src, dst, weight); |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 88 | @Override |
| 89 | public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) { |
| 90 | checkPermission(TOPOLOGY_READ); |
| 91 | return super.getPaths(src, dst, weigher); |
| 92 | } |
| 93 | |
Yuta HIGUCHI | a684b6e | 2017-05-18 22:29:22 -0700 | [diff] [blame] | 94 | @Override |
| 95 | public Stream<Path> getKShortestPaths(ElementId src, ElementId dst, |
| 96 | LinkWeigher weigher) { |
| 97 | checkPermission(TOPOLOGY_READ); |
| 98 | return super.getKShortestPaths(src, dst, weigher); |
| 99 | } |
Claudine Chiu | 45920dd | 2016-07-28 19:19:46 +0000 | [diff] [blame] | 100 | |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 101 | @Override |
| 102 | public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) { |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 103 | checkPermission(TOPOLOGY_READ); |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 104 | return getDisjointPaths(src, dst, (LinkWeigher) null); |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) { |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 109 | checkPermission(TOPOLOGY_READ); |
Claudine Chiu | 45920dd | 2016-07-28 19:19:46 +0000 | [diff] [blame] | 110 | return super.getDisjointPaths(src, dst, weight); |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | @Override |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 114 | public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher) { |
| 115 | checkPermission(TOPOLOGY_READ); |
| 116 | return super.getDisjointPaths(src, dst, weigher); |
| 117 | } |
| 118 | |
| 119 | @Override |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 120 | public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, |
| 121 | Map<Link, Object> riskProfile) { |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 122 | checkPermission(TOPOLOGY_READ); |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 123 | return getDisjointPaths(src, dst, (LinkWeigher) null, riskProfile); |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | @Override |
Thomas Vachuska | 48e64e4 | 2015-09-22 15:32:55 -0700 | [diff] [blame] | 127 | public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight, |
| 128 | Map<Link, Object> riskProfile) { |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 129 | checkPermission(TOPOLOGY_READ); |
Claudine Chiu | 45920dd | 2016-07-28 19:19:46 +0000 | [diff] [blame] | 130 | return super.getDisjointPaths(src, dst, weight, riskProfile); |
Nikhil Cheerla | 2ec191f | 2015-07-09 12:34:54 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 133 | @Override |
| 134 | public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher, |
| 135 | Map<Link, Object> riskProfile) { |
| 136 | checkPermission(TOPOLOGY_READ); |
| 137 | return super.getDisjointPaths(src, dst, weigher, riskProfile); |
| 138 | } |
| 139 | |
tom | 4774c8f | 2014-09-16 11:17:08 -0700 | [diff] [blame] | 140 | } |