[ONOS-4170] [ONOS-4163] PCE APP side changes : PceManager (code + UT)
Change-Id: I43db98b2fa3c5930b989d4fa3e2c00f7fa65c5ca
Showing
13 changed files
with
441 additions
and
78 deletions
... | @@ -23,13 +23,24 @@ import java.util.List; | ... | @@ -23,13 +23,24 @@ import java.util.List; |
23 | import java.util.ListIterator; | 23 | import java.util.ListIterator; |
24 | import java.util.LinkedList; | 24 | import java.util.LinkedList; |
25 | 25 | ||
26 | +import org.onlab.packet.MplsLabel; | ||
27 | +import org.onosproject.core.ApplicationId; | ||
26 | import org.onosproject.incubator.net.resource.label.DefaultLabelResource; | 28 | import org.onosproject.incubator.net.resource.label.DefaultLabelResource; |
27 | import org.onosproject.incubator.net.resource.label.LabelResource; | 29 | import org.onosproject.incubator.net.resource.label.LabelResource; |
28 | import org.onosproject.incubator.net.resource.label.LabelResourceId; | 30 | import org.onosproject.incubator.net.resource.label.LabelResourceId; |
29 | import org.onosproject.incubator.net.resource.label.LabelResourceService; | 31 | import org.onosproject.incubator.net.resource.label.LabelResourceService; |
30 | import org.onosproject.incubator.net.tunnel.Tunnel; | 32 | import org.onosproject.incubator.net.tunnel.Tunnel; |
33 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
31 | import org.onosproject.net.DeviceId; | 34 | import org.onosproject.net.DeviceId; |
32 | import org.onosproject.net.PortNumber; | 35 | import org.onosproject.net.PortNumber; |
36 | +import org.onosproject.net.flow.DefaultTrafficSelector; | ||
37 | +import org.onosproject.net.flow.DefaultTrafficTreatment; | ||
38 | +import org.onosproject.net.flow.TrafficSelector; | ||
39 | +import org.onosproject.net.flow.TrafficTreatment; | ||
40 | +import org.onosproject.net.flowobjective.DefaultForwardingObjective; | ||
41 | +import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
42 | +import org.onosproject.net.flowobjective.ForwardingObjective; | ||
43 | +import org.onosproject.net.flowobjective.Objective; | ||
33 | import org.onosproject.pce.pcestore.api.PceStore; | 44 | import org.onosproject.pce.pcestore.api.PceStore; |
34 | import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; | 45 | import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; |
35 | import org.onosproject.pce.pcestore.PceccTunnelInfo; | 46 | import org.onosproject.pce.pcestore.PceccTunnelInfo; |
... | @@ -58,6 +69,8 @@ public final class BasicPceccHandler { | ... | @@ -58,6 +69,8 @@ public final class BasicPceccHandler { |
58 | private static BasicPceccHandler crHandlerInstance = null; | 69 | private static BasicPceccHandler crHandlerInstance = null; |
59 | private LabelResourceService labelRsrcService; | 70 | private LabelResourceService labelRsrcService; |
60 | private PceStore pceStore; | 71 | private PceStore pceStore; |
72 | + private FlowObjectiveService flowObjectiveService; | ||
73 | + private ApplicationId appId; | ||
61 | 74 | ||
62 | /** | 75 | /** |
63 | * Initializes default values. | 76 | * Initializes default values. |
... | @@ -83,8 +96,11 @@ public final class BasicPceccHandler { | ... | @@ -83,8 +96,11 @@ public final class BasicPceccHandler { |
83 | * @param labelRsrcService label resource service | 96 | * @param labelRsrcService label resource service |
84 | * @param pceStore pce label store | 97 | * @param pceStore pce label store |
85 | */ | 98 | */ |
86 | - public void initialize(LabelResourceService labelRsrcService, PceStore pceStore) { | 99 | + public void initialize(LabelResourceService labelRsrcService, FlowObjectiveService flowObjectiveService, |
100 | + ApplicationId appId, PceStore pceStore) { | ||
87 | this.labelRsrcService = labelRsrcService; | 101 | this.labelRsrcService = labelRsrcService; |
102 | + this.flowObjectiveService = flowObjectiveService; | ||
103 | + this.appId = appId; | ||
88 | this.pceStore = pceStore; | 104 | this.pceStore = pceStore; |
89 | } | 105 | } |
90 | 106 | ||
... | @@ -106,8 +122,8 @@ public final class BasicPceccHandler { | ... | @@ -106,8 +122,8 @@ public final class BasicPceccHandler { |
106 | if ((linkList != null) && (linkList.size() > 0)) { | 122 | if ((linkList != null) && (linkList.size() > 0)) { |
107 | // Sequence through reverse order to push local labels into devices | 123 | // Sequence through reverse order to push local labels into devices |
108 | // Generation of labels from egress to ingress | 124 | // Generation of labels from egress to ingress |
109 | - for (ListIterator iterator = linkList.listIterator(linkList.size()); iterator.hasPrevious();) { | 125 | + for (ListIterator<Link> iterator = linkList.listIterator(linkList.size()); iterator.hasPrevious();) { |
110 | - Link link = (Link) iterator.previous(); | 126 | + Link link = iterator.previous(); |
111 | DeviceId dstDeviceId = link.dst().deviceId(); | 127 | DeviceId dstDeviceId = link.dst().deviceId(); |
112 | DeviceId srcDeviceId = link.src().deviceId(); | 128 | DeviceId srcDeviceId = link.src().deviceId(); |
113 | labelRscList = labelRsrcService.applyFromDevicePool(dstDeviceId, applyNum); | 129 | labelRscList = labelRsrcService.applyFromDevicePool(dstDeviceId, applyNum); |
... | @@ -131,16 +147,14 @@ public final class BasicPceccHandler { | ... | @@ -131,16 +147,14 @@ public final class BasicPceccHandler { |
131 | } | 147 | } |
132 | 148 | ||
133 | // Push into destination device | 149 | // Push into destination device |
134 | - //TODO: uncomment below lines once installLocalLabelRule() method is ready | ||
135 | // Destination device IN port is link.dst().port() | 150 | // Destination device IN port is link.dst().port() |
136 | - //installLocalLabelRule(dstDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush, | 151 | + installLocalLabelRule(dstDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush, |
137 | - // LabelType.IN, Objective.Operation.ADD); | 152 | + Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.ADD); |
138 | 153 | ||
139 | // Push into source device | 154 | // Push into source device |
140 | - //TODO: uncomment below lines once installLocalLabelRule() method is ready | ||
141 | // Source device OUT port will be link.dst().port(). Means its remote port used to send packet. | 155 | // Source device OUT port will be link.dst().port(). Means its remote port used to send packet. |
142 | - //installLocalLabelRule(srcDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush, | 156 | + installLocalLabelRule(srcDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush, |
143 | - // LabelType.OUT, Objective.Operation.ADD); | 157 | + Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.ADD); |
144 | 158 | ||
145 | // Add or update pcecc tunnel info in pce store. | 159 | // Add or update pcecc tunnel info in pce store. |
146 | updatePceccTunnelInfoInStore(srcDeviceId, dstDeviceId, labelId, dstPort, | 160 | updatePceccTunnelInfoInStore(srcDeviceId, dstDeviceId, labelId, dstPort, |
... | @@ -183,7 +197,7 @@ public final class BasicPceccHandler { | ... | @@ -183,7 +197,7 @@ public final class BasicPceccHandler { |
183 | if ((lspLabelInfoList != null) && (lspLabelInfoList.size() > 0)) { | 197 | if ((lspLabelInfoList != null) && (lspLabelInfoList.size() > 0)) { |
184 | for (int i = 0; i < lspLabelInfoList.size(); ++i) { | 198 | for (int i = 0; i < lspLabelInfoList.size(); ++i) { |
185 | LspLocalLabelInfo lspLocalLabelInfo = | 199 | LspLocalLabelInfo lspLocalLabelInfo = |
186 | - (DefaultLspLocalLabelInfo) lspLabelInfoList.get(i); | 200 | + lspLabelInfoList.get(i); |
187 | LspLocalLabelInfo.Builder lspLocalLabelInfoBuilder = null; | 201 | LspLocalLabelInfo.Builder lspLocalLabelInfoBuilder = null; |
188 | if (dstDeviceId.equals(lspLocalLabelInfo.deviceId())) { | 202 | if (dstDeviceId.equals(lspLocalLabelInfo.deviceId())) { |
189 | lspLocalLabelInfoBuilder = DefaultLspLocalLabelInfo.builder(lspLocalLabelInfo); | 203 | lspLocalLabelInfoBuilder = DefaultLspLocalLabelInfo.builder(lspLocalLabelInfo); |
... | @@ -264,7 +278,7 @@ public final class BasicPceccHandler { | ... | @@ -264,7 +278,7 @@ public final class BasicPceccHandler { |
264 | List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList(); | 278 | List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList(); |
265 | if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) { | 279 | if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) { |
266 | for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) { | 280 | for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) { |
267 | - LspLocalLabelInfo lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next(); | 281 | + LspLocalLabelInfo lspLocalLabelInfo = iterator.next(); |
268 | DeviceId deviceId = lspLocalLabelInfo.deviceId(); | 282 | DeviceId deviceId = lspLocalLabelInfo.deviceId(); |
269 | LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId(); | 283 | LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId(); |
270 | LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId(); | 284 | LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId(); |
... | @@ -278,15 +292,13 @@ public final class BasicPceccHandler { | ... | @@ -278,15 +292,13 @@ public final class BasicPceccHandler { |
278 | 292 | ||
279 | // Push into device | 293 | // Push into device |
280 | if ((inLabelId != null) && (inPort != null)) { | 294 | if ((inLabelId != null) && (inPort != null)) { |
281 | - //TODO: uncomment below lines once installLocalLabelRule() method is ready | 295 | + installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush, |
282 | - //installLocalLabelRule(deviceId, inLabelId, inPort, tunnelId, isLastLabelToPush, | 296 | + Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE); |
283 | - // LabelType.IN, Objective.Operation.REMOVE); | ||
284 | } | 297 | } |
285 | 298 | ||
286 | if ((outLabelId != null) && (outPort != null)) { | 299 | if ((outLabelId != null) && (outPort != null)) { |
287 | - //TODO: uncomment below lines once installLocalLabelRule() method is ready | 300 | + installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush, |
288 | - //installLocalLabelRule(deviceId, outLabelId, outPort, tunnelId, isLastLabelToPush, | 301 | + Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE); |
289 | - // LabelType.OUT, Objective.Operation.REMOVE); | ||
290 | } | 302 | } |
291 | 303 | ||
292 | // List is stored from egress to ingress. So, using IN label id to release. | 304 | // List is stored from egress to ingress. So, using IN label id to release. |
... | @@ -315,4 +327,35 @@ public final class BasicPceccHandler { | ... | @@ -315,4 +327,35 @@ public final class BasicPceccHandler { |
315 | log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString()); | 327 | log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString()); |
316 | } | 328 | } |
317 | } | 329 | } |
330 | + | ||
331 | + // Install a rule for pushing local labels to the device which is specific to path. | ||
332 | + private void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId, | ||
333 | + PortNumber portNum, TunnelId tunnelId, | ||
334 | + Boolean isBos, Long labelType, | ||
335 | + Objective.Operation type) { | ||
336 | + checkNotNull(flowObjectiveService); | ||
337 | + checkNotNull(appId); | ||
338 | + TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(); | ||
339 | + | ||
340 | + selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue())); | ||
341 | + selectorBuilder.matchInPort(portNum); | ||
342 | + selectorBuilder.matchTunnelId(Long.parseLong(tunnelId.id())); | ||
343 | + selectorBuilder.matchMplsBos(isBos); | ||
344 | + selectorBuilder.matchMetadata(labelType); | ||
345 | + | ||
346 | + TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); | ||
347 | + | ||
348 | + ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder() | ||
349 | + .withSelector(selectorBuilder.build()) | ||
350 | + .withTreatment(treatment) | ||
351 | + .withFlag(ForwardingObjective.Flag.VERSATILE) | ||
352 | + .fromApp(appId) | ||
353 | + .makePermanent(); | ||
354 | + | ||
355 | + if (type.equals(Objective.Operation.ADD)) { | ||
356 | + flowObjectiveService.forward(deviceId, forwardingObjective.add()); | ||
357 | + } else { | ||
358 | + flowObjectiveService.forward(deviceId, forwardingObjective.remove()); | ||
359 | + } | ||
360 | + } | ||
318 | } | 361 | } | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
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 | +/** | ||
19 | + * Collection of keys for annotation for PCEP tunnels. | ||
20 | + */ | ||
21 | +public final class PcepAnnotationKeys { | ||
22 | + | ||
23 | + /** | ||
24 | + * Prohibits instantiation. | ||
25 | + */ | ||
26 | + private PcepAnnotationKeys() { | ||
27 | + } | ||
28 | + | ||
29 | + /** | ||
30 | + * Annotation key for bandwidth. | ||
31 | + * The value for this key is interpreted as Mbps. | ||
32 | + */ | ||
33 | + public static final String BANDWIDTH = "bandwidth"; | ||
34 | + | ||
35 | + /** | ||
36 | + * Annotation key for the LSP signaling type. | ||
37 | + */ | ||
38 | + public static final String LSP_SIG_TYPE = "lspSigType"; | ||
39 | + | ||
40 | + /** | ||
41 | + * Annotation key for the PCC tunnel id. | ||
42 | + */ | ||
43 | + public static final String PCC_TUNNEL_ID = "PccTunnelId"; | ||
44 | + | ||
45 | + /** | ||
46 | + * Annotation key for the LSP id assigned per tunnel per session. | ||
47 | + */ | ||
48 | + public static final String PLSP_ID = "PLspId"; | ||
49 | + | ||
50 | + /** | ||
51 | + * Annotation key for the LSP id assigned per tunnel. | ||
52 | + */ | ||
53 | + public static final String LOCAL_LSP_ID = "localLspId"; | ||
54 | + | ||
55 | + /** | ||
56 | + * Annotation key for the identification of initiated LSP. | ||
57 | + */ | ||
58 | + public static final String PCE_INIT = "pceInit"; | ||
59 | + | ||
60 | + /** | ||
61 | + * Annotation key for the cost type. | ||
62 | + */ | ||
63 | + public static final String COST_TYPE = "costType"; | ||
64 | + | ||
65 | + /** | ||
66 | + * Annotation key for the Delegation. | ||
67 | + * Whether LSPs are delegated or not. | ||
68 | + */ | ||
69 | + public static final String DELEGATE = "delegate"; | ||
70 | +} |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.pce.pceservice; | 16 | package org.onosproject.pce.pceservice; |
17 | 17 | ||
18 | +import org.onlab.util.Identifier; | ||
18 | import org.onosproject.net.resource.ResourceConsumer; | 19 | import org.onosproject.net.resource.ResourceConsumer; |
19 | 20 | ||
20 | import com.google.common.annotations.Beta; | 21 | import com.google.common.annotations.Beta; |
... | @@ -25,9 +26,7 @@ import org.onosproject.net.resource.ResourceConsumerId; | ... | @@ -25,9 +26,7 @@ import org.onosproject.net.resource.ResourceConsumerId; |
25 | * resource allocations. | 26 | * resource allocations. |
26 | */ | 27 | */ |
27 | @Beta | 28 | @Beta |
28 | -public final class TunnelConsumerId implements ResourceConsumer { | 29 | +public final class TunnelConsumerId extends Identifier<Long> implements ResourceConsumer { |
29 | - | ||
30 | - private final long value; | ||
31 | 30 | ||
32 | /** | 31 | /** |
33 | * Creates a tunnel resource consumer identifier from the specified long value. | 32 | * Creates a tunnel resource consumer identifier from the specified long value. |
... | @@ -43,7 +42,7 @@ public final class TunnelConsumerId implements ResourceConsumer { | ... | @@ -43,7 +42,7 @@ public final class TunnelConsumerId implements ResourceConsumer { |
43 | * Initializes object for serializer. | 42 | * Initializes object for serializer. |
44 | */ | 43 | */ |
45 | public TunnelConsumerId() { | 44 | public TunnelConsumerId() { |
46 | - this.value = 0; | 45 | + super(0L); |
47 | } | 46 | } |
48 | 47 | ||
49 | /** | 48 | /** |
... | @@ -54,43 +53,25 @@ public final class TunnelConsumerId implements ResourceConsumer { | ... | @@ -54,43 +53,25 @@ public final class TunnelConsumerId implements ResourceConsumer { |
54 | * resource consumer id | 53 | * resource consumer id |
55 | */ | 54 | */ |
56 | public TunnelConsumerId(long value) { | 55 | public TunnelConsumerId(long value) { |
57 | - this.value = value; | 56 | + super(value); |
58 | } | 57 | } |
59 | 58 | ||
60 | /** | 59 | /** |
61 | - * Returns the tunnel resource consumer id value in long format. | 60 | + * Returns the backing identifier value. |
62 | * | 61 | * |
63 | - * @return value the tunnel resource consumer id's long value | 62 | + * @return value backing identifier value |
64 | */ | 63 | */ |
65 | public long value() { | 64 | public long value() { |
66 | - return value; | 65 | + return identifier; |
67 | - } | ||
68 | - | ||
69 | - @Override | ||
70 | - public int hashCode() { | ||
71 | - return Long.hashCode(value); | ||
72 | - } | ||
73 | - | ||
74 | - @Override | ||
75 | - public boolean equals(Object obj) { | ||
76 | - if (obj == this) { | ||
77 | - return true; | ||
78 | - } | ||
79 | - if (!(obj instanceof TunnelConsumerId)) { | ||
80 | - return false; | ||
81 | - } | ||
82 | - TunnelConsumerId that = (TunnelConsumerId) obj; | ||
83 | - return this.value == that.value; | ||
84 | } | 66 | } |
85 | 67 | ||
86 | @Override | 68 | @Override |
87 | public String toString() { | 69 | public String toString() { |
88 | - return "0x" + Long.toHexString(value); | 70 | + return "0x" + Long.toHexString(identifier); |
89 | } | 71 | } |
90 | 72 | ||
91 | @Override | 73 | @Override |
92 | public ResourceConsumerId consumerId() { | 74 | public ResourceConsumerId consumerId() { |
93 | - // TODO | 75 | + return ResourceConsumerId.of(this); |
94 | - return null; | ||
95 | } | 76 | } |
96 | } | 77 | } | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2016 Open Networking Laboratory | 2 | + * Copyright 2016-present Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. | ... | ... |
... | @@ -31,6 +31,8 @@ import org.junit.Before; | ... | @@ -31,6 +31,8 @@ import org.junit.Before; |
31 | import org.junit.Test; | 31 | import org.junit.Test; |
32 | 32 | ||
33 | import org.onlab.packet.IpAddress; | 33 | import org.onlab.packet.IpAddress; |
34 | +import org.onosproject.core.ApplicationId; | ||
35 | +import org.onosproject.core.CoreService; | ||
34 | import org.onosproject.core.DefaultGroupId; | 36 | import org.onosproject.core.DefaultGroupId; |
35 | import org.onosproject.incubator.net.tunnel.Tunnel; | 37 | import org.onosproject.incubator.net.tunnel.Tunnel; |
36 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | 38 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; |
... | @@ -45,11 +47,11 @@ import org.onosproject.net.DefaultAnnotations; | ... | @@ -45,11 +47,11 @@ import org.onosproject.net.DefaultAnnotations; |
45 | import org.onosproject.net.DefaultPath; | 47 | import org.onosproject.net.DefaultPath; |
46 | import org.onosproject.net.DeviceId; | 48 | import org.onosproject.net.DeviceId; |
47 | import org.onosproject.net.PortNumber; | 49 | import org.onosproject.net.PortNumber; |
50 | +import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
48 | import org.onosproject.net.Path; | 51 | import org.onosproject.net.Path; |
49 | import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; | 52 | import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; |
50 | import org.onosproject.pce.pcestore.api.PceStore; | 53 | import org.onosproject.pce.pcestore.api.PceStore; |
51 | import org.onosproject.pce.pcestore.PceccTunnelInfo; | 54 | import org.onosproject.pce.pcestore.PceccTunnelInfo; |
52 | -import org.onosproject.pce.pcestore.DefaultLspLocalLabelInfo; | ||
53 | import org.onosproject.net.provider.ProviderId; | 55 | import org.onosproject.net.provider.ProviderId; |
54 | import org.onosproject.pce.util.LabelResourceAdapter; | 56 | import org.onosproject.pce.util.LabelResourceAdapter; |
55 | import org.onosproject.pce.util.PceStoreAdapter; | 57 | import org.onosproject.pce.util.PceStoreAdapter; |
... | @@ -67,6 +69,9 @@ public class BasicPceccHandlerTest { | ... | @@ -67,6 +69,9 @@ public class BasicPceccHandlerTest { |
67 | private BasicPceccHandler pceccHandler; | 69 | private BasicPceccHandler pceccHandler; |
68 | protected LabelResourceService labelRsrcService; | 70 | protected LabelResourceService labelRsrcService; |
69 | protected PceStore pceStore; | 71 | protected PceStore pceStore; |
72 | + private FlowObjectiveService flowObjectiveService; | ||
73 | + private CoreService coreService; | ||
74 | + private ApplicationId appId; | ||
70 | private TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423)); | 75 | private TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423)); |
71 | private TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421)); | 76 | private TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421)); |
72 | private DefaultGroupId groupId = new DefaultGroupId(92034); | 77 | private DefaultGroupId groupId = new DefaultGroupId(92034); |
... | @@ -92,7 +97,10 @@ public class BasicPceccHandlerTest { | ... | @@ -92,7 +97,10 @@ public class BasicPceccHandlerTest { |
92 | pceccHandler = BasicPceccHandler.getInstance(); | 97 | pceccHandler = BasicPceccHandler.getInstance(); |
93 | labelRsrcService = new LabelResourceAdapter(); | 98 | labelRsrcService = new LabelResourceAdapter(); |
94 | pceStore = new PceStoreAdapter(); | 99 | pceStore = new PceStoreAdapter(); |
95 | - pceccHandler.initialize(labelRsrcService, pceStore); | 100 | + flowObjectiveService = new PceManagerTest.MockFlowObjService(); |
101 | + coreService = new PceManagerTest.MockCoreService(); | ||
102 | + appId = coreService.registerApplication("org.onosproject.pce"); | ||
103 | + pceccHandler.initialize(labelRsrcService, flowObjectiveService, appId, pceStore); | ||
96 | 104 | ||
97 | // Cretae tunnel test | 105 | // Cretae tunnel test |
98 | // Link | 106 | // Link |
... | @@ -190,7 +198,7 @@ public class BasicPceccHandlerTest { | ... | @@ -190,7 +198,7 @@ public class BasicPceccHandlerTest { |
190 | iterator = lspLocalLabelInfoList.iterator(); | 198 | iterator = lspLocalLabelInfoList.iterator(); |
191 | 199 | ||
192 | // Retrieve values and check device5 | 200 | // Retrieve values and check device5 |
193 | - lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next(); | 201 | + lspLocalLabelInfo = iterator.next(); |
194 | deviceId = lspLocalLabelInfo.deviceId(); | 202 | deviceId = lspLocalLabelInfo.deviceId(); |
195 | inLabelId = lspLocalLabelInfo.inLabelId(); | 203 | inLabelId = lspLocalLabelInfo.inLabelId(); |
196 | outLabelId = lspLocalLabelInfo.outLabelId(); | 204 | outLabelId = lspLocalLabelInfo.outLabelId(); |
... | @@ -205,7 +213,7 @@ public class BasicPceccHandlerTest { | ... | @@ -205,7 +213,7 @@ public class BasicPceccHandlerTest { |
205 | 213 | ||
206 | // Next element check | 214 | // Next element check |
207 | // Retrieve values and check device4 | 215 | // Retrieve values and check device4 |
208 | - lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next(); | 216 | + lspLocalLabelInfo = iterator.next(); |
209 | deviceId = lspLocalLabelInfo.deviceId(); | 217 | deviceId = lspLocalLabelInfo.deviceId(); |
210 | inLabelId = lspLocalLabelInfo.inLabelId(); | 218 | inLabelId = lspLocalLabelInfo.inLabelId(); |
211 | outLabelId = lspLocalLabelInfo.outLabelId(); | 219 | outLabelId = lspLocalLabelInfo.outLabelId(); |
... | @@ -220,7 +228,7 @@ public class BasicPceccHandlerTest { | ... | @@ -220,7 +228,7 @@ public class BasicPceccHandlerTest { |
220 | 228 | ||
221 | // Next element check | 229 | // Next element check |
222 | // Retrieve values and check device3 | 230 | // Retrieve values and check device3 |
223 | - lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next(); | 231 | + lspLocalLabelInfo = iterator.next(); |
224 | deviceId = lspLocalLabelInfo.deviceId(); | 232 | deviceId = lspLocalLabelInfo.deviceId(); |
225 | inLabelId = lspLocalLabelInfo.inLabelId(); | 233 | inLabelId = lspLocalLabelInfo.inLabelId(); |
226 | outLabelId = lspLocalLabelInfo.outLabelId(); | 234 | outLabelId = lspLocalLabelInfo.outLabelId(); |
... | @@ -235,7 +243,7 @@ public class BasicPceccHandlerTest { | ... | @@ -235,7 +243,7 @@ public class BasicPceccHandlerTest { |
235 | 243 | ||
236 | // Next element check | 244 | // Next element check |
237 | // Retrieve values and check device2 | 245 | // Retrieve values and check device2 |
238 | - lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next(); | 246 | + lspLocalLabelInfo = iterator.next(); |
239 | deviceId = lspLocalLabelInfo.deviceId(); | 247 | deviceId = lspLocalLabelInfo.deviceId(); |
240 | inLabelId = lspLocalLabelInfo.inLabelId(); | 248 | inLabelId = lspLocalLabelInfo.inLabelId(); |
241 | outLabelId = lspLocalLabelInfo.outLabelId(); | 249 | outLabelId = lspLocalLabelInfo.outLabelId(); |
... | @@ -250,7 +258,7 @@ public class BasicPceccHandlerTest { | ... | @@ -250,7 +258,7 @@ public class BasicPceccHandlerTest { |
250 | 258 | ||
251 | // Next element check | 259 | // Next element check |
252 | // Retrieve values and check device1 | 260 | // Retrieve values and check device1 |
253 | - lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next(); | 261 | + lspLocalLabelInfo = iterator.next(); |
254 | deviceId = lspLocalLabelInfo.deviceId(); | 262 | deviceId = lspLocalLabelInfo.deviceId(); |
255 | inLabelId = lspLocalLabelInfo.inLabelId(); | 263 | inLabelId = lspLocalLabelInfo.inLabelId(); |
256 | outLabelId = lspLocalLabelInfo.outLabelId(); | 264 | outLabelId = lspLocalLabelInfo.outLabelId(); | ... | ... |
... | @@ -96,20 +96,20 @@ public class PathComputationTest { | ... | @@ -96,20 +96,20 @@ public class PathComputationTest { |
96 | private final MockDeviceService deviceService = new MockDeviceService(); | 96 | private final MockDeviceService deviceService = new MockDeviceService(); |
97 | private PceManager pceManager = new PceManager(); | 97 | private PceManager pceManager = new PceManager(); |
98 | public static ProviderId providerId = new ProviderId("pce", "foo"); | 98 | public static ProviderId providerId = new ProviderId("pce", "foo"); |
99 | - private static final String DEVICE1 = "D001"; | 99 | + public static final String DEVICE1 = "D001"; |
100 | - private static final String DEVICE2 = "D002"; | 100 | + public static final String DEVICE2 = "D002"; |
101 | - private static final String DEVICE3 = "D003"; | 101 | + public static final String DEVICE3 = "D003"; |
102 | - private static final String DEVICE4 = "D004"; | 102 | + public static final String DEVICE4 = "D004"; |
103 | - private static final String DEVICE5 = "D005"; | 103 | + public static final String DEVICE5 = "D005"; |
104 | public static final String PCEPDEVICE1 = "PD001"; | 104 | public static final String PCEPDEVICE1 = "PD001"; |
105 | public static final String PCEPDEVICE2 = "PD002"; | 105 | public static final String PCEPDEVICE2 = "PD002"; |
106 | public static final String PCEPDEVICE3 = "PD003"; | 106 | public static final String PCEPDEVICE3 = "PD003"; |
107 | public static final String PCEPDEVICE4 = "PD004"; | 107 | public static final String PCEPDEVICE4 = "PD004"; |
108 | - private static final TopologyVertex D1 = new DefaultTopologyVertex(DeviceId.deviceId("D001")); | 108 | + public static final TopologyVertex D1 = new DefaultTopologyVertex(DeviceId.deviceId("D001")); |
109 | - private static final TopologyVertex D2 = new DefaultTopologyVertex(DeviceId.deviceId("D002")); | 109 | + public static final TopologyVertex D2 = new DefaultTopologyVertex(DeviceId.deviceId("D002")); |
110 | - private static final TopologyVertex D3 = new DefaultTopologyVertex(DeviceId.deviceId("D003")); | 110 | + public static final TopologyVertex D3 = new DefaultTopologyVertex(DeviceId.deviceId("D003")); |
111 | - private static final TopologyVertex D4 = new DefaultTopologyVertex(DeviceId.deviceId("D004")); | 111 | + public static final TopologyVertex D4 = new DefaultTopologyVertex(DeviceId.deviceId("D004")); |
112 | - private static final TopologyVertex D5 = new DefaultTopologyVertex(DeviceId.deviceId("D005")); | 112 | + public static final TopologyVertex D5 = new DefaultTopologyVertex(DeviceId.deviceId("D005")); |
113 | private static final String ANNOTATION_COST = "cost"; | 113 | private static final String ANNOTATION_COST = "cost"; |
114 | private static final String ANNOTATION_TE_COST = "teCost"; | 114 | private static final String ANNOTATION_TE_COST = "teCost"; |
115 | private static final String UNKNOWN = "unknown"; | 115 | private static final String UNKNOWN = "unknown"; |
... | @@ -130,7 +130,7 @@ public class PathComputationTest { | ... | @@ -130,7 +130,7 @@ public class PathComputationTest { |
130 | * | 130 | * |
131 | * @return graph path search algorithm | 131 | * @return graph path search algorithm |
132 | */ | 132 | */ |
133 | - private AbstractGraphPathSearch<TopologyVertex, TopologyEdge> graphSearch() { | 133 | + public static AbstractGraphPathSearch<TopologyVertex, TopologyEdge> graphSearch() { |
134 | return new DijkstraGraphSearch<>(); | 134 | return new DijkstraGraphSearch<>(); |
135 | } | 135 | } |
136 | 136 | ||
... | @@ -143,7 +143,7 @@ public class PathComputationTest { | ... | @@ -143,7 +143,7 @@ public class PathComputationTest { |
143 | * @param port2 destination port | 143 | * @param port2 destination port |
144 | * @return link | 144 | * @return link |
145 | */ | 145 | */ |
146 | - private Link addLink(String device, long port, String device2, long port2, boolean setCost, int value) { | 146 | + public static Link addLink(String device, long port, String device2, long port2, boolean setCost, int value) { |
147 | ConnectPoint src = new ConnectPoint(DeviceId.deviceId(device), PortNumber.portNumber(port)); | 147 | ConnectPoint src = new ConnectPoint(DeviceId.deviceId(device), PortNumber.portNumber(port)); |
148 | ConnectPoint dst = new ConnectPoint(DeviceId.deviceId(device2), PortNumber.portNumber(port2)); | 148 | ConnectPoint dst = new ConnectPoint(DeviceId.deviceId(device2), PortNumber.portNumber(port2)); |
149 | Link curLink; | 149 | Link curLink; |
... | @@ -256,19 +256,37 @@ public class PathComputationTest { | ... | @@ -256,19 +256,37 @@ public class PathComputationTest { |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | - private Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) { | 259 | + /** |
260 | + * Returns the path in Path object format. | ||
261 | + */ | ||
262 | + public static Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) { | ||
260 | List<Link> links = path.edges().stream().map(TopologyEdge::link).collect(Collectors.toList()); | 263 | List<Link> links = path.edges().stream().map(TopologyEdge::link).collect(Collectors.toList()); |
261 | return new DefaultPath(CORE_PROVIDER_ID, links, path.cost()); | 264 | return new DefaultPath(CORE_PROVIDER_ID, links, path.cost()); |
262 | } | 265 | } |
263 | 266 | ||
264 | /** | 267 | /** |
265 | - * Test Resource service for path computation. | 268 | + * Tests Resource service for path computation. |
266 | */ | 269 | */ |
267 | - private class MockPathResourceService extends ResourceServiceAdapter { | 270 | + public class MockPathResourceService extends ResourceServiceAdapter { |
268 | private final Map<Resource, ResourceConsumer> assignment = new HashMap<>(); | 271 | private final Map<Resource, ResourceConsumer> assignment = new HashMap<>(); |
269 | private Map<ResourceId, List<ResourceAllocation>> resourcesAllocations = new HashMap<>(); | 272 | private Map<ResourceId, List<ResourceAllocation>> resourcesAllocations = new HashMap<>(); |
270 | 273 | ||
271 | @Override | 274 | @Override |
275 | + public Optional<ResourceAllocation> allocate(ResourceConsumer consumer, Resource resources) { | ||
276 | + List<ResourceAllocation> allocations = allocate(consumer, ImmutableList.of(resources)); | ||
277 | + if (allocations.isEmpty()) { | ||
278 | + return Optional.empty(); | ||
279 | + } | ||
280 | + | ||
281 | + assert allocations.size() == 1; | ||
282 | + ResourceAllocation allocation = allocations.get(0); | ||
283 | + assert allocation.resource().equals(resources); | ||
284 | + | ||
285 | + // cast is ensured by the assertions above | ||
286 | + return Optional.of(allocation); | ||
287 | + } | ||
288 | + | ||
289 | + @Override | ||
272 | public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { | 290 | public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { |
273 | for (Resource resource: resources) { | 291 | for (Resource resource: resources) { |
274 | if (resource instanceof ContinuousResource) { | 292 | if (resource instanceof ContinuousResource) { | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -33,6 +33,8 @@ import org.junit.Before; | ... | @@ -33,6 +33,8 @@ import org.junit.Before; |
33 | import org.junit.Test; | 33 | import org.junit.Test; |
34 | 34 | ||
35 | import org.onosproject.incubator.net.resource.label.LabelResourceId; | 35 | import org.onosproject.incubator.net.resource.label.LabelResourceId; |
36 | +import org.onosproject.core.ApplicationId; | ||
37 | +import org.onosproject.core.CoreService; | ||
36 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; | 38 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; |
37 | import org.onosproject.incubator.net.resource.label.LabelResourceService; | 39 | import org.onosproject.incubator.net.resource.label.LabelResourceService; |
38 | import org.onosproject.incubator.net.tunnel.LabelStack; | 40 | import org.onosproject.incubator.net.tunnel.LabelStack; |
... | @@ -41,6 +43,7 @@ import org.onosproject.net.DefaultAnnotations; | ... | @@ -41,6 +43,7 @@ import org.onosproject.net.DefaultAnnotations; |
41 | import org.onosproject.net.DefaultPath; | 43 | import org.onosproject.net.DefaultPath; |
42 | import org.onosproject.net.DeviceId; | 44 | import org.onosproject.net.DeviceId; |
43 | import org.onosproject.net.PortNumber; | 45 | import org.onosproject.net.PortNumber; |
46 | +import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
44 | import org.onosproject.net.Path; | 47 | import org.onosproject.net.Path; |
45 | import org.onosproject.pce.pcestore.api.PceStore; | 48 | import org.onosproject.pce.pcestore.api.PceStore; |
46 | import org.onosproject.net.provider.ProviderId; | 49 | import org.onosproject.net.provider.ProviderId; |
... | @@ -61,6 +64,9 @@ public class PceccSrTeBeHandlerTest { | ... | @@ -61,6 +64,9 @@ public class PceccSrTeBeHandlerTest { |
61 | protected LabelResourceAdminService labelRsrcAdminService; | 64 | protected LabelResourceAdminService labelRsrcAdminService; |
62 | protected LabelResourceService labelRsrcService; | 65 | protected LabelResourceService labelRsrcService; |
63 | protected PceStore pceStore; | 66 | protected PceStore pceStore; |
67 | + private FlowObjectiveService flowObjectiveService; | ||
68 | + private CoreService coreService; | ||
69 | + private ApplicationId appId; | ||
64 | private ProviderId providerId; | 70 | private ProviderId providerId; |
65 | private DeviceId deviceId1; | 71 | private DeviceId deviceId1; |
66 | private DeviceId deviceId2; | 72 | private DeviceId deviceId2; |
... | @@ -88,8 +94,11 @@ public class PceccSrTeBeHandlerTest { | ... | @@ -88,8 +94,11 @@ public class PceccSrTeBeHandlerTest { |
88 | srTeHandler = PceccSrTeBeHandler.getInstance(); | 94 | srTeHandler = PceccSrTeBeHandler.getInstance(); |
89 | labelRsrcService = new LabelResourceAdapter(); | 95 | labelRsrcService = new LabelResourceAdapter(); |
90 | labelRsrcAdminService = new LabelResourceAdapter(); | 96 | labelRsrcAdminService = new LabelResourceAdapter(); |
97 | + flowObjectiveService = new PceManagerTest.MockFlowObjService(); | ||
98 | + coreService = new PceManagerTest.MockCoreService(); | ||
99 | + appId = coreService.registerApplication("org.onosproject.pce"); | ||
91 | pceStore = new PceStoreAdapter(); | 100 | pceStore = new PceStoreAdapter(); |
92 | - srTeHandler.initialize(labelRsrcAdminService, labelRsrcService, pceStore); | 101 | + srTeHandler.initialize(labelRsrcAdminService, labelRsrcService, flowObjectiveService, appId, pceStore); |
93 | 102 | ||
94 | // Creates path | 103 | // Creates path |
95 | // Creates list of links | 104 | // Creates list of links |
... | @@ -446,39 +455,39 @@ public class PceccSrTeBeHandlerTest { | ... | @@ -446,39 +455,39 @@ public class PceccSrTeBeHandlerTest { |
446 | // check node-label of deviceId1 | 455 | // check node-label of deviceId1 |
447 | List<LabelResourceId> labelList = labelStack.labelResources(); | 456 | List<LabelResourceId> labelList = labelStack.labelResources(); |
448 | Iterator<LabelResourceId> iterator = labelList.iterator(); | 457 | Iterator<LabelResourceId> iterator = labelList.iterator(); |
449 | - labelId = (LabelResourceId) iterator.next(); | 458 | + labelId = iterator.next(); |
450 | assertThat(labelId, is(LabelResourceId.labelResourceId(4097))); | 459 | assertThat(labelId, is(LabelResourceId.labelResourceId(4097))); |
451 | 460 | ||
452 | // check adjacency label of deviceId1 | 461 | // check adjacency label of deviceId1 |
453 | - labelId = (LabelResourceId) iterator.next(); | 462 | + labelId = iterator.next(); |
454 | assertThat(labelId, is(LabelResourceId.labelResourceId(5122))); | 463 | assertThat(labelId, is(LabelResourceId.labelResourceId(5122))); |
455 | 464 | ||
456 | // check node-label of deviceId2 | 465 | // check node-label of deviceId2 |
457 | - labelId = (LabelResourceId) iterator.next(); | 466 | + labelId = iterator.next(); |
458 | assertThat(labelId, is(LabelResourceId.labelResourceId(4098))); | 467 | assertThat(labelId, is(LabelResourceId.labelResourceId(4098))); |
459 | 468 | ||
460 | // check adjacency label of deviceId2 | 469 | // check adjacency label of deviceId2 |
461 | - labelId = (LabelResourceId) iterator.next(); | 470 | + labelId = iterator.next(); |
462 | assertThat(labelId, is(LabelResourceId.labelResourceId(5123))); | 471 | assertThat(labelId, is(LabelResourceId.labelResourceId(5123))); |
463 | 472 | ||
464 | // check node-label of deviceId3 | 473 | // check node-label of deviceId3 |
465 | - labelId = (LabelResourceId) iterator.next(); | 474 | + labelId = iterator.next(); |
466 | assertThat(labelId, is(LabelResourceId.labelResourceId(4099))); | 475 | assertThat(labelId, is(LabelResourceId.labelResourceId(4099))); |
467 | 476 | ||
468 | // check adjacency label of deviceId3 | 477 | // check adjacency label of deviceId3 |
469 | - labelId = (LabelResourceId) iterator.next(); | 478 | + labelId = iterator.next(); |
470 | assertThat(labelId, is(LabelResourceId.labelResourceId(5124))); | 479 | assertThat(labelId, is(LabelResourceId.labelResourceId(5124))); |
471 | 480 | ||
472 | // check node-label of deviceId4 | 481 | // check node-label of deviceId4 |
473 | - labelId = (LabelResourceId) iterator.next(); | 482 | + labelId = iterator.next(); |
474 | assertThat(labelId, is(LabelResourceId.labelResourceId(4100))); | 483 | assertThat(labelId, is(LabelResourceId.labelResourceId(4100))); |
475 | 484 | ||
476 | // check adjacency label of deviceId4 | 485 | // check adjacency label of deviceId4 |
477 | - labelId = (LabelResourceId) iterator.next(); | 486 | + labelId = iterator.next(); |
478 | assertThat(labelId, is(LabelResourceId.labelResourceId(5125))); | 487 | assertThat(labelId, is(LabelResourceId.labelResourceId(5125))); |
479 | 488 | ||
480 | // check node-label of deviceId5 | 489 | // check node-label of deviceId5 |
481 | - labelId = (LabelResourceId) iterator.next(); | 490 | + labelId = iterator.next(); |
482 | assertThat(labelId, is(LabelResourceId.labelResourceId(4101))); | 491 | assertThat(labelId, is(LabelResourceId.labelResourceId(4101))); |
483 | } | 492 | } |
484 | } | 493 | } | ... | ... |
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.util; | ||
17 | + | ||
18 | +import java.util.List; | ||
19 | + | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | +import org.onosproject.net.flowobjective.FilteringObjective; | ||
22 | +import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
23 | +import org.onosproject.net.flowobjective.ForwardingObjective; | ||
24 | +import org.onosproject.net.flowobjective.NextObjective; | ||
25 | + | ||
26 | +/** | ||
27 | + * Test implementation of FlowObjectiveService. | ||
28 | + */ | ||
29 | +public class FlowObjServiceAdapter implements FlowObjectiveService { | ||
30 | + | ||
31 | + private ForwardingObjective forwardingObjective; | ||
32 | + @Override | ||
33 | + public void filter(DeviceId deviceId, FilteringObjective filteringObjective) { | ||
34 | + | ||
35 | + } | ||
36 | + | ||
37 | + @Override | ||
38 | + public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) { | ||
39 | + this.forwardingObjective = forwardingObjective; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public void next(DeviceId deviceId, NextObjective nextObjective) { | ||
44 | + | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public int allocateNextId() { | ||
49 | + return 0; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public void initPolicy(String policy) { | ||
54 | + | ||
55 | + } | ||
56 | + | ||
57 | + public ForwardingObjective forwardingObjective() { | ||
58 | + return forwardingObjective; | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public List<String> getNextMappings() { | ||
63 | + return null; | ||
64 | + } | ||
65 | +} |
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.util; | ||
17 | + | ||
18 | +import java.util.Collection; | ||
19 | + | ||
20 | +import org.onosproject.core.ApplicationId; | ||
21 | +import org.onosproject.incubator.net.tunnel.Tunnel; | ||
22 | +import org.onosproject.incubator.net.tunnel.Tunnel.Type; | ||
23 | +import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | ||
24 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
25 | +import org.onosproject.incubator.net.tunnel.TunnelListener; | ||
26 | +import org.onosproject.incubator.net.tunnel.TunnelName; | ||
27 | +import org.onosproject.incubator.net.tunnel.TunnelService; | ||
28 | +import org.onosproject.incubator.net.tunnel.TunnelSubscription; | ||
29 | +import org.onosproject.net.Annotations; | ||
30 | +import org.onosproject.net.DeviceId; | ||
31 | +import org.onosproject.net.ElementId; | ||
32 | +import org.onosproject.net.Path; | ||
33 | + | ||
34 | +/** | ||
35 | + * Provides test implementation of class TunnelService. | ||
36 | + */ | ||
37 | +public class TunnelServiceAdapter implements TunnelService { | ||
38 | + | ||
39 | + @Override | ||
40 | + public void addListener(TunnelListener listener) { | ||
41 | + // TODO Auto-generated method stub | ||
42 | + | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public void removeListener(TunnelListener listener) { | ||
47 | + // TODO Auto-generated method stub | ||
48 | + | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { | ||
53 | + // TODO Auto-generated method stub | ||
54 | + return null; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName, | ||
59 | + Annotations... annotations) { | ||
60 | + // TODO Auto-generated method stub | ||
61 | + return null; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, | ||
66 | + Annotations... annotations) { | ||
67 | + // TODO Auto-generated method stub | ||
68 | + return null; | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type, | ||
73 | + Annotations... annotations) { | ||
74 | + // TODO Auto-generated method stub | ||
75 | + return null; | ||
76 | + } | ||
77 | + | ||
78 | + @Override | ||
79 | + public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { | ||
80 | + // TODO Auto-generated method stub | ||
81 | + return null; | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public boolean downTunnel(ApplicationId producerId, TunnelId tunnelId) { | ||
86 | + // TODO Auto-generated method stub | ||
87 | + return false; | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { | ||
92 | + // TODO Auto-generated method stub | ||
93 | + return false; | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, Annotations... annotations) { | ||
98 | + // TODO Auto-generated method stub | ||
99 | + return false; | ||
100 | + } | ||
101 | + | ||
102 | + @Override | ||
103 | + public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type, | ||
104 | + Annotations... annotations) { | ||
105 | + // TODO Auto-generated method stub | ||
106 | + return false; | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, | ||
111 | + Annotations... annotations) { | ||
112 | + // TODO Auto-generated method stub | ||
113 | + return false; | ||
114 | + } | ||
115 | + | ||
116 | + @Override | ||
117 | + public Tunnel queryTunnel(TunnelId tunnelId) { | ||
118 | + // TODO Auto-generated method stub | ||
119 | + return null; | ||
120 | + } | ||
121 | + | ||
122 | + @Override | ||
123 | + public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) { | ||
124 | + // TODO Auto-generated method stub | ||
125 | + return null; | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
129 | + public Collection<Tunnel> queryTunnel(Type type) { | ||
130 | + // TODO Auto-generated method stub | ||
131 | + return null; | ||
132 | + } | ||
133 | + | ||
134 | + @Override | ||
135 | + public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) { | ||
136 | + // TODO Auto-generated method stub | ||
137 | + return null; | ||
138 | + } | ||
139 | + | ||
140 | + @Override | ||
141 | + public Collection<Tunnel> queryAllTunnels() { | ||
142 | + // TODO Auto-generated method stub | ||
143 | + return null; | ||
144 | + } | ||
145 | + | ||
146 | + @Override | ||
147 | + public int tunnelCount() { | ||
148 | + // TODO Auto-generated method stub | ||
149 | + return 0; | ||
150 | + } | ||
151 | + | ||
152 | + @Override | ||
153 | + public Iterable<Tunnel> getTunnels(DeviceId deviceId) { | ||
154 | + // TODO Auto-generated method stub | ||
155 | + return null; | ||
156 | + } | ||
157 | + | ||
158 | +} |
... | @@ -56,4 +56,15 @@ public final class PcepAnnotationKeys { | ... | @@ -56,4 +56,15 @@ public final class PcepAnnotationKeys { |
56 | * Annotation key for the identification of initiated LSP. | 56 | * Annotation key for the identification of initiated LSP. |
57 | */ | 57 | */ |
58 | public static final String PCE_INIT = "pceInit"; | 58 | public static final String PCE_INIT = "pceInit"; |
59 | + | ||
60 | + /** | ||
61 | + * Annotation key for the cost type. | ||
62 | + */ | ||
63 | + public static final String COST_TYPE = "costType"; | ||
64 | + | ||
65 | + /** | ||
66 | + * Annotation key for the Delegation. | ||
67 | + * Whether LSPs are delegated or not | ||
68 | + */ | ||
69 | + public static final String DELEGATE = "delegate"; | ||
59 | } | 70 | } | ... | ... |
-
Please register or login to post a comment