blob: 6f0a1b8213907b12ccfd1ea6c9aa1d310f3d7fc1 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
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.impl;
tom4774c8f2014-09-16 11:17:08 -070017
tom4774c8f2014-09-16 11:17:08 -070018import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070021import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
tom4774c8f2014-09-16 11:17:08 -070023import org.apache.felix.scr.annotations.Service;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070024import org.onosproject.net.DisjointPath;
Brian O'Connorabafb502014-12-02 22:26:20 -080025import org.onosproject.net.ElementId;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import org.onosproject.net.Link;
27import org.onosproject.net.Path;
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070028import org.onosproject.net.host.HostService;
Andrey Komarov2398d962016-09-26 15:11:23 +030029import org.onosproject.net.topology.LinkWeigher;
Brian O'Connorabafb502014-12-02 22:26:20 -080030import org.onosproject.net.topology.LinkWeight;
31import org.onosproject.net.topology.PathService;
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070032import org.onosproject.net.topology.TopologyService;
Claudine Chiu45920dd2016-07-28 19:19:46 +000033import org.onosproject.net.topology.AbstractPathService;
tom4774c8f2014-09-16 11:17:08 -070034import org.slf4j.Logger;
35
tom4774c8f2014-09-16 11:17:08 -070036import java.util.Set;
Yuta HIGUCHIa684b6e2017-05-18 22:29:22 -070037import java.util.stream.Stream;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070038import java.util.Map;
39
tom4774c8f2014-09-16 11:17:08 -070040
tom4774c8f2014-09-16 11:17:08 -070041import static org.slf4j.LoggerFactory.getLogger;
Changhoon Yoon541ef712015-05-23 17:18:34 +090042import static org.onosproject.security.AppGuard.checkPermission;
Changhoon Yoonb856b812015-08-10 03:47:19 +090043import static org.onosproject.security.AppPermission.Type.*;
Changhoon Yoon541ef712015-05-23 17:18:34 +090044
tom4774c8f2014-09-16 11:17:08 -070045
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 Chiu45920dd2016-07-28 19:19:46 +000052public class PathManager extends AbstractPathService implements PathService {
tom4774c8f2014-09-16 11:17:08 -070053
tom4774c8f2014-09-16 11:17:08 -070054 private final Logger log = getLogger(getClass());
55
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070056 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
57 protected TopologyService topologyService;
58
59 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
60 protected HostService hostService;
61
tom4774c8f2014-09-16 11:17:08 -070062 @Activate
tomca90c462014-09-22 11:40:58 -070063 public void activate() {
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070064 // initialize AbstractPathService
65 super.topologyService = this.topologyService;
66 super.hostService = this.hostService;
tom4774c8f2014-09-16 11:17:08 -070067 log.info("Started");
68 }
69
70 @Deactivate
tomca90c462014-09-22 11:40:58 -070071 public void deactivate() {
tom4774c8f2014-09-16 11:17:08 -070072 log.info("Stopped");
73 }
74
75 @Override
tomcbefa232014-09-16 14:17:20 -070076 public Set<Path> getPaths(ElementId src, ElementId dst) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090077 checkPermission(TOPOLOGY_READ);
Changhoon Yoon541ef712015-05-23 17:18:34 +090078
Andrey Komarov2398d962016-09-26 15:11:23 +030079 return getPaths(src, dst, (LinkWeigher) null);
tom4774c8f2014-09-16 11:17:08 -070080 }
81
82 @Override
tomcbefa232014-09-16 14:17:20 -070083 public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090084 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +000085 return super.getPaths(src, dst, weight);
tom4774c8f2014-09-16 11:17:08 -070086 }
87
Andrey Komarov2398d962016-09-26 15:11:23 +030088 @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 HIGUCHIa684b6e2017-05-18 22:29:22 -070094 @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 Chiu45920dd2016-07-28 19:19:46 +0000100
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700101 @Override
102 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
Heedo Kang4a47a302016-02-29 17:40:23 +0900103 checkPermission(TOPOLOGY_READ);
Andrey Komarov2398d962016-09-26 15:11:23 +0300104 return getDisjointPaths(src, dst, (LinkWeigher) null);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700105 }
106
107 @Override
108 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
Heedo Kang4a47a302016-02-29 17:40:23 +0900109 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +0000110 return super.getDisjointPaths(src, dst, weight);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700111 }
112
113 @Override
Andrey Komarov2398d962016-09-26 15:11:23 +0300114 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 Vachuska48e64e42015-09-22 15:32:55 -0700120 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
121 Map<Link, Object> riskProfile) {
Heedo Kang4a47a302016-02-29 17:40:23 +0900122 checkPermission(TOPOLOGY_READ);
Andrey Komarov2398d962016-09-26 15:11:23 +0300123 return getDisjointPaths(src, dst, (LinkWeigher) null, riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700124 }
125
126 @Override
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700127 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
128 Map<Link, Object> riskProfile) {
Heedo Kang4a47a302016-02-29 17:40:23 +0900129 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +0000130 return super.getDisjointPaths(src, dst, weight, riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700131 }
132
Andrey Komarov2398d962016-09-26 15:11:23 +0300133 @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
tom4774c8f2014-09-16 11:17:08 -0700140}