Priyanka B
Committed by Gerrit Code Review

[ONOS-4051] Path computation algorithm implementation (Coding & UT).

Change-Id: If94be2ba2a010a203003b7ce38289b516ab20f59
...@@ -18,8 +18,10 @@ package org.onosproject.pce.pceservice; ...@@ -18,8 +18,10 @@ package org.onosproject.pce.pceservice;
18 import static com.google.common.base.Preconditions.checkNotNull; 18 import static com.google.common.base.Preconditions.checkNotNull;
19 import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; 19 import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
20 20
21 +import java.util.Collections;
21 import java.util.Iterator; 22 import java.util.Iterator;
22 import java.util.List; 23 import java.util.List;
24 +import java.util.Set;
23 25
24 import org.apache.felix.scr.annotations.Activate; 26 import org.apache.felix.scr.annotations.Activate;
25 import org.apache.felix.scr.annotations.Component; 27 import org.apache.felix.scr.annotations.Component;
...@@ -34,8 +36,15 @@ import org.onosproject.incubator.net.tunnel.Tunnel; ...@@ -34,8 +36,15 @@ import org.onosproject.incubator.net.tunnel.Tunnel;
34 import org.onosproject.incubator.net.tunnel.TunnelId; 36 import org.onosproject.incubator.net.tunnel.TunnelId;
35 import org.onosproject.incubator.net.tunnel.TunnelService; 37 import org.onosproject.incubator.net.tunnel.TunnelService;
36 import org.onosproject.net.DeviceId; 38 import org.onosproject.net.DeviceId;
39 +import org.onosproject.net.Path;
37 import org.onosproject.net.intent.Constraint; 40 import org.onosproject.net.intent.Constraint;
41 +import org.onosproject.net.device.DeviceService;
42 +import org.onosproject.net.resource.ResourceService;
43 +import org.onosproject.net.topology.LinkWeight;
44 +import org.onosproject.net.topology.PathService;
45 +import org.onosproject.net.topology.TopologyEdge;
38 import org.onosproject.pce.pceservice.api.PceService; 46 import org.onosproject.pce.pceservice.api.PceService;
47 +import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
39 import org.onosproject.store.serializers.KryoNamespaces; 48 import org.onosproject.store.serializers.KryoNamespaces;
40 import org.onosproject.store.service.DistributedSet; 49 import org.onosproject.store.service.DistributedSet;
41 import org.onosproject.store.service.Serializer; 50 import org.onosproject.store.service.Serializer;
...@@ -43,6 +52,8 @@ import org.onosproject.store.service.StorageService; ...@@ -43,6 +52,8 @@ import org.onosproject.store.service.StorageService;
43 import org.slf4j.Logger; 52 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory; 53 import org.slf4j.LoggerFactory;
45 54
55 +import com.google.common.collect.ImmutableList;
56 +
46 /** 57 /**
47 * Implementation of PCE service. 58 * Implementation of PCE service.
48 */ 59 */
...@@ -66,6 +77,15 @@ public class PceManager implements PceService { ...@@ -66,6 +77,15 @@ public class PceManager implements PceService {
66 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 77 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
67 protected StorageService storageService; 78 protected StorageService storageService;
68 79
80 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
81 + protected PathService pathService;
82 +
83 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
84 + protected ResourceService resourceService;
85 +
86 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
87 + protected DeviceService deviceService;
88 +
69 private ApplicationId appId; 89 private ApplicationId appId;
70 90
71 /** 91 /**
...@@ -92,6 +112,36 @@ public class PceManager implements PceService { ...@@ -92,6 +112,36 @@ public class PceManager implements PceService {
92 log.info("Stopped"); 112 log.info("Stopped");
93 } 113 }
94 114
115 + /**
116 + * Returns an edge-weight capable of evaluating links on the basis of the
117 + * specified constraints.
118 + *
119 + * @param constraints path constraints
120 + * @return edge-weight function
121 + */
122 + private LinkWeight weight(List<Constraint> constraints) {
123 + return new TeConstraintBasedLinkWeight(constraints);
124 + }
125 +
126 + /**
127 + * Computes a path between two devices.
128 + *
129 + * @param src ingress device
130 + * @param dst egress device
131 + * @param constraints path constraints
132 + * @return computed path based on constraints
133 + */
134 + protected Set<Path> computePath(DeviceId src, DeviceId dst, List<Constraint> constraints) {
135 + if (pathService == null) {
136 + return null;
137 + }
138 + Set<Path> paths = pathService.getPaths(src, dst, weight(constraints));
139 + if (!paths.isEmpty()) {
140 + return paths;
141 + }
142 + return null;
143 + }
144 +
95 //[TODO:] handle requests in queue 145 //[TODO:] handle requests in queue
96 @Override 146 @Override
97 public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, 147 public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints,
...@@ -103,8 +153,8 @@ public class PceManager implements PceService { ...@@ -103,8 +153,8 @@ public class PceManager implements PceService {
103 checkNotNull(lspType); 153 checkNotNull(lspType);
104 154
105 // TODO: compute and setup path. 155 // TODO: compute and setup path.
106 - 156 + //TODO: gets the path based on constraints and creates a tunnel in network via tunnel manager
107 - return true; 157 + return computePath(src, dst, constraints) != null ? true : false;
108 } 158 }
109 159
110 160
...@@ -159,4 +209,44 @@ public class PceManager implements PceService { ...@@ -159,4 +209,44 @@ public class PceManager implements PceService {
159 return value; 209 return value;
160 } 210 }
161 211
212 + protected class TeConstraintBasedLinkWeight implements LinkWeight {
213 +
214 + private final List<Constraint> constraints;
215 +
216 + /**
217 + * Creates a new edge-weight function capable of evaluating links
218 + * on the basis of the specified constraints.
219 + *
220 + * @param constraints path constraints
221 + */
222 + public TeConstraintBasedLinkWeight(List<Constraint> constraints) {
223 + if (constraints == null) {
224 + this.constraints = Collections.emptyList();
225 + } else {
226 + this.constraints = ImmutableList.copyOf(constraints);
227 + }
228 + }
229 +
230 + @Override
231 + public double weight(TopologyEdge edge) {
232 + if (!constraints.iterator().hasNext()) {
233 + //Takes default cost/hopcount as 1 if no constraints specified
234 + return 1.0;
235 + }
236 +
237 + Iterator<Constraint> it = constraints.iterator();
238 + double cost = 1;
239 +
240 + //If any constraint fails return -1 also value of cost returned from cost constraint can't be negative
241 + while (it.hasNext() && cost > 0) {
242 + Constraint constraint = it.next();
243 + if (constraint instanceof CapabilityConstraint) {
244 + cost = ((CapabilityConstraint) constraint).isValidLink(edge.link(), deviceService) ? 1 : -1;
245 + } else {
246 + cost = constraint.cost(edge.link(), resourceService::isAvailable);
247 + }
248 + }
249 + return cost;
250 + }
251 + }
162 } 252 }
...\ No newline at end of file ...\ No newline at end of file
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 + */
16 +package org.onosproject.pce.pceservice.constraint;
17 +
18 +import org.onosproject.net.AnnotationKeys;
19 +import org.onosproject.net.Device;
20 +import org.onosproject.net.Link;
21 +import org.onosproject.net.device.DeviceService;
22 +import org.onosproject.net.intent.ResourceContext;
23 +import org.onosproject.net.intent.constraint.BooleanConstraint;
24 +
25 +import java.util.Objects;
26 +
27 +import static com.google.common.base.MoreObjects.toStringHelper;
28 +
29 +/**
30 + * Constraint that evaluates whether devices satisfies capability.
31 + */
32 +public final class CapabilityConstraint extends BooleanConstraint {
33 +
34 + private final CapabilityType capabilityType;
35 + public static final String PCECC_CAPABILITY = "pceccCapability";
36 + public static final String SR_CAPABILITY = "srCapability";
37 + public static final String LABEL_STACK_CAPABILITY = "labelStackCapability";
38 + public static final String LSRID = "lsrId";
39 + public static final String L3 = "L3";
40 + public static final String TRUE = "true";
41 +
42 + /**
43 + * Represents about capability type.
44 + */
45 + public enum CapabilityType {
46 + /**
47 + * Signifies that path is created via signaling mode.
48 + */
49 + WITH_SIGNALLING(0),
50 +
51 + /**
52 + * Signifies that path is created via SR mode.
53 + */
54 + SR_WITHOUT_SIGNALLING(1),
55 +
56 + /**
57 + * Signifies that path is created via without signaling and without SR mode.
58 + */
59 + WITHOUT_SIGNALLING_AND_WITHOUT_SR(2);
60 +
61 + int value;
62 +
63 + /**
64 + * Assign val with the value as the capability type.
65 + *
66 + * @param val capability type
67 + */
68 + CapabilityType(int val) {
69 + value = val;
70 + }
71 +
72 + /**
73 + * Returns value of capability type.
74 + *
75 + * @return capability type
76 + */
77 + public byte type() {
78 + return (byte) value;
79 + }
80 + }
81 +
82 + // Constructor for serialization
83 + private CapabilityConstraint() {
84 + capabilityType = null;
85 + }
86 +
87 + /**
88 + * Creates a new capability constraint.
89 + *
90 + * @param capabilityType type of capability device supports
91 + */
92 + public CapabilityConstraint(CapabilityType capabilityType) {
93 + this.capabilityType = capabilityType;
94 + }
95 +
96 + /**
97 + * Creates a new capability constraint.
98 + *
99 + * @param capabilityType type of capability device supports
100 + * @return instance of CapabilityConstraint for specified capability type
101 + */
102 + public static CapabilityConstraint of(CapabilityType capabilityType) {
103 + return new CapabilityConstraint(capabilityType);
104 + }
105 +
106 + /**
107 + * Obtains type of capability.
108 + *
109 + * @return type of capability
110 + */
111 + public CapabilityType capabilityType() {
112 + return capabilityType;
113 + }
114 +
115 + /**
116 + * Validates the link based on capability constraint.
117 + *
118 + * @param link to validate source and destination based on capability constraint
119 + * @param deviceService instance of DeviceService
120 + * @return true if link satisfies capability constraint otherwise false
121 + */
122 + public boolean isValidLink(Link link, DeviceService deviceService) {
123 + if (deviceService == null) {
124 + return false;
125 + }
126 +
127 + Device srcDevice = deviceService.getDevice(link.src().deviceId());
128 + Device dstDevice = deviceService.getDevice(link.dst().deviceId());
129 +
130 + //TODO: Usage of annotations are for transient solution. In future will be replaces with the
131 + // network config service / Projection model.
132 + // L3 device
133 + if (srcDevice == null
134 + || dstDevice == null
135 + || srcDevice.annotations().value(AnnotationKeys.TYPE) == null
136 + || dstDevice.annotations().value(AnnotationKeys.TYPE) == null
137 + || !srcDevice.annotations().value(AnnotationKeys.TYPE).equals(L3)
138 + || !dstDevice.annotations().value(AnnotationKeys.TYPE).equals(L3)) {
139 + return false;
140 + }
141 +
142 + String scrLsrId = srcDevice.annotations().value(LSRID);
143 + String dstLsrId = dstDevice.annotations().value(LSRID);
144 +
145 + Device srcCapDevice = null;
146 + Device dstCapDevice = null;
147 +
148 + // Get Capability device
149 + Iterable<Device> devices = deviceService.getAvailableDevices();
150 + for (Device dev : devices) {
151 + if (dev.annotations().value(LSRID).equals(scrLsrId)) {
152 + srcCapDevice = dev;
153 + } else if (dev.annotations().value(LSRID).equals(dstLsrId)) {
154 + dstCapDevice = dev;
155 + }
156 + }
157 +
158 + if (srcCapDevice == null || dstCapDevice == null) {
159 + return false;
160 + }
161 +
162 + switch (capabilityType) {
163 + case WITH_SIGNALLING:
164 + return true;
165 + case WITHOUT_SIGNALLING_AND_WITHOUT_SR:
166 + if (srcCapDevice.annotations().value(PCECC_CAPABILITY) != null
167 + && dstCapDevice.annotations().value(PCECC_CAPABILITY) != null) {
168 + return srcCapDevice.annotations().value(PCECC_CAPABILITY).equals(TRUE)
169 + && dstCapDevice.annotations().value(PCECC_CAPABILITY).equals(TRUE);
170 + }
171 + return false;
172 + case SR_WITHOUT_SIGNALLING:
173 + if (srcCapDevice.annotations().value(LABEL_STACK_CAPABILITY) != null
174 + && dstCapDevice.annotations().value(LABEL_STACK_CAPABILITY) != null
175 + && srcCapDevice.annotations().value(SR_CAPABILITY) != null
176 + && dstCapDevice.annotations().value(SR_CAPABILITY) != null) {
177 + return srcCapDevice.annotations().value(LABEL_STACK_CAPABILITY).equals(TRUE)
178 + && dstCapDevice.annotations().value(LABEL_STACK_CAPABILITY).equals(TRUE)
179 + && srcCapDevice.annotations().value(SR_CAPABILITY).equals(TRUE)
180 + && dstCapDevice.annotations().value(SR_CAPABILITY).equals(TRUE);
181 + }
182 + return false;
183 + default:
184 + return false;
185 + }
186 + }
187 +
188 + @Override
189 + public boolean isValid(Link link, ResourceContext context) {
190 + return false;
191 + //Do nothing instead using isValidLink needs device service to validate link
192 + }
193 +
194 + @Override
195 + public int hashCode() {
196 + return Objects.hash(capabilityType);
197 + }
198 +
199 + @Override
200 + public boolean equals(Object obj) {
201 + if (this == obj) {
202 + return true;
203 + }
204 +
205 + if (obj instanceof CapabilityConstraint) {
206 + CapabilityConstraint other = (CapabilityConstraint) obj;
207 + return Objects.equals(this.capabilityType, other.capabilityType);
208 + }
209 +
210 + return false;
211 + }
212 +
213 + @Override
214 + public String toString() {
215 + return toStringHelper(this)
216 + .add("capabilityType", capabilityType)
217 + .toString();
218 + }
219 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 + */
16 +package org.onosproject.pce.pceservice.constraint;
17 +
18 +import org.onosproject.net.Link;
19 +import org.onosproject.net.Path;
20 +import org.onosproject.net.intent.ResourceContext;
21 +import org.onosproject.net.intent.Constraint;
22 +
23 +import java.util.Objects;
24 +
25 +import static com.google.common.base.MoreObjects.toStringHelper;
26 +import static com.google.common.base.Preconditions.checkNotNull;
27 +
28 +/**
29 + * Constraint that evaluates whether cost for a link is available, if yes return cost for that link.
30 + */
31 +public final class CostConstraint implements Constraint {
32 +
33 + /**
34 + * Represents about cost types.
35 + */
36 + public enum Type {
37 + /**
38 + * Signifies that cost is IGP cost.
39 + */
40 + COST(1),
41 +
42 + /**
43 + * Signifies that cost is TE cost.
44 + */
45 + TE_COST(2);
46 +
47 + int value;
48 +
49 + /**
50 + * Assign val with the value as the Cost type.
51 + *
52 + * @param val Cost type
53 + */
54 + Type(int val) {
55 + value = val;
56 + }
57 +
58 + /**
59 + * Returns value of Cost type.
60 + *
61 + * @return Cost type
62 + */
63 + public byte type() {
64 + return (byte) value;
65 + }
66 + }
67 +
68 + private final Type type;
69 + public static final String TE_COST = "teCost";
70 + public static final String COST = "cost";
71 +
72 + // Constructor for serialization
73 + private CostConstraint() {
74 + this.type = null;
75 + }
76 +
77 + /**
78 + * Creates a new cost constraint.
79 + *
80 + * @param type of a link
81 + */
82 + public CostConstraint(Type type) {
83 + this.type = checkNotNull(type, "Type cannot be null");
84 + }
85 +
86 + /**
87 + * Creates new CostConstraint with specified cost type.
88 + *
89 + * @param type of cost
90 + * @return instance of CostConstraint
91 + */
92 + public static CostConstraint of(Type type) {
93 + return new CostConstraint(type);
94 + }
95 +
96 + /**
97 + * Returns the type of a cost specified in a constraint.
98 + *
99 + * @return required cost type
100 + */
101 + public Type type() {
102 + return type;
103 + }
104 +
105 + @Override
106 + public int hashCode() {
107 + return Objects.hash(type);
108 + }
109 +
110 + @Override
111 + public boolean equals(Object obj) {
112 + if (this == obj) {
113 + return true;
114 + }
115 +
116 + if (obj instanceof CostConstraint) {
117 + CostConstraint other = (CostConstraint) obj;
118 + return Objects.equals(this.type, other.type);
119 + }
120 +
121 + return false;
122 + }
123 +
124 + @Override
125 + public String toString() {
126 + return toStringHelper(this)
127 + .add("type", type)
128 + .toString();
129 + }
130 +
131 + @Override
132 + public double cost(Link link, ResourceContext context) {
133 + //TODO: Usage of annotations are for transient solution. In future will be replaces with the
134 + // network config service / Projection model.
135 + switch (type) {
136 + case COST:
137 + if (link.annotations().value(COST) != null) {
138 + return Double.parseDouble(link.annotations().value(COST));
139 + }
140 +
141 + //If cost annotations absent return -1[It is not L3 device]
142 + return -1;
143 + case TE_COST:
144 + if (link.annotations().value(TE_COST) != null) {
145 + return Double.parseDouble(link.annotations().value(TE_COST));
146 + }
147 +
148 + //If TE cost annotations absent return -1[It is not L3 device]
149 + return -1;
150 + default:
151 + return -1;
152 + }
153 + }
154 +
155 + @Override
156 + public boolean validate(Path path, ResourceContext context) {
157 + // TODO Auto-generated method stub
158 + return false;
159 + }
160 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 + */
16 +package org.onosproject.pce.pceservice.constraint;
17 +
18 +import org.onlab.util.Bandwidth;
19 +import org.onosproject.net.Link;
20 +import org.onosproject.net.intent.ResourceContext;
21 +import org.onosproject.net.intent.constraint.BooleanConstraint;
22 +import org.onosproject.net.resource.Resources;
23 +
24 +import java.util.List;
25 +import java.util.Objects;
26 +import java.util.stream.Stream;
27 +
28 +import static com.google.common.base.MoreObjects.toStringHelper;
29 +
30 +/**
31 + * Constraint that evaluates whether links satisfies sharedbandwidth request.
32 + */
33 +public final class SharedBandwidthConstraint extends BooleanConstraint {
34 +
35 + private final List<Link> links;
36 + private final Bandwidth sharedBwValue;
37 + private final Bandwidth requestBwValue;
38 + //temporary variable declared to hold changed bandwidth value
39 + private Bandwidth changedBwValue;
40 +
41 + // Constructor for serialization
42 + private SharedBandwidthConstraint() {
43 + links = null;
44 + sharedBwValue = null;
45 + requestBwValue = null;
46 + }
47 +
48 + /**
49 + * Creates a new SharedBandwidth constraint.
50 + *
51 + * @param links shared links
52 + * @param sharedBwValue shared bandwidth of the links
53 + * @param requestBwValue requested bandwidth value
54 + */
55 + public SharedBandwidthConstraint(List<Link> links, Bandwidth sharedBwValue, Bandwidth requestBwValue) {
56 + this.links = links;
57 + this.sharedBwValue = sharedBwValue;
58 + this.requestBwValue = requestBwValue;
59 + }
60 +
61 + /**
62 + * Creates a new SharedBandwidth constraint.
63 + *
64 + * @param links shared links
65 + * @param sharedBwValue shared bandwidth of the links
66 + * @param requestBwValue requested bandwidth value
67 + * @return SharedBandwidth instance
68 + */
69 + public static SharedBandwidthConstraint of(List<Link> links, Bandwidth sharedBwValue, Bandwidth requestBwValue) {
70 + return new SharedBandwidthConstraint(links, sharedBwValue, requestBwValue);
71 + }
72 +
73 + /**
74 + * Obtains shared links.
75 + *
76 + * @return shared links
77 + */
78 + public List<Link> links() {
79 + return links;
80 + }
81 +
82 + /**
83 + * Obtains shared bandwidth of the links.
84 + *
85 + * @return shared bandwidth
86 + */
87 + public Bandwidth sharedBwValue() {
88 + return sharedBwValue;
89 + }
90 +
91 + /**
92 + * Obtains requested bandwidth value.
93 + *
94 + * @return requested bandwidth value
95 + */
96 + public Bandwidth requestBwValue() {
97 + return requestBwValue;
98 + }
99 +
100 + @Override
101 + public boolean isValid(Link link, ResourceContext context) {
102 + changedBwValue = requestBwValue;
103 + if (links.contains(link)) {
104 + changedBwValue = requestBwValue.isGreaterThan(sharedBwValue) ? requestBwValue.subtract(sharedBwValue)
105 + : Bandwidth.bps(0);
106 + }
107 +
108 + return Stream
109 + .of(link.src(), link.dst())
110 + .map(cp -> Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class).resource(
111 + changedBwValue.bps())).allMatch(context::isAvailable);
112 + }
113 +
114 + @Override
115 + public int hashCode() {
116 + return Objects.hash(requestBwValue, sharedBwValue, links);
117 + }
118 +
119 + @Override
120 + public boolean equals(Object obj) {
121 + if (this == obj) {
122 + return true;
123 + }
124 +
125 + if (obj instanceof SharedBandwidthConstraint) {
126 + SharedBandwidthConstraint other = (SharedBandwidthConstraint) obj;
127 + return Objects.equals(this.requestBwValue, other.requestBwValue)
128 + && Objects.equals(this.sharedBwValue, other.sharedBwValue)
129 + && Objects.equals(this.links, other.links);
130 + }
131 +
132 + return false;
133 + }
134 +
135 + @Override
136 + public String toString() {
137 + return toStringHelper(this)
138 + .add("requestBwValue", requestBwValue)
139 + .add("sharedBwValue", sharedBwValue)
140 + .add("links", links)
141 + .toString();
142 + }
143 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * Constraints for path computation for PCE service.
19 + */
20 +package org.onosproject.pce.pceservice.constraint;
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 + */
16 +package org.onosproject.pce.pceservice;
17 +
18 +import org.onosproject.net.resource.DiscreteResourceId;
19 +import org.onosproject.net.resource.ResourceAllocation;
20 +import org.onosproject.net.resource.ResourceConsumer;
21 +import org.onosproject.net.resource.ResourceId;
22 +import org.onosproject.net.resource.ResourceListener;
23 +import org.onosproject.net.resource.Resource;
24 +import org.onosproject.net.resource.ResourceService;
25 +
26 +import java.util.Collection;
27 +import java.util.List;
28 +import java.util.Set;
29 +
30 +/**
31 + * Adapter for resource service for path computation.
32 + */
33 +public class ResourceServiceAdapter implements ResourceService {
34 +
35 + @Override
36 + public void addListener(ResourceListener listener) {
37 + // TODO Auto-generated method stub
38 + }
39 +
40 + @Override
41 + public void removeListener(ResourceListener listener) {
42 + // TODO Auto-generated method stub
43 + }
44 +
45 + @Override
46 + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
47 + // TODO Auto-generated method stub
48 + return null;
49 + }
50 +
51 + @Override
52 + public boolean release(List<ResourceAllocation> allocations) {
53 + // TODO Auto-generated method stub
54 + return false;
55 + }
56 +
57 + @Override
58 + public boolean release(ResourceConsumer consumer) {
59 + // TODO Auto-generated method stub
60 + return false;
61 + }
62 +
63 + @Override
64 + public List<ResourceAllocation> getResourceAllocations(ResourceId id) {
65 + // TODO Auto-generated method stub
66 + return null;
67 + }
68 +
69 + @Override
70 + public <T> Collection<ResourceAllocation> getResourceAllocations(DiscreteResourceId parent, Class<T> cls) {
71 + // TODO Auto-generated method stub
72 + return null;
73 + }
74 +
75 + @Override
76 + public Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer) {
77 + // TODO Auto-generated method stub
78 + return null;
79 + }
80 +
81 + @Override
82 + public Set<Resource> getAvailableResources(DiscreteResourceId parent) {
83 + // TODO Auto-generated method stub
84 + return null;
85 + }
86 +
87 + @Override
88 + public <T> Set<Resource> getAvailableResources(DiscreteResourceId parent, Class<T> cls) {
89 + // TODO Auto-generated method stub
90 + return null;
91 + }
92 +
93 + @Override
94 + public <T> Set<T> getAvailableResourceValues(DiscreteResourceId parent, Class<T> cls) {
95 + // TODO Auto-generated method stub
96 + return null;
97 + }
98 +
99 + @Override
100 + public Set<Resource> getRegisteredResources(DiscreteResourceId parent) {
101 + // TODO Auto-generated method stub
102 + return null;
103 + }
104 +
105 + @Override
106 + public boolean isAvailable(Resource resource) {
107 + // TODO Auto-generated method stub
108 + return false;
109 + }
110 +}