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