blob: ec650da9276ae49722a8c380b98c52dbcfba6801 [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;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070037import java.util.Map;
38
tom4774c8f2014-09-16 11:17:08 -070039
tom4774c8f2014-09-16 11:17:08 -070040import static org.slf4j.LoggerFactory.getLogger;
Changhoon Yoon541ef712015-05-23 17:18:34 +090041import static org.onosproject.security.AppGuard.checkPermission;
Changhoon Yoonb856b812015-08-10 03:47:19 +090042import static org.onosproject.security.AppPermission.Type.*;
Changhoon Yoon541ef712015-05-23 17:18:34 +090043
tom4774c8f2014-09-16 11:17:08 -070044
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 Chiu45920dd2016-07-28 19:19:46 +000051public class PathManager extends AbstractPathService implements PathService {
tom4774c8f2014-09-16 11:17:08 -070052
tom4774c8f2014-09-16 11:17:08 -070053 private final Logger log = getLogger(getClass());
54
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070055 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
56 protected TopologyService topologyService;
57
58 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
59 protected HostService hostService;
60
tom4774c8f2014-09-16 11:17:08 -070061 @Activate
tomca90c462014-09-22 11:40:58 -070062 public void activate() {
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070063 // initialize AbstractPathService
64 super.topologyService = this.topologyService;
65 super.hostService = this.hostService;
tom4774c8f2014-09-16 11:17:08 -070066 log.info("Started");
67 }
68
69 @Deactivate
tomca90c462014-09-22 11:40:58 -070070 public void deactivate() {
tom4774c8f2014-09-16 11:17:08 -070071 log.info("Stopped");
72 }
73
74 @Override
tomcbefa232014-09-16 14:17:20 -070075 public Set<Path> getPaths(ElementId src, ElementId dst) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090076 checkPermission(TOPOLOGY_READ);
Changhoon Yoon541ef712015-05-23 17:18:34 +090077
Andrey Komarov2398d962016-09-26 15:11:23 +030078 return getPaths(src, dst, (LinkWeigher) null);
tom4774c8f2014-09-16 11:17:08 -070079 }
80
81 @Override
tomcbefa232014-09-16 14:17:20 -070082 public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090083 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +000084 return super.getPaths(src, dst, weight);
tom4774c8f2014-09-16 11:17:08 -070085 }
86
Andrey Komarov2398d962016-09-26 15:11:23 +030087 @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 Chiu45920dd2016-07-28 19:19:46 +000093
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070094 @Override
95 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
Heedo Kang4a47a302016-02-29 17:40:23 +090096 checkPermission(TOPOLOGY_READ);
Andrey Komarov2398d962016-09-26 15:11:23 +030097 return getDisjointPaths(src, dst, (LinkWeigher) null);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070098 }
99
100 @Override
101 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
Heedo Kang4a47a302016-02-29 17:40:23 +0900102 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +0000103 return super.getDisjointPaths(src, dst, weight);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700104 }
105
106 @Override
Andrey Komarov2398d962016-09-26 15:11:23 +0300107 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 Vachuska48e64e42015-09-22 15:32:55 -0700113 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
114 Map<Link, Object> riskProfile) {
Heedo Kang4a47a302016-02-29 17:40:23 +0900115 checkPermission(TOPOLOGY_READ);
Andrey Komarov2398d962016-09-26 15:11:23 +0300116 return getDisjointPaths(src, dst, (LinkWeigher) null, riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700117 }
118
119 @Override
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700120 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
121 Map<Link, Object> riskProfile) {
Heedo Kang4a47a302016-02-29 17:40:23 +0900122 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +0000123 return super.getDisjointPaths(src, dst, weight, riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700124 }
125
Andrey Komarov2398d962016-09-26 15:11:23 +0300126 @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
tom4774c8f2014-09-16 11:17:08 -0700133}