blob: 5c41ff4038e4aacaf26980596647ac47291c4c9c [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;
Brian O'Connorabafb502014-12-02 22:26:20 -080029import org.onosproject.net.topology.LinkWeight;
30import org.onosproject.net.topology.PathService;
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070031import org.onosproject.net.topology.TopologyService;
Claudine Chiu45920dd2016-07-28 19:19:46 +000032import org.onosproject.net.topology.AbstractPathService;
tom4774c8f2014-09-16 11:17:08 -070033import org.slf4j.Logger;
34
tom4774c8f2014-09-16 11:17:08 -070035import java.util.Set;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070036import java.util.Map;
37
tom4774c8f2014-09-16 11:17:08 -070038
tom4774c8f2014-09-16 11:17:08 -070039import static org.slf4j.LoggerFactory.getLogger;
Changhoon Yoon541ef712015-05-23 17:18:34 +090040import static org.onosproject.security.AppGuard.checkPermission;
Changhoon Yoonb856b812015-08-10 03:47:19 +090041import static org.onosproject.security.AppPermission.Type.*;
Changhoon Yoon541ef712015-05-23 17:18:34 +090042
tom4774c8f2014-09-16 11:17:08 -070043
44/**
45 * Provides implementation of a path selection service atop the current
46 * topology and host services.
47 */
48@Component(immediate = true)
49@Service
Claudine Chiu45920dd2016-07-28 19:19:46 +000050public class PathManager extends AbstractPathService implements PathService {
tom4774c8f2014-09-16 11:17:08 -070051
tom4774c8f2014-09-16 11:17:08 -070052 private final Logger log = getLogger(getClass());
53
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070054 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
55 protected TopologyService topologyService;
56
57 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
58 protected HostService hostService;
59
tom4774c8f2014-09-16 11:17:08 -070060 @Activate
tomca90c462014-09-22 11:40:58 -070061 public void activate() {
Yuta HIGUCHI90e12292016-08-02 18:02:53 -070062 // initialize AbstractPathService
63 super.topologyService = this.topologyService;
64 super.hostService = this.hostService;
tom4774c8f2014-09-16 11:17:08 -070065 log.info("Started");
66 }
67
68 @Deactivate
tomca90c462014-09-22 11:40:58 -070069 public void deactivate() {
tom4774c8f2014-09-16 11:17:08 -070070 log.info("Stopped");
71 }
72
73 @Override
tomcbefa232014-09-16 14:17:20 -070074 public Set<Path> getPaths(ElementId src, ElementId dst) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090075 checkPermission(TOPOLOGY_READ);
Changhoon Yoon541ef712015-05-23 17:18:34 +090076
tom4774c8f2014-09-16 11:17:08 -070077 return getPaths(src, dst, null);
78 }
79
80 @Override
tomcbefa232014-09-16 14:17:20 -070081 public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090082 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +000083 return super.getPaths(src, dst, weight);
tom4774c8f2014-09-16 11:17:08 -070084 }
85
Claudine Chiu45920dd2016-07-28 19:19:46 +000086
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070087 @Override
88 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
Heedo Kang4a47a302016-02-29 17:40:23 +090089 checkPermission(TOPOLOGY_READ);
Thomas Vachuska48e64e42015-09-22 15:32:55 -070090 return getDisjointPaths(src, dst, (LinkWeight) null);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070091 }
92
93 @Override
94 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
Heedo Kang4a47a302016-02-29 17:40:23 +090095 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +000096 return super.getDisjointPaths(src, dst, weight);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070097 }
98
99 @Override
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700100 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
101 Map<Link, Object> riskProfile) {
Heedo Kang4a47a302016-02-29 17:40:23 +0900102 checkPermission(TOPOLOGY_READ);
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700103 return getDisjointPaths(src, dst, null, riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700104 }
105
106 @Override
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700107 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
108 Map<Link, Object> riskProfile) {
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, riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700111 }
112
tom4774c8f2014-09-16 11:17:08 -0700113}