Avantika-Huawei
Committed by Gerrit Code Review

Move PCE label handling from APP to protocol.

Change-Id: I26ae21b27ac2dc9ae3302030f6860e0e371c342c
Showing 60 changed files with 3085 additions and 852 deletions
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.pcestore;
17 -
18 -import com.google.common.base.MoreObjects;
19 -
20 -import java.util.Objects;
21 -import java.util.List;
22 -
23 -import org.onosproject.net.resource.ResourceConsumer;
24 -import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
25 -
26 -/**
27 - * PCECC tunnel information is used to store
28 - * list of links label information of a path containing IN, OUT label and destination port of a link
29 - * to release label allocation in devices.
30 - * Also storing resource consumer id to release bandwdith of a tunnel.
31 - * The first entry is created with TunnelId and resource consumer id,
32 - * later this entry may be updated to store label information on basic PCECC case.
33 - */
34 -public final class PceccTunnelInfo {
35 -
36 - private List<LspLocalLabelInfo> lspLocalLabelInfoList;
37 -
38 - private ResourceConsumer tunnelConsumerId;
39 -
40 - /**
41 - * Initialization of member variables.
42 - *
43 - * @param lspLocalLabelInfoList list of devices local label info
44 - * @param tunnelConsumerId tunnel consumer id
45 - */
46 - public PceccTunnelInfo(List<LspLocalLabelInfo> lspLocalLabelInfoList,
47 - ResourceConsumer tunnelConsumerId) {
48 - this.lspLocalLabelInfoList = lspLocalLabelInfoList;
49 - this.tunnelConsumerId = tunnelConsumerId;
50 - }
51 -
52 - /**
53 - * Initialization for serialization.
54 - */
55 - public PceccTunnelInfo() {
56 - this.lspLocalLabelInfoList = null;
57 - this.tunnelConsumerId = null;
58 - }
59 -
60 - /**
61 - * Retrieves list of devices local label info.
62 - *
63 - * @return list of devices local label info
64 - */
65 - public List<LspLocalLabelInfo> lspLocalLabelInfoList() {
66 - return this.lspLocalLabelInfoList;
67 - }
68 -
69 - /**
70 - * Retrieves tunnel consumer id.
71 - *
72 - * @return tunnel consumer id
73 - */
74 - public ResourceConsumer tunnelConsumerId() {
75 - return this.tunnelConsumerId;
76 - }
77 -
78 - /**
79 - * Sets list of local label info of a path.
80 - *
81 - * @param lspLocalLabelInfoList list of devices local label info
82 - */
83 - public void lspLocalLabelInfoList(List<LspLocalLabelInfo> lspLocalLabelInfoList) {
84 - this.lspLocalLabelInfoList = lspLocalLabelInfoList;
85 - }
86 -
87 - /**
88 - * Sets tunnel consumer id.
89 - *
90 - * @param id tunnel consumer id
91 - */
92 - public void tunnelConsumerId(ResourceConsumer id) {
93 - this.tunnelConsumerId = id;
94 - }
95 -
96 - @Override
97 - public int hashCode() {
98 - return Objects.hash(lspLocalLabelInfoList, tunnelConsumerId);
99 - }
100 -
101 - @Override
102 - public boolean equals(Object obj) {
103 - if (this == obj) {
104 - return true;
105 - }
106 - if (obj instanceof PceccTunnelInfo) {
107 - final PceccTunnelInfo other = (PceccTunnelInfo) obj;
108 - return Objects.equals(this.lspLocalLabelInfoList, other.lspLocalLabelInfoList) &&
109 - Objects.equals(this.tunnelConsumerId, other.tunnelConsumerId);
110 - }
111 - return false;
112 - }
113 -
114 - @Override
115 - public String toString() {
116 - return MoreObjects.toStringHelper(getClass())
117 - .omitNullValues()
118 - .add("DeviceLabelInfoList", lspLocalLabelInfoList)
119 - .add("TunnelConsumerId", tunnelConsumerId)
120 - .toString();
121 - }
122 -}
...@@ -15,14 +15,8 @@ ...@@ -15,14 +15,8 @@
15 */ 15 */
16 package org.onosproject.pce.pcestore.api; 16 package org.onosproject.pce.pcestore.api;
17 17
18 -import java.util.List;
19 -
20 -import org.onosproject.incubator.net.resource.label.LabelResourceId;
21 import org.onosproject.incubator.net.tunnel.TunnelId; 18 import org.onosproject.incubator.net.tunnel.TunnelId;
22 -import org.onosproject.net.DeviceId;
23 -import org.onosproject.net.Link;
24 import org.onosproject.net.resource.ResourceConsumer; 19 import org.onosproject.net.resource.ResourceConsumer;
25 -import org.onosproject.pce.pcestore.PceccTunnelInfo;
26 import org.onosproject.pce.pcestore.PcePathInfo; 20 import org.onosproject.pce.pcestore.PcePathInfo;
27 21
28 import java.util.Map; 22 import java.util.Map;
...@@ -32,22 +26,6 @@ import java.util.Map; ...@@ -32,22 +26,6 @@ import java.util.Map;
32 */ 26 */
33 public interface PceStore { 27 public interface PceStore {
34 /** 28 /**
35 - * Checks whether device id is present in global node label store.
36 - *
37 - * @param id device id
38 - * @return success of failure
39 - */
40 - boolean existsGlobalNodeLabel(DeviceId id);
41 -
42 - /**
43 - * Checks whether link is present in adjacency label store.
44 - *
45 - * @param link link between devices
46 - * @return success of failure
47 - */
48 - boolean existsAdjLabel(Link link);
49 -
50 - /**
51 * Checks whether tunnel id is present in tunnel info store. 29 * Checks whether tunnel id is present in tunnel info store.
52 * 30 *
53 * @param tunnelId tunnel id 31 * @param tunnelId tunnel id
...@@ -64,20 +42,6 @@ public interface PceStore { ...@@ -64,20 +42,6 @@ public interface PceStore {
64 boolean existsFailedPathInfo(PcePathInfo failedPathInfo); 42 boolean existsFailedPathInfo(PcePathInfo failedPathInfo);
65 43
66 /** 44 /**
67 - * Retrieves the node label count.
68 - *
69 - * @return node label count
70 - */
71 - int getGlobalNodeLabelCount();
72 -
73 - /**
74 - * Retrieves the adjacency label count.
75 - *
76 - * @return adjacency label count
77 - */
78 - int getAdjLabelCount();
79 -
80 - /**
81 * Retrieves the tunnel info count. 45 * Retrieves the tunnel info count.
82 * 46 *
83 * @return tunnel info count 47 * @return tunnel info count
...@@ -92,25 +56,11 @@ public interface PceStore { ...@@ -92,25 +56,11 @@ public interface PceStore {
92 int getFailedPathInfoCount(); 56 int getFailedPathInfoCount();
93 57
94 /** 58 /**
95 - * Retrieves device id and label pairs collection from global node label store.
96 - *
97 - * @return collection of device id and label pairs
98 - */
99 - Map<DeviceId, LabelResourceId> getGlobalNodeLabels();
100 -
101 - /**
102 - * Retrieves link and label pairs collection from adjacency label store.
103 - *
104 - * @return collection of link and label pairs
105 - */
106 - Map<Link, LabelResourceId> getAdjLabels();
107 -
108 - /**
109 * Retrieves tunnel id and pcecc tunnel info pairs collection from tunnel info store. 59 * Retrieves tunnel id and pcecc tunnel info pairs collection from tunnel info store.
110 * 60 *
111 - * @return collection of tunnel id and pcecc tunnel info pairs 61 + * @return collection of tunnel id and resource consumer pairs
112 */ 62 */
113 - Map<TunnelId, PceccTunnelInfo> getTunnelInfos(); 63 + Map<TunnelId, ResourceConsumer> getTunnelInfos();
114 64
115 /** 65 /**
116 * Retrieves path info collection from failed path info store. 66 * Retrieves path info collection from failed path info store.
...@@ -120,52 +70,20 @@ public interface PceStore { ...@@ -120,52 +70,20 @@ public interface PceStore {
120 Iterable<PcePathInfo> getFailedPathInfos(); 70 Iterable<PcePathInfo> getFailedPathInfos();
121 71
122 /** 72 /**
123 - * Retrieves node label for specified device id.
124 - *
125 - * @param id device id
126 - * @return node label
127 - */
128 - LabelResourceId getGlobalNodeLabel(DeviceId id);
129 -
130 - /**
131 - * Retrieves adjacency label for specified link.
132 - *
133 - * @param link between devices
134 - * @return adjacency label
135 - */
136 - LabelResourceId getAdjLabel(Link link);
137 -
138 - /**
139 * Retrieves local label info with tunnel consumer id from tunnel info store. 73 * Retrieves local label info with tunnel consumer id from tunnel info store.
140 * 74 *
141 * @param tunnelId tunnel id 75 * @param tunnelId tunnel id
142 - * @return pcecc tunnel info 76 + * @return resource consumer
143 - */
144 - PceccTunnelInfo getTunnelInfo(TunnelId tunnelId);
145 -
146 - /**
147 - * Stores node label into global node label store.
148 - *
149 - * @param deviceId device id
150 - * @param labelId node label id
151 - */
152 - void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId);
153 -
154 - /**
155 - * Stores adjacency label into adjacency label store.
156 - *
157 - * @param link link between nodes
158 - * @param labelId link label id
159 */ 77 */
160 - void addAdjLabel(Link link, LabelResourceId labelId); 78 + ResourceConsumer getTunnelInfo(TunnelId tunnelId);
161 79
162 /** 80 /**
163 * Stores local label info with tunnel consumer id into tunnel info store for specified tunnel id. 81 * Stores local label info with tunnel consumer id into tunnel info store for specified tunnel id.
164 * 82 *
165 * @param tunnelId tunnel id 83 * @param tunnelId tunnel id
166 - * @param pceccTunnelInfo local label info 84 + * @param tunnelConsumerId tunnel consumer id
167 */ 85 */
168 - void addTunnelInfo(TunnelId tunnelId, PceccTunnelInfo pceccTunnelInfo); 86 + void addTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId);
169 87
170 /** 88 /**
171 * Stores path information into failed path info store. 89 * Stores path information into failed path info store.
...@@ -175,41 +93,6 @@ public interface PceStore { ...@@ -175,41 +93,6 @@ public interface PceStore {
175 void addFailedPathInfo(PcePathInfo failedPathInfo); 93 void addFailedPathInfo(PcePathInfo failedPathInfo);
176 94
177 /** 95 /**
178 - * Updates local label info. The first entry is created with TunnelId and TunnelConsumerId.
179 - * Later this entry may be updated to store label information if it is basic PCECC case.
180 - *
181 - * @param tunnelId tunnel id
182 - * @param lspLocalLabelInfoList list of local labels
183 - * @return success or failure
184 - */
185 - boolean updateTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList);
186 -
187 - /**
188 - * Updates tunnel info map with tunnel consumer id.
189 - *
190 - * @param tunnelId tunnel id
191 - * @param tunnelConsumerId tunnel consumer id
192 - * @return success or failure
193 - */
194 - boolean updateTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId);
195 -
196 - /**
197 - * Removes device label from global node label store for specified device id.
198 - *
199 - * @param id device id
200 - * @return success or failure
201 - */
202 - boolean removeGlobalNodeLabel(DeviceId id);
203 -
204 - /**
205 - * Removes adjacency label from adjacency label store for specified link information.
206 - *
207 - * @param link between nodes
208 - * @return success or failure
209 - */
210 - boolean removeAdjLabel(Link link);
211 -
212 - /**
213 * Removes local label info with tunnel consumer id from tunnel info store for specified tunnel id. 96 * Removes local label info with tunnel consumer id from tunnel info store for specified tunnel id.
214 * 97 *
215 * @param tunnelId tunnel id 98 * @param tunnelId tunnel id
...@@ -224,54 +107,4 @@ public interface PceStore { ...@@ -224,54 +107,4 @@ public interface PceStore {
224 * @return success or failure 107 * @return success or failure
225 */ 108 */
226 boolean removeFailedPathInfo(PcePathInfo failedPathInfo); 109 boolean removeFailedPathInfo(PcePathInfo failedPathInfo);
227 -
228 - /**
229 - * Adds lsrid to device id mapping.
230 - *
231 - * @param lsrId lsrId of the device
232 - * @param deviceId device id
233 - * @return success or failure
234 - */
235 - boolean addLsrIdDevice(String lsrId, DeviceId deviceId);
236 -
237 - /**
238 - * Removes lsrid to device id mapping.
239 - *
240 - * @param lsrId lsrId of the device
241 - * @return success or failure
242 - */
243 - boolean removeLsrIdDevice(String lsrId);
244 -
245 - /**
246 - * Gets lsrid to device id mapping.
247 - *
248 - * @param lsrId lsrId of the device
249 - * @return device id of the lsrId
250 - */
251 - DeviceId getLsrIdDevice(String lsrId);
252 -
253 - /**
254 - * Adds lsrId of the PCC in form of device id for the PCC for which sync is pending due to non-availability of BGP.
255 - * device.
256 - *
257 - * @param lsrId LSR id of the PCC in form of device id
258 - * @return success or failure
259 - */
260 - public boolean addPccLsr(DeviceId lsrId);
261 -
262 - /**
263 - * Removes lsrId of the PCC in form of device id for the PCC for which pending sync is done.
264 - *
265 - * @param lsrId LSR id of the PCC in form of device id
266 - * @return success or failure
267 - */
268 - public boolean removePccLsr(DeviceId lsrId);
269 -
270 - /**
271 - * Gets lsrId of the PCC in form of device id.
272 - *
273 - * @param lsrId LSR id of the PCC in form of device id
274 - * @return success or failure
275 - */
276 - public boolean hasPccLsr(DeviceId lsrId);
277 } 110 }
......
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.pcestore;
17 -
18 -import java.util.LinkedList;
19 -import java.util.List;
20 -
21 -import static org.hamcrest.MatcherAssert.assertThat;
22 -import static org.hamcrest.Matchers.is;
23 -
24 -import com.google.common.testing.EqualsTester;
25 -
26 -import org.junit.Test;
27 -import org.onosproject.incubator.net.resource.label.LabelResourceId;
28 -import org.onosproject.net.DeviceId;
29 -import org.onosproject.net.PortNumber;
30 -import org.onosproject.net.resource.ResourceConsumer;
31 -import org.onosproject.pce.pceservice.TunnelConsumerId;
32 -import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
33 -
34 -/**
35 - * Unit tests for PceccTunnelInfo class.
36 - */
37 -public class PceccTunnelInfoTest {
38 -
39 - /**
40 - * Checks the operation of equals() methods.
41 - */
42 - @Test
43 - public void testEquals() {
44 - // create same two objects.
45 - List<LspLocalLabelInfo> lspLocalLabelList1 = new LinkedList<>();
46 - ResourceConsumer tunnelConsumerId1 = TunnelConsumerId.valueOf(10);
47 -
48 - // create object of DefaultLspLocalLabelInfo
49 - DeviceId deviceId1 = DeviceId.deviceId("foo");
50 - LabelResourceId inLabelId1 = LabelResourceId.labelResourceId(1);
51 - LabelResourceId outLabelId1 = LabelResourceId.labelResourceId(2);
52 - PortNumber inPort1 = PortNumber.portNumber(5122);
53 - PortNumber outPort1 = PortNumber.portNumber(5123);
54 -
55 - LspLocalLabelInfo lspLocalLabel1 = DefaultLspLocalLabelInfo.builder()
56 - .deviceId(deviceId1)
57 - .inLabelId(inLabelId1)
58 - .outLabelId(outLabelId1)
59 - .inPort(inPort1)
60 - .outPort(outPort1)
61 - .build();
62 - lspLocalLabelList1.add(lspLocalLabel1);
63 -
64 - PceccTunnelInfo pceccTunnelInfo1 = new PceccTunnelInfo(lspLocalLabelList1, tunnelConsumerId1);
65 -
66 - // create same as above object
67 - PceccTunnelInfo samePceccTunnelInfo1 = new PceccTunnelInfo(lspLocalLabelList1, tunnelConsumerId1);
68 -
69 - // Create different object.
70 - List<LspLocalLabelInfo> lspLocalLabelInfoList2 = new LinkedList<>();
71 - ResourceConsumer tunnelConsumerId2 = TunnelConsumerId.valueOf(20);
72 -
73 - // create object of DefaultLspLocalLabelInfo
74 - DeviceId deviceId2 = DeviceId.deviceId("goo");
75 - LabelResourceId inLabelId2 = LabelResourceId.labelResourceId(3);
76 - LabelResourceId outLabelId2 = LabelResourceId.labelResourceId(4);
77 - PortNumber inPort2 = PortNumber.portNumber(5124);
78 - PortNumber outPort2 = PortNumber.portNumber(5125);
79 -
80 - LspLocalLabelInfo lspLocalLabel2 = DefaultLspLocalLabelInfo.builder()
81 - .deviceId(deviceId2)
82 - .inLabelId(inLabelId2)
83 - .outLabelId(outLabelId2)
84 - .inPort(inPort2)
85 - .outPort(outPort2)
86 - .build();
87 - lspLocalLabelInfoList2.add(lspLocalLabel2);
88 -
89 - PceccTunnelInfo pceccTunnelInfo2 = new PceccTunnelInfo(lspLocalLabelInfoList2, tunnelConsumerId2);
90 -
91 - new EqualsTester().addEqualityGroup(pceccTunnelInfo1, samePceccTunnelInfo1)
92 - .addEqualityGroup(pceccTunnelInfo2)
93 - .testEquals();
94 - }
95 -
96 - /**
97 - * Checks the construction of a PceccTunnelInfo object.
98 - */
99 - @Test
100 - public void testConstruction() {
101 - List<LspLocalLabelInfo> lspLocalLabelInfoList = new LinkedList<>();
102 - ResourceConsumer tunnelConsumerId = TunnelConsumerId.valueOf(10);
103 -
104 - // create object of DefaultLspLocalLabelInfo
105 - DeviceId deviceId = DeviceId.deviceId("foo");
106 - LabelResourceId inLabelId = LabelResourceId.labelResourceId(1);
107 - LabelResourceId outLabelId = LabelResourceId.labelResourceId(2);
108 - PortNumber inPort = PortNumber.portNumber(5122);
109 - PortNumber outPort = PortNumber.portNumber(5123);
110 -
111 - LspLocalLabelInfo lspLocalLabelInfo = DefaultLspLocalLabelInfo.builder()
112 - .deviceId(deviceId)
113 - .inLabelId(inLabelId)
114 - .outLabelId(outLabelId)
115 - .inPort(inPort)
116 - .outPort(outPort)
117 - .build();
118 - lspLocalLabelInfoList.add(lspLocalLabelInfo);
119 -
120 - PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(lspLocalLabelInfoList, tunnelConsumerId);
121 -
122 - assertThat(lspLocalLabelInfoList, is(pceccTunnelInfo.lspLocalLabelInfoList()));
123 - }
124 -}
...@@ -22,19 +22,14 @@ import java.util.concurrent.ConcurrentMap; ...@@ -22,19 +22,14 @@ import java.util.concurrent.ConcurrentMap;
22 22
23 import java.util.HashMap; 23 import java.util.HashMap;
24 import java.util.HashSet; 24 import java.util.HashSet;
25 -import java.util.List;
26 import java.util.Map; 25 import java.util.Map;
27 import java.util.Set; 26 import java.util.Set;
28 import java.util.stream.Collectors; 27 import java.util.stream.Collectors;
29 28
30 -import org.onosproject.incubator.net.resource.label.LabelResourceId;
31 import org.onosproject.incubator.net.tunnel.TunnelId; 29 import org.onosproject.incubator.net.tunnel.TunnelId;
32 import org.onosproject.net.DeviceId; 30 import org.onosproject.net.DeviceId;
33 -import org.onosproject.net.Link;
34 import org.onosproject.net.resource.ResourceConsumer; 31 import org.onosproject.net.resource.ResourceConsumer;
35 -import org.onosproject.pce.pcestore.PceccTunnelInfo;
36 import org.onosproject.pce.pcestore.PcePathInfo; 32 import org.onosproject.pce.pcestore.PcePathInfo;
37 -import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
38 import org.onosproject.pce.pcestore.api.PceStore; 33 import org.onosproject.pce.pcestore.api.PceStore;
39 34
40 /** 35 /**
...@@ -42,14 +37,8 @@ import org.onosproject.pce.pcestore.api.PceStore; ...@@ -42,14 +37,8 @@ import org.onosproject.pce.pcestore.api.PceStore;
42 */ 37 */
43 public class PceStoreAdapter implements PceStore { 38 public class PceStoreAdapter implements PceStore {
44 39
45 - // Mapping device with global node label
46 - private ConcurrentMap<DeviceId, LabelResourceId> globalNodeLabelMap = new ConcurrentHashMap<>();
47 -
48 - // Mapping link with adjacency label
49 - private ConcurrentMap<Link, LabelResourceId> adjLabelMap = new ConcurrentHashMap<>();
50 -
51 // Mapping tunnel with device local info with tunnel consumer id 40 // Mapping tunnel with device local info with tunnel consumer id
52 - private ConcurrentMap<TunnelId, PceccTunnelInfo> tunnelInfoMap = new ConcurrentHashMap<>(); 41 + private ConcurrentMap<TunnelId, ResourceConsumer> tunnelInfoMap = new ConcurrentHashMap<>();
53 42
54 // Set of Path info 43 // Set of Path info
55 private Set<PcePathInfo> failedPathInfoSet = new HashSet<>(); 44 private Set<PcePathInfo> failedPathInfoSet = new HashSet<>();
...@@ -58,16 +47,6 @@ public class PceStoreAdapter implements PceStore { ...@@ -58,16 +47,6 @@ public class PceStoreAdapter implements PceStore {
58 private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>(); 47 private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
59 48
60 @Override 49 @Override
61 - public boolean existsGlobalNodeLabel(DeviceId id) {
62 - return globalNodeLabelMap.containsKey(id);
63 - }
64 -
65 - @Override
66 - public boolean existsAdjLabel(Link link) {
67 - return adjLabelMap.containsKey(link);
68 - }
69 -
70 - @Override
71 public boolean existsTunnelInfo(TunnelId tunnelId) { 50 public boolean existsTunnelInfo(TunnelId tunnelId) {
72 return tunnelInfoMap.containsKey(tunnelId); 51 return tunnelInfoMap.containsKey(tunnelId);
73 } 52 }
...@@ -78,16 +57,6 @@ public class PceStoreAdapter implements PceStore { ...@@ -78,16 +57,6 @@ public class PceStoreAdapter implements PceStore {
78 } 57 }
79 58
80 @Override 59 @Override
81 - public int getGlobalNodeLabelCount() {
82 - return globalNodeLabelMap.size();
83 - }
84 -
85 - @Override
86 - public int getAdjLabelCount() {
87 - return adjLabelMap.size();
88 - }
89 -
90 - @Override
91 public int getTunnelInfoCount() { 60 public int getTunnelInfoCount() {
92 return tunnelInfoMap.size(); 61 return tunnelInfoMap.size();
93 } 62 }
...@@ -98,21 +67,9 @@ public class PceStoreAdapter implements PceStore { ...@@ -98,21 +67,9 @@ public class PceStoreAdapter implements PceStore {
98 } 67 }
99 68
100 @Override 69 @Override
101 - public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() { 70 + public Map<TunnelId, ResourceConsumer> getTunnelInfos() {
102 - return globalNodeLabelMap.entrySet().stream()
103 - .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue()));
104 - }
105 -
106 - @Override
107 - public Map<Link, LabelResourceId> getAdjLabels() {
108 - return adjLabelMap.entrySet().stream()
109 - .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue()));
110 - }
111 -
112 - @Override
113 - public Map<TunnelId, PceccTunnelInfo> getTunnelInfos() {
114 return tunnelInfoMap.entrySet().stream() 71 return tunnelInfoMap.entrySet().stream()
115 - .collect(Collectors.toMap(Map.Entry::getKey, e -> (PceccTunnelInfo) e.getValue())); 72 + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
116 } 73 }
117 74
118 @Override 75 @Override
...@@ -121,33 +78,13 @@ public class PceStoreAdapter implements PceStore { ...@@ -121,33 +78,13 @@ public class PceStoreAdapter implements PceStore {
121 } 78 }
122 79
123 @Override 80 @Override
124 - public LabelResourceId getGlobalNodeLabel(DeviceId id) { 81 + public ResourceConsumer getTunnelInfo(TunnelId tunnelId) {
125 - return globalNodeLabelMap.get(id);
126 - }
127 -
128 - @Override
129 - public LabelResourceId getAdjLabel(Link link) {
130 - return adjLabelMap.get(link);
131 - }
132 -
133 - @Override
134 - public PceccTunnelInfo getTunnelInfo(TunnelId tunnelId) {
135 return tunnelInfoMap.get(tunnelId); 82 return tunnelInfoMap.get(tunnelId);
136 } 83 }
137 84
138 @Override 85 @Override
139 - public void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId) { 86 + public void addTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId) {
140 - globalNodeLabelMap.put(deviceId, labelId); 87 + tunnelInfoMap.put(tunnelId, tunnelConsumerId);
141 - }
142 -
143 - @Override
144 - public void addAdjLabel(Link link, LabelResourceId labelId) {
145 - adjLabelMap.put(link, labelId);
146 - }
147 -
148 - @Override
149 - public void addTunnelInfo(TunnelId tunnelId, PceccTunnelInfo pceccTunnelInfo) {
150 - tunnelInfoMap.put(tunnelId, pceccTunnelInfo);
151 } 88 }
152 89
153 @Override 90 @Override
...@@ -156,48 +93,6 @@ public class PceStoreAdapter implements PceStore { ...@@ -156,48 +93,6 @@ public class PceStoreAdapter implements PceStore {
156 } 93 }
157 94
158 @Override 95 @Override
159 - public boolean updateTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
160 - if (!tunnelInfoMap.containsKey((tunnelId))) {
161 - return false;
162 - }
163 -
164 - PceccTunnelInfo labelStoreInfo = tunnelInfoMap.get(tunnelId);
165 - labelStoreInfo.lspLocalLabelInfoList(lspLocalLabelInfoList);
166 - tunnelInfoMap.put(tunnelId, labelStoreInfo);
167 - return true;
168 - }
169 -
170 - @Override
171 - public boolean updateTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId) {
172 - if (!tunnelInfoMap.containsKey((tunnelId))) {
173 - return false;
174 - }
175 -
176 - PceccTunnelInfo tunnelInfo = tunnelInfoMap.get(tunnelId);
177 - tunnelInfo.tunnelConsumerId(tunnelConsumerId);
178 - tunnelInfoMap.put(tunnelId, tunnelInfo);
179 - return true;
180 - }
181 -
182 - @Override
183 - public boolean removeGlobalNodeLabel(DeviceId id) {
184 - globalNodeLabelMap.remove(id);
185 - if (globalNodeLabelMap.containsKey(id)) {
186 - return false;
187 - }
188 - return true;
189 - }
190 -
191 - @Override
192 - public boolean removeAdjLabel(Link link) {
193 - adjLabelMap.remove(link);
194 - if (adjLabelMap.containsKey(link)) {
195 - return false;
196 - }
197 - return true;
198 - }
199 -
200 - @Override
201 public boolean removeTunnelInfo(TunnelId tunnelId) { 96 public boolean removeTunnelInfo(TunnelId tunnelId) {
202 tunnelInfoMap.remove(tunnelId); 97 tunnelInfoMap.remove(tunnelId);
203 if (tunnelInfoMap.containsKey(tunnelId)) { 98 if (tunnelInfoMap.containsKey(tunnelId)) {
...@@ -213,39 +108,4 @@ public class PceStoreAdapter implements PceStore { ...@@ -213,39 +108,4 @@ public class PceStoreAdapter implements PceStore {
213 } 108 }
214 return true; 109 return true;
215 } 110 }
216 -
217 - @Override
218 - public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
219 - lsrIdDeviceIdMap.put(lsrId, deviceId);
220 - return true;
221 - }
222 -
223 - @Override
224 - public boolean removeLsrIdDevice(String lsrId) {
225 - lsrIdDeviceIdMap.remove(lsrId);
226 - return true;
227 - }
228 -
229 - @Override
230 - public DeviceId getLsrIdDevice(String lsrId) {
231 - return lsrIdDeviceIdMap.get(lsrId);
232 - }
233 -
234 - @Override
235 - public boolean addPccLsr(DeviceId lsrId) {
236 - // TODO Auto-generated method stub
237 - return false;
238 - }
239 -
240 - @Override
241 - public boolean removePccLsr(DeviceId lsrId) {
242 - // TODO Auto-generated method stub
243 - return false;
244 - }
245 -
246 - @Override
247 - public boolean hasPccLsr(DeviceId lsrId) {
248 - // TODO Auto-generated method stub
249 - return false;
250 - }
251 } 111 }
......
...@@ -16,8 +16,14 @@ ...@@ -16,8 +16,14 @@
16 package org.onosproject.pcep.controller; 16 package org.onosproject.pcep.controller;
17 17
18 import java.util.Collection; 18 import java.util.Collection;
19 +import java.util.LinkedList;
19 20
21 +import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
22 +import org.onosproject.incubator.net.tunnel.LabelStack;
23 +import org.onosproject.incubator.net.tunnel.Tunnel;
24 +import org.onosproject.net.Path;
20 import org.onosproject.pcepio.protocol.PcepMessage; 25 import org.onosproject.pcepio.protocol.PcepMessage;
26 +import org.onosproject.pcepio.types.PcepValueType;
21 27
22 /** 28 /**
23 * Abstraction of an Pcep client controller. Serves as a one stop 29 * Abstraction of an Pcep client controller. Serves as a one stop
...@@ -85,20 +91,6 @@ public interface PcepClientController { ...@@ -85,20 +91,6 @@ public interface PcepClientController {
85 void removeNodeListener(PcepNodeListener listener); 91 void removeNodeListener(PcepNodeListener listener);
86 92
87 /** 93 /**
88 - * Register a listener for packet events.
89 - *
90 - * @param listener the listener to notify
91 - */
92 - void addPacketListener(PcepPacketListener listener);
93 -
94 - /**
95 - * Unregister a packet listener.
96 - *
97 - * @param listener the listener to unregister
98 - */
99 - void removePacketListener(PcepPacketListener listener);
100 -
101 - /**
102 * Send a message to a particular pcc client. 94 * Send a message to a particular pcc client.
103 * 95 *
104 * @param pccId the id of the client to send message. 96 * @param pccId the id of the client to send message.
...@@ -118,4 +110,29 @@ public interface PcepClientController { ...@@ -118,4 +110,29 @@ public interface PcepClientController {
118 * Close all connected PCC clients. 110 * Close all connected PCC clients.
119 */ 111 */
120 void closeConnectedClients(); 112 void closeConnectedClients();
113 +
114 + /**
115 + * Create label stack from the given path.
116 + *
117 + * @param path from which label stack is to be computed
118 + * @return the label stack
119 + */
120 + public LabelStack computeLabelStack(Path path);
121 +
122 + /**
123 + * Allocates and downloads local labels for the given LSP.
124 + *
125 + * @param tunnel for which local labels have to be assigned and downloaded
126 + * @return success or failure
127 + */
128 + public boolean allocateLocalLabel(Tunnel tunnel);
129 +
130 + /**
131 + * Creates label stack for ERO object from network resource.
132 + *
133 + * @param labelStack
134 + * @param path (hop list)
135 + * @return list of ERO sub-objects
136 + */
137 + public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path);
121 } 138 }
......
1 COMPILE_DEPS = [ 1 COMPILE_DEPS = [
2 '//lib:CORE_DEPS', 2 '//lib:CORE_DEPS',
3 + '//incubator/api:onos-incubator-api',
3 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', 4 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
4 '//protocols/pcep/api:onos-protocols-pcep-api', 5 '//protocols/pcep/api:onos-protocols-pcep-api',
5 - '//incubator/api:onos-incubator-api', 6 + '//core/store/serializers:onos-core-serializers',
6 '//apps/pcep-api:onos-apps-pcep-api', 7 '//apps/pcep-api:onos-apps-pcep-api',
7 ] 8 ]
8 9
......
...@@ -50,6 +50,11 @@ ...@@ -50,6 +50,11 @@
50 <groupId>org.onosproject</groupId> 50 <groupId>org.onosproject</groupId>
51 <artifactId>onlab-misc</artifactId> 51 <artifactId>onlab-misc</artifactId>
52 </dependency> 52 </dependency>
53 + <dependency>
54 + <groupId>org.onosproject</groupId>
55 + <artifactId>onos-core-serializers</artifactId>
56 + <version>${project.version}</version>
57 + </dependency>
53 </dependencies> 58 </dependencies>
54 59
55 <build> 60 <build>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.pcestore; 16 +package org.onosproject.pcelabelstore;
17 17
18 import com.google.common.base.MoreObjects; 18 import com.google.common.base.MoreObjects;
19 19
...@@ -21,8 +21,8 @@ import java.util.Objects; ...@@ -21,8 +21,8 @@ import java.util.Objects;
21 21
22 import org.onosproject.net.DeviceId; 22 import org.onosproject.net.DeviceId;
23 import org.onosproject.net.PortNumber; 23 import org.onosproject.net.PortNumber;
24 +import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
24 import org.onosproject.incubator.net.resource.label.LabelResourceId; 25 import org.onosproject.incubator.net.resource.label.LabelResourceId;
25 -import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
26 26
27 /** 27 /**
28 * Local node details including IN and OUT labels as well as IN and OUT port details. 28 * Local node details including IN and OUT labels as well as IN and OUT port details.
...@@ -30,13 +30,9 @@ import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; ...@@ -30,13 +30,9 @@ import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
30 public final class DefaultLspLocalLabelInfo implements LspLocalLabelInfo { 30 public final class DefaultLspLocalLabelInfo implements LspLocalLabelInfo {
31 31
32 private final DeviceId deviceId; 32 private final DeviceId deviceId;
33 -
34 private final LabelResourceId inLabelId; 33 private final LabelResourceId inLabelId;
35 -
36 private final LabelResourceId outLabelId; 34 private final LabelResourceId outLabelId;
37 -
38 private final PortNumber inPort; 35 private final PortNumber inPort;
39 -
40 private final PortNumber outPort; 36 private final PortNumber outPort;
41 37
42 /** 38 /**
...@@ -152,15 +148,10 @@ public final class DefaultLspLocalLabelInfo implements LspLocalLabelInfo { ...@@ -152,15 +148,10 @@ public final class DefaultLspLocalLabelInfo implements LspLocalLabelInfo {
152 * Builder. 148 * Builder.
153 */ 149 */
154 public static final class Builder implements LspLocalLabelInfo.Builder { 150 public static final class Builder implements LspLocalLabelInfo.Builder {
155 -
156 private DeviceId deviceId; 151 private DeviceId deviceId;
157 -
158 private LabelResourceId inLabelId; 152 private LabelResourceId inLabelId;
159 -
160 private LabelResourceId outLabelId; 153 private LabelResourceId outLabelId;
161 -
162 private PortNumber inPort; 154 private PortNumber inPort;
163 -
164 private PortNumber outPort; 155 private PortNumber outPort;
165 156
166 /** 157 /**
......
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.pcelabelstore;
17 +
18 +import static com.google.common.base.Preconditions.checkNotNull;
19 +
20 +import java.util.HashMap;
21 +import java.util.HashSet;
22 +import java.util.List;
23 +import java.util.Map;
24 +import java.util.stream.Collectors;
25 +
26 +import org.apache.felix.scr.annotations.Activate;
27 +import org.apache.felix.scr.annotations.Component;
28 +import org.apache.felix.scr.annotations.Deactivate;
29 +import org.apache.felix.scr.annotations.Reference;
30 +import org.apache.felix.scr.annotations.ReferenceCardinality;
31 +import org.apache.felix.scr.annotations.Service;
32 +
33 +import org.onlab.util.KryoNamespace;
34 +import org.onosproject.incubator.net.tunnel.TunnelId;
35 +import org.onosproject.incubator.net.resource.label.LabelResource;
36 +import org.onosproject.incubator.net.resource.label.LabelResourceId;
37 +import org.onosproject.net.DeviceId;
38 +import org.onosproject.net.Link;
39 +import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
40 +import org.onosproject.pcelabelstore.api.PceLabelStore;
41 +import org.onosproject.store.serializers.KryoNamespaces;
42 +import org.onosproject.store.service.ConsistentMap;
43 +import org.onosproject.store.service.Serializer;
44 +import org.onosproject.store.service.StorageService;
45 +
46 +import org.slf4j.Logger;
47 +import org.slf4j.LoggerFactory;
48 +
49 +/**
50 + * Manages the pool of available labels to devices, links and tunnels.
51 + */
52 +@Component(immediate = true)
53 +@Service
54 +public class DistributedPceLabelStore implements PceLabelStore {
55 +
56 + private static final String DEVICE_ID_NULL = "Device ID cannot be null";
57 + private static final String LABEL_RESOURCE_ID_NULL = "Label Resource Id cannot be null";
58 + private static final String LINK_NULL = "LINK cannot be null";
59 + private static final String PCECC_TUNNEL_INFO_NULL = "PCECC Tunnel Info cannot be null";
60 + private static final String TUNNEL_ID_NULL = "Tunnel Id cannot be null";
61 +
62 + private final Logger log = LoggerFactory.getLogger(getClass());
63 +
64 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
65 + protected StorageService storageService;
66 +
67 + // Mapping device with global node label
68 + private ConsistentMap<DeviceId, LabelResourceId> globalNodeLabelMap;
69 +
70 + // Mapping link with adjacency label
71 + private ConsistentMap<Link, LabelResourceId> adjLabelMap;
72 +
73 + // Mapping tunnel id with local labels.
74 + private ConsistentMap<TunnelId, List<LspLocalLabelInfo>> tunnelLabelInfoMap;
75 +
76 + // Locally maintain LSRID to device id mapping for better performance.
77 + private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
78 +
79 + // List of PCC LSR ids whose BGP device information was not available to perform
80 + // label db sync.
81 + private HashSet<DeviceId> pendinglabelDbSyncPccMap = new HashSet<>();
82 +
83 + @Activate
84 + protected void activate() {
85 + globalNodeLabelMap = storageService.<DeviceId, LabelResourceId>consistentMapBuilder()
86 + .withName("onos-pce-globalnodelabelmap")
87 + .withSerializer(Serializer.using(
88 + new KryoNamespace.Builder()
89 + .register(KryoNamespaces.API)
90 + .register(LabelResourceId.class)
91 + .build()))
92 + .build();
93 +
94 + adjLabelMap = storageService.<Link, LabelResourceId>consistentMapBuilder()
95 + .withName("onos-pce-adjlabelmap")
96 + .withSerializer(Serializer.using(
97 + new KryoNamespace.Builder()
98 + .register(KryoNamespaces.API)
99 + .register(Link.class,
100 + LabelResource.class,
101 + LabelResourceId.class)
102 + .build()))
103 + .build();
104 +
105 + tunnelLabelInfoMap = storageService.<TunnelId, List<LspLocalLabelInfo>>consistentMapBuilder()
106 + .withName("onos-pce-tunnellabelinfomap")
107 + .withSerializer(Serializer.using(
108 + new KryoNamespace.Builder()
109 + .register(KryoNamespaces.API)
110 + .register(TunnelId.class,
111 + DefaultLspLocalLabelInfo.class,
112 + LabelResourceId.class,
113 + DeviceId.class)
114 + .build()))
115 + .build();
116 +
117 + log.info("Started");
118 + }
119 +
120 + @Deactivate
121 + protected void deactivate() {
122 + log.info("Stopped");
123 + }
124 +
125 + @Override
126 + public boolean existsGlobalNodeLabel(DeviceId id) {
127 + checkNotNull(id, DEVICE_ID_NULL);
128 + return globalNodeLabelMap.containsKey(id);
129 + }
130 +
131 + @Override
132 + public boolean existsAdjLabel(Link link) {
133 + checkNotNull(link, LINK_NULL);
134 + return adjLabelMap.containsKey(link);
135 + }
136 +
137 + @Override
138 + public boolean existsTunnelInfo(TunnelId tunnelId) {
139 + checkNotNull(tunnelId, TUNNEL_ID_NULL);
140 + return tunnelLabelInfoMap.containsKey(tunnelId);
141 + }
142 +
143 + @Override
144 + public int getGlobalNodeLabelCount() {
145 + return globalNodeLabelMap.size();
146 + }
147 +
148 + @Override
149 + public int getAdjLabelCount() {
150 + return adjLabelMap.size();
151 + }
152 +
153 + @Override
154 + public int getTunnelInfoCount() {
155 + return tunnelLabelInfoMap.size();
156 + }
157 +
158 + @Override
159 + public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
160 + return globalNodeLabelMap.entrySet().stream()
161 + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
162 + }
163 +
164 + @Override
165 + public Map<Link, LabelResourceId> getAdjLabels() {
166 + return adjLabelMap.entrySet().stream()
167 + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
168 + }
169 +
170 + @Override
171 + public Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos() {
172 + return tunnelLabelInfoMap.entrySet().stream()
173 + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
174 + }
175 +
176 + @Override
177 + public LabelResourceId getGlobalNodeLabel(DeviceId id) {
178 + checkNotNull(id, DEVICE_ID_NULL);
179 + return globalNodeLabelMap.get(id) == null ? null : globalNodeLabelMap.get(id).value();
180 + }
181 +
182 + @Override
183 + public LabelResourceId getAdjLabel(Link link) {
184 + checkNotNull(link, LINK_NULL);
185 + return adjLabelMap.get(link) == null ? null : adjLabelMap.get(link).value();
186 + }
187 +
188 + @Override
189 + public List<LspLocalLabelInfo> getTunnelInfo(TunnelId tunnelId) {
190 + checkNotNull(tunnelId, TUNNEL_ID_NULL);
191 + return tunnelLabelInfoMap.get(tunnelId) == null ? null : tunnelLabelInfoMap.get(tunnelId).value();
192 + }
193 +
194 + @Override
195 + public void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId) {
196 + checkNotNull(deviceId, DEVICE_ID_NULL);
197 + checkNotNull(labelId, LABEL_RESOURCE_ID_NULL);
198 +
199 + globalNodeLabelMap.put(deviceId, labelId);
200 + }
201 +
202 + @Override
203 + public void addAdjLabel(Link link, LabelResourceId labelId) {
204 + checkNotNull(link, LINK_NULL);
205 + checkNotNull(labelId, LABEL_RESOURCE_ID_NULL);
206 +
207 + adjLabelMap.put(link, labelId);
208 + }
209 +
210 + @Override
211 + public void addTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
212 + checkNotNull(tunnelId, TUNNEL_ID_NULL);
213 + checkNotNull(lspLocalLabelInfoList, PCECC_TUNNEL_INFO_NULL);
214 +
215 + tunnelLabelInfoMap.put(tunnelId, lspLocalLabelInfoList);
216 + }
217 +
218 + @Override
219 + public boolean removeGlobalNodeLabel(DeviceId id) {
220 + checkNotNull(id, DEVICE_ID_NULL);
221 +
222 + if (globalNodeLabelMap.remove(id) == null) {
223 + log.error("SR-TE node label deletion for device {} has failed.", id.toString());
224 + return false;
225 + }
226 + return true;
227 + }
228 +
229 + @Override
230 + public boolean removeAdjLabel(Link link) {
231 + checkNotNull(link, LINK_NULL);
232 +
233 + if (adjLabelMap.remove(link) == null) {
234 + log.error("Adjacency label deletion for link {} hash failed.", link.toString());
235 + return false;
236 + }
237 + return true;
238 + }
239 +
240 + @Override
241 + public boolean removeTunnelInfo(TunnelId tunnelId) {
242 + checkNotNull(tunnelId, TUNNEL_ID_NULL);
243 +
244 + if (tunnelLabelInfoMap.remove(tunnelId) == null) {
245 + log.error("Tunnel info deletion for tunnel id {} has failed.", tunnelId.toString());
246 + return false;
247 + }
248 + return true;
249 + }
250 +
251 + @Override
252 + public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
253 + checkNotNull(lsrId);
254 + checkNotNull(deviceId);
255 +
256 + lsrIdDeviceIdMap.put(lsrId, deviceId);
257 + return true;
258 + }
259 +
260 + @Override
261 + public boolean removeLsrIdDevice(String lsrId) {
262 + checkNotNull(lsrId);
263 +
264 + lsrIdDeviceIdMap.remove(lsrId);
265 + return true;
266 + }
267 +
268 + @Override
269 + public DeviceId getLsrIdDevice(String lsrId) {
270 + checkNotNull(lsrId);
271 +
272 + return lsrIdDeviceIdMap.get(lsrId);
273 +
274 + }
275 +
276 + @Override
277 + public boolean addPccLsr(DeviceId lsrId) {
278 + checkNotNull(lsrId);
279 + pendinglabelDbSyncPccMap.add(lsrId);
280 + return true;
281 + }
282 +
283 + @Override
284 + public boolean removePccLsr(DeviceId lsrId) {
285 + checkNotNull(lsrId);
286 + pendinglabelDbSyncPccMap.remove(lsrId);
287 + return true;
288 + }
289 +
290 + @Override
291 + public boolean hasPccLsr(DeviceId lsrId) {
292 + checkNotNull(lsrId);
293 + return pendinglabelDbSyncPccMap.contains(lsrId);
294 +
295 + }
296 +}
1 +package org.onosproject.pcelabelstore;
2 +
3 +/**
4 + * Representation of label operation over PCEP.
5 + */
6 +public enum PcepLabelOp {
7 + /**
8 + * Signifies that the label operation is addition.
9 + */
10 + ADD,
11 +
12 + /**
13 + * Signifies that the label operation is modification. This is reserved for future.
14 + */
15 + MODIFY,
16 +
17 + /**
18 + * Signifies that the label operation is deletion.
19 + */
20 + REMOVE
21 +}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.pcestore.api; 16 +package org.onosproject.pcelabelstore.api;
17 17
18 import org.onosproject.net.DeviceId; 18 import org.onosproject.net.DeviceId;
19 import org.onosproject.net.PortNumber; 19 import org.onosproject.net.PortNumber;
......
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.pcelabelstore.api;
17 +
18 +import java.util.List;
19 +
20 +import org.onosproject.incubator.net.resource.label.LabelResourceId;
21 +import org.onosproject.incubator.net.tunnel.TunnelId;
22 +import org.onosproject.net.DeviceId;
23 +import org.onosproject.net.Link;
24 +import java.util.Map;
25 +
26 +/**
27 + * Abstraction of an entity providing pool of available labels to devices, links and tunnels.
28 + */
29 +public interface PceLabelStore {
30 + /**
31 + * Checks whether device id is present in global node label store.
32 + *
33 + * @param id device id
34 + * @return success of failure
35 + */
36 + boolean existsGlobalNodeLabel(DeviceId id);
37 +
38 + /**
39 + * Checks whether link is present in adjacency label store.
40 + *
41 + * @param link link between devices
42 + * @return success of failure
43 + */
44 + boolean existsAdjLabel(Link link);
45 +
46 + /**
47 + * Checks whether tunnel id is present in tunnel info store.
48 + *
49 + * @param tunnelId tunnel id
50 + * @return success of failure
51 + */
52 + boolean existsTunnelInfo(TunnelId tunnelId);
53 +
54 + /**
55 + * Retrieves the node label count.
56 + *
57 + * @return node label count
58 + */
59 + int getGlobalNodeLabelCount();
60 +
61 + /**
62 + * Retrieves the adjacency label count.
63 + *
64 + * @return adjacency label count
65 + */
66 + int getAdjLabelCount();
67 +
68 + /**
69 + * Retrieves the tunnel info count.
70 + *
71 + * @return tunnel info count
72 + */
73 + int getTunnelInfoCount();
74 +
75 + /**
76 + * Retrieves device id and label pairs collection from global node label store.
77 + *
78 + * @return collection of device id and label pairs
79 + */
80 + Map<DeviceId, LabelResourceId> getGlobalNodeLabels();
81 +
82 + /**
83 + * Retrieves link and label pairs collection from adjacency label store.
84 + *
85 + * @return collection of link and label pairs
86 + */
87 + Map<Link, LabelResourceId> getAdjLabels();
88 +
89 + /**
90 + * Retrieves tunnel id and pcecc tunnel info pairs collection from tunnel info store.
91 + *
92 + * @return collection of tunnel id and pcecc tunnel info pairs
93 + */
94 + Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos();
95 +
96 + /**
97 + * Retrieves node label for specified device id.
98 + *
99 + * @param id device id
100 + * @return node label
101 + */
102 + LabelResourceId getGlobalNodeLabel(DeviceId id);
103 +
104 + /**
105 + * Retrieves adjacency label for specified link.
106 + *
107 + * @param link between devices
108 + * @return adjacency label
109 + */
110 + LabelResourceId getAdjLabel(Link link);
111 +
112 + /**
113 + * Retrieves local label info with tunnel consumer id from tunnel info store.
114 + *
115 + * @param tunnelId tunnel id
116 + * @return pcecc tunnel info
117 + */
118 + List<LspLocalLabelInfo> getTunnelInfo(TunnelId tunnelId);
119 +
120 + /**
121 + * Stores node label into global node label store.
122 + *
123 + * @param deviceId device id
124 + * @param labelId node label id
125 + */
126 + void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId);
127 +
128 + /**
129 + * Stores adjacency label into adjacency label store.
130 + *
131 + * @param link link between nodes
132 + * @param labelId link label id
133 + */
134 + void addAdjLabel(Link link, LabelResourceId labelId);
135 +
136 + /**
137 + * Stores local label info with tunnel consumer id into tunnel info store for specified tunnel id.
138 + *
139 + * @param tunnelId tunnel id
140 + * @param lspLocalLabelInfoList local label info
141 + */
142 + void addTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList);
143 +
144 + /**
145 + * Removes device label from global node label store for specified device id.
146 + *
147 + * @param id device id
148 + * @return success or failure
149 + */
150 + boolean removeGlobalNodeLabel(DeviceId id);
151 +
152 + /**
153 + * Removes adjacency label from adjacency label store for specified link information.
154 + *
155 + * @param link between nodes
156 + * @return success or failure
157 + */
158 + boolean removeAdjLabel(Link link);
159 +
160 + /**
161 + * Removes local label info with tunnel consumer id from tunnel info store for specified tunnel id.
162 + *
163 + * @param tunnelId tunnel id
164 + * @return success or failure
165 + */
166 + boolean removeTunnelInfo(TunnelId tunnelId);
167 +
168 + /**
169 + * Adds lsrid to device id mapping.
170 + *
171 + * @param lsrId lsrId of the device
172 + * @param deviceId device id
173 + * @return success or failure
174 + */
175 + boolean addLsrIdDevice(String lsrId, DeviceId deviceId);
176 +
177 + /**
178 + * Removes lsrid to device id mapping.
179 + *
180 + * @param lsrId lsrId of the device
181 + * @return success or failure
182 + */
183 + boolean removeLsrIdDevice(String lsrId);
184 +
185 + /**
186 + * Gets lsrid to device id mapping.
187 + *
188 + * @param lsrId lsrId of the device
189 + * @return device id of the lsrId
190 + */
191 + DeviceId getLsrIdDevice(String lsrId);
192 +
193 + /**
194 + * Adds lsrId of the PCC in form of device id for the PCC for which sync is pending due to non-availability of BGP.
195 + * device.
196 + *
197 + * @param lsrId LSR id of the PCC in form of device id
198 + * @return success or failure
199 + */
200 + public boolean addPccLsr(DeviceId lsrId);
201 +
202 + /**
203 + * Removes lsrId of the PCC in form of device id for the PCC for which pending sync is done.
204 + *
205 + * @param lsrId LSR id of the PCC in form of device id
206 + * @return success or failure
207 + */
208 + public boolean removePccLsr(DeviceId lsrId);
209 +
210 + /**
211 + * Gets lsrId of the PCC in form of device id.
212 + *
213 + * @param lsrId LSR id of the PCC in form of device id
214 + * @return success or failure
215 + */
216 + public boolean hasPccLsr(DeviceId lsrId);
217 +}
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 /** 17 /**
17 - *Provider that uses PCEP controller as a means to send packets. 18 + * PCE store service API.
18 */ 19 */
19 -package org.onosproject.provider.pcep.packet.impl;
...\ No newline at end of file ...\ No newline at end of file
20 +package org.onosproject.pcelabelstore.api;
......
...@@ -13,10 +13,8 @@ ...@@ -13,10 +13,8 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pcep.controller;
17 16
18 -public interface PcepPacketListener { 17 +/**
19 - 18 + * PCE store application.
20 - void sendPacketIn(PccId pccId); 19 + */
21 - 20 +package org.onosproject.pcelabelstore;
22 -}
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.pce.pceservice; 17 +package org.onosproject.pcep.controller.impl;
18 18
19 /** 19 /**
20 * Describes about Label type. 20 * Describes about Label type.
......
...@@ -111,13 +111,13 @@ public class PcepControllerImpl implements PcepController { ...@@ -111,13 +111,13 @@ public class PcepControllerImpl implements PcepController {
111 @Override 111 @Override
112 public Boolean deleteTunnel(String id) { 112 public Boolean deleteTunnel(String id) {
113 // TODO Auto-generated method stub 113 // TODO Auto-generated method stub
114 - return null; 114 + return false;
115 } 115 }
116 116
117 @Override 117 @Override
118 public Boolean updateTunnelBandwidth(String id, long bandwidth) { 118 public Boolean updateTunnelBandwidth(String id, long bandwidth) {
119 // TODO Auto-generated method stub 119 // TODO Auto-generated method stub
120 - return null; 120 + return false;
121 } 121 }
122 122
123 @Override 123 @Override
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.pcestore; 16 +package org.onosproject.pcelabelstore;
17 17
18 import static org.hamcrest.MatcherAssert.assertThat; 18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is; 19 import static org.hamcrest.Matchers.is;
...@@ -24,7 +24,7 @@ import org.junit.Test; ...@@ -24,7 +24,7 @@ import org.junit.Test;
24 import org.onosproject.incubator.net.resource.label.LabelResourceId; 24 import org.onosproject.incubator.net.resource.label.LabelResourceId;
25 import org.onosproject.net.DeviceId; 25 import org.onosproject.net.DeviceId;
26 import org.onosproject.net.PortNumber; 26 import org.onosproject.net.PortNumber;
27 -import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; 27 +import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
28 28
29 /** 29 /**
30 * Unit tests for DefaultLspLocalLabelInfo class. 30 * Unit tests for DefaultLspLocalLabelInfo class.
......
...@@ -13,14 +13,13 @@ ...@@ -13,14 +13,13 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.pceservice; 16 +package org.onosproject.pcelabelstore.label;
17 17
18 import static org.hamcrest.MatcherAssert.assertThat; 18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is; 19 import static org.hamcrest.Matchers.is;
20 import static org.hamcrest.Matchers.notNullValue; 20 import static org.hamcrest.Matchers.notNullValue;
21 import static org.hamcrest.Matchers.nullValue; 21 import static org.hamcrest.Matchers.nullValue;
22 import static org.onosproject.net.Link.Type.DIRECT; 22 import static org.onosproject.net.Link.Type.DIRECT;
23 -
24 import java.util.Iterator; 23 import java.util.Iterator;
25 import java.util.List; 24 import java.util.List;
26 import java.util.LinkedList; 25 import java.util.LinkedList;
...@@ -29,8 +28,6 @@ import org.junit.After; ...@@ -29,8 +28,6 @@ import org.junit.After;
29 import org.junit.Before; 28 import org.junit.Before;
30 import org.junit.Test; 29 import org.junit.Test;
31 import org.onlab.packet.IpAddress; 30 import org.onlab.packet.IpAddress;
32 -import org.onosproject.core.ApplicationId;
33 -import org.onosproject.core.CoreService;
34 import org.onosproject.core.DefaultGroupId; 31 import org.onosproject.core.DefaultGroupId;
35 import org.onosproject.incubator.net.tunnel.Tunnel; 32 import org.onosproject.incubator.net.tunnel.Tunnel;
36 import org.onosproject.incubator.net.tunnel.TunnelEndPoint; 33 import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
...@@ -40,19 +37,24 @@ import org.onosproject.incubator.net.tunnel.TunnelId; ...@@ -40,19 +37,24 @@ import org.onosproject.incubator.net.tunnel.TunnelId;
40 import org.onosproject.incubator.net.tunnel.DefaultTunnel; 37 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
41 import org.onosproject.incubator.net.resource.label.LabelResourceId; 38 import org.onosproject.incubator.net.resource.label.LabelResourceId;
42 import org.onosproject.incubator.net.resource.label.LabelResourceService; 39 import org.onosproject.incubator.net.resource.label.LabelResourceService;
40 +import org.onosproject.net.AnnotationKeys;
41 +import org.onosproject.net.Annotations;
43 import org.onosproject.net.ConnectPoint; 42 import org.onosproject.net.ConnectPoint;
44 import org.onosproject.net.DefaultAnnotations; 43 import org.onosproject.net.DefaultAnnotations;
44 +import org.onosproject.net.DefaultDevice;
45 import org.onosproject.net.DefaultPath; 45 import org.onosproject.net.DefaultPath;
46 +import org.onosproject.net.Device;
46 import org.onosproject.net.DeviceId; 47 import org.onosproject.net.DeviceId;
47 import org.onosproject.net.PortNumber; 48 import org.onosproject.net.PortNumber;
48 -import org.onosproject.net.flowobjective.FlowObjectiveService;
49 import org.onosproject.net.Path; 49 import org.onosproject.net.Path;
50 -import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
51 -import org.onosproject.pce.pcestore.api.PceStore;
52 -import org.onosproject.pce.pcestore.PceccTunnelInfo;
53 import org.onosproject.net.provider.ProviderId; 50 import org.onosproject.net.provider.ProviderId;
54 -import org.onosproject.pce.util.LabelResourceAdapter; 51 +import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
55 -import org.onosproject.pce.util.PceStoreAdapter; 52 +import org.onosproject.pcelabelstore.api.PceLabelStore;
53 +import org.onosproject.pcelabelstore.util.LabelResourceAdapter;
54 +import org.onosproject.pcelabelstore.util.MockDeviceService;
55 +import org.onosproject.pcelabelstore.util.PceLabelStoreAdapter;
56 +import org.onosproject.pcep.controller.impl.BasicPceccHandler;
57 +import org.onosproject.pcep.controller.impl.PcepClientControllerImpl;
56 import org.onosproject.net.DefaultLink; 58 import org.onosproject.net.DefaultLink;
57 import org.onosproject.net.Link; 59 import org.onosproject.net.Link;
58 60
...@@ -63,13 +65,13 @@ public class BasicPceccHandlerTest { ...@@ -63,13 +65,13 @@ public class BasicPceccHandlerTest {
63 65
64 public static final long LOCAL_LABEL_SPACE_MIN = 5122; 66 public static final long LOCAL_LABEL_SPACE_MIN = 5122;
65 public static final long LOCAL_LABEL_SPACE_MAX = 9217; 67 public static final long LOCAL_LABEL_SPACE_MAX = 9217;
68 + private static final String L3 = "L3";
69 + private static final String LSRID = "lsrId";
66 70
67 private BasicPceccHandler pceccHandler; 71 private BasicPceccHandler pceccHandler;
68 protected LabelResourceService labelRsrcService; 72 protected LabelResourceService labelRsrcService;
69 - protected PceStore pceStore; 73 + protected MockDeviceService deviceService;
70 - private FlowObjectiveService flowObjectiveService; 74 + protected PceLabelStore pceStore;
71 - private CoreService coreService;
72 - private ApplicationId appId;
73 private TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423)); 75 private TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
74 private TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421)); 76 private TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
75 private DefaultGroupId groupId = new DefaultGroupId(92034); 77 private DefaultGroupId groupId = new DefaultGroupId(92034);
...@@ -78,7 +80,8 @@ public class BasicPceccHandlerTest { ...@@ -78,7 +80,8 @@ public class BasicPceccHandlerTest {
78 private ProviderId producerName = new ProviderId("producer1", "13"); 80 private ProviderId producerName = new ProviderId("producer1", "13");
79 private Path path; 81 private Path path;
80 private Tunnel tunnel; 82 private Tunnel tunnel;
81 - private PceccTunnelInfo pceccTunnelInfo; 83 + List<LspLocalLabelInfo> lspLocalLabelInfoList;
84 + private Device deviceD1, deviceD2, deviceD3, deviceD4, deviceD5;
82 private DeviceId deviceId1; 85 private DeviceId deviceId1;
83 private DeviceId deviceId2; 86 private DeviceId deviceId2;
84 private DeviceId deviceId3; 87 private DeviceId deviceId3;
...@@ -94,13 +97,14 @@ public class BasicPceccHandlerTest { ...@@ -94,13 +97,14 @@ public class BasicPceccHandlerTest {
94 public void setUp() throws Exception { 97 public void setUp() throws Exception {
95 pceccHandler = BasicPceccHandler.getInstance(); 98 pceccHandler = BasicPceccHandler.getInstance();
96 labelRsrcService = new LabelResourceAdapter(); 99 labelRsrcService = new LabelResourceAdapter();
97 - pceStore = new PceStoreAdapter(); 100 + pceStore = new PceLabelStoreAdapter();
98 - flowObjectiveService = new PceManagerTest.MockFlowObjService(); 101 + deviceService = new MockDeviceService();
99 - coreService = new PceManagerTest.MockCoreService(); 102 + pceccHandler.initialize(labelRsrcService,
100 - appId = coreService.registerApplication("org.onosproject.pce"); 103 + deviceService,
101 - pceccHandler.initialize(labelRsrcService, flowObjectiveService, appId, pceStore); 104 + pceStore,
105 + new PcepClientControllerImpl());
102 106
103 - // Cretae tunnel test 107 + // Create tunnel test
104 // Link 108 // Link
105 ProviderId providerId = new ProviderId("of", "foo"); 109 ProviderId providerId = new ProviderId("of", "foo");
106 deviceId1 = DeviceId.deviceId("of:A"); 110 deviceId1 = DeviceId.deviceId("of:A");
...@@ -115,6 +119,41 @@ public class BasicPceccHandlerTest { ...@@ -115,6 +119,41 @@ public class BasicPceccHandlerTest {
115 port5 = PortNumber.portNumber(5); 119 port5 = PortNumber.portNumber(5);
116 List<Link> linkList = new LinkedList<>(); 120 List<Link> linkList = new LinkedList<>();
117 121
122 + // Making L3 devices
123 + DefaultAnnotations.Builder builderDev1 = DefaultAnnotations.builder();
124 + builderDev1.set(AnnotationKeys.TYPE, L3);
125 + builderDev1.set(LSRID, "1.1.1.1");
126 + deviceD1 = new MockDevice(deviceId1, builderDev1.build());
127 + deviceService.addDevice(deviceD1);
128 +
129 + // Making L3 devices
130 + DefaultAnnotations.Builder builderDev2 = DefaultAnnotations.builder();
131 + builderDev2.set(AnnotationKeys.TYPE, L3);
132 + builderDev2.set(LSRID, "2.2.2.2");
133 + deviceD2 = new MockDevice(deviceId2, builderDev2.build());
134 + deviceService.addDevice(deviceD2);
135 +
136 + // Making L3 devices
137 + DefaultAnnotations.Builder builderDev3 = DefaultAnnotations.builder();
138 + builderDev3.set(AnnotationKeys.TYPE, L3);
139 + builderDev3.set(LSRID, "3.3.3.3");
140 + deviceD3 = new MockDevice(deviceId3, builderDev3.build());
141 + deviceService.addDevice(deviceD3);
142 +
143 + // Making L3 devices
144 + DefaultAnnotations.Builder builderDev4 = DefaultAnnotations.builder();
145 + builderDev4.set(AnnotationKeys.TYPE, L3);
146 + builderDev4.set(LSRID, "4.4.4.4");
147 + deviceD4 = new MockDevice(deviceId4, builderDev4.build());
148 + deviceService.addDevice(deviceD4);
149 +
150 + // Making L3 devices
151 + DefaultAnnotations.Builder builderDev5 = DefaultAnnotations.builder();
152 + builderDev5.set(AnnotationKeys.TYPE, L3);
153 + builderDev5.set(LSRID, "5.5.5.5");
154 + deviceD5 = new MockDevice(deviceId5, builderDev5.build());
155 + deviceService.addDevice(deviceD5);
156 +
118 Link l1 = DefaultLink.builder() 157 Link l1 = DefaultLink.builder()
119 .providerId(providerId) 158 .providerId(providerId)
120 .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build()) 159 .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
...@@ -163,7 +202,6 @@ public class BasicPceccHandlerTest { ...@@ -163,7 +202,6 @@ public class BasicPceccHandlerTest {
163 202
164 @After 203 @After
165 public void tearDown() throws Exception { 204 public void tearDown() throws Exception {
166 - PceManagerTest.flowsDownloaded = 0;
167 } 205 }
168 206
169 /** 207 /**
...@@ -179,7 +217,6 @@ public class BasicPceccHandlerTest { ...@@ -179,7 +217,6 @@ public class BasicPceccHandlerTest {
179 */ 217 */
180 @Test 218 @Test
181 public void testAllocateLabel() { 219 public void testAllocateLabel() {
182 - List<LspLocalLabelInfo> lspLocalLabelInfoList;
183 Iterator<LspLocalLabelInfo> iterator; 220 Iterator<LspLocalLabelInfo> iterator;
184 LspLocalLabelInfo lspLocalLabelInfo; 221 LspLocalLabelInfo lspLocalLabelInfo;
185 DeviceId deviceId; 222 DeviceId deviceId;
...@@ -192,8 +229,7 @@ public class BasicPceccHandlerTest { ...@@ -192,8 +229,7 @@ public class BasicPceccHandlerTest {
192 assertThat(pceccHandler.allocateLabel(tunnel), is(true)); 229 assertThat(pceccHandler.allocateLabel(tunnel), is(true));
193 230
194 // Check list of devices with IN and OUT labels whether stored properly in store 231 // Check list of devices with IN and OUT labels whether stored properly in store
195 - pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); 232 + lspLocalLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
196 - lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList();
197 iterator = lspLocalLabelInfoList.iterator(); 233 iterator = lspLocalLabelInfoList.iterator();
198 234
199 // Retrieve values and check device5 235 // Retrieve values and check device5
...@@ -281,7 +317,13 @@ public class BasicPceccHandlerTest { ...@@ -281,7 +317,13 @@ public class BasicPceccHandlerTest {
281 pceccHandler.releaseLabel(tunnel); 317 pceccHandler.releaseLabel(tunnel);
282 318
283 // Retrieve from store. Store should not contain this tunnel info. 319 // Retrieve from store. Store should not contain this tunnel info.
284 - pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); 320 + lspLocalLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
285 - assertThat(pceccTunnelInfo, is(nullValue())); 321 + assertThat(lspLocalLabelInfoList, is(nullValue()));
322 + }
323 +
324 + private class MockDevice extends DefaultDevice {
325 + MockDevice(DeviceId id, Annotations annotations) {
326 + super(null, id, null, null, null, null, null, null, annotations);
327 + }
286 } 328 }
287 } 329 }
......
1 +/*
2 + * Copyright 2015-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.pcelabelstore.util;
17 +
18 +import java.util.Collection;
19 +import java.util.Map;
20 +import java.util.Set;
21 +import java.util.concurrent.Executor;
22 +import java.util.function.BiFunction;
23 +import java.util.function.Function;
24 +import java.util.function.Predicate;
25 +
26 +import org.onosproject.store.service.ConsistentMap;
27 +import org.onosproject.store.service.DistributedPrimitive;
28 +import org.onosproject.store.service.MapEventListener;
29 +import org.onosproject.store.service.Versioned;
30 +
31 +/**
32 + * Testing adapter for the consistent map.
33 + */
34 +public class ConsistentMapAdapter<K, V> implements ConsistentMap<K, V> {
35 +
36 + @Override
37 + public String name() {
38 + return null;
39 + }
40 +
41 + @Override
42 + public DistributedPrimitive.Type primitiveType() {
43 + return DistributedPrimitive.Type.CONSISTENT_MAP;
44 + }
45 +
46 + @Override
47 + public int size() {
48 + return 0;
49 + }
50 +
51 + @Override
52 + public boolean isEmpty() {
53 + return false;
54 + }
55 +
56 + @Override
57 + public boolean containsKey(K key) {
58 + return false;
59 + }
60 +
61 + @Override
62 + public boolean containsValue(V value) {
63 + return false;
64 + }
65 +
66 + @Override
67 + public Versioned<V> get(K key) {
68 + return null;
69 + }
70 +
71 + @Override
72 + public Versioned<V> computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
73 + return null;
74 + }
75 +
76 + @Override
77 + public Versioned<V> compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
78 + return null;
79 + }
80 +
81 + @Override
82 + public Versioned<V> computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
83 + return null;
84 + }
85 +
86 + @Override
87 + public Versioned<V> computeIf(K key, Predicate<? super V> condition,
88 + BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
89 + return null;
90 + }
91 +
92 + @Override
93 + public Versioned<V> put(K key, V value) {
94 + return null;
95 + }
96 +
97 + @Override
98 + public Versioned<V> putAndGet(K key, V value) {
99 + return null;
100 + }
101 +
102 + @Override
103 + public Versioned<V> remove(K key) {
104 + return null;
105 + }
106 +
107 + @Override
108 + public void clear() {
109 +
110 + }
111 +
112 + @Override
113 + public Set<K> keySet() {
114 + return null;
115 + }
116 +
117 + @Override
118 + public Collection<Versioned<V>> values() {
119 + return null;
120 + }
121 +
122 + @Override
123 + public Set<Map.Entry<K, Versioned<V>>> entrySet() {
124 + return null;
125 + }
126 +
127 + @Override
128 + public Versioned<V> putIfAbsent(K key, V value) {
129 + return null;
130 + }
131 +
132 + @Override
133 + public boolean remove(K key, V value) {
134 + return false;
135 + }
136 +
137 + @Override
138 + public boolean remove(K key, long version) {
139 + return false;
140 + }
141 +
142 + @Override
143 + public Versioned replace(K key, V value) {
144 + return null;
145 + }
146 +
147 + @Override
148 + public boolean replace(K key, V oldValue, V newValue) {
149 + return false;
150 + }
151 +
152 + @Override
153 + public boolean replace(K key, long oldVersion, V newValue) {
154 + return false;
155 + }
156 +
157 + @Override
158 + public void addListener(MapEventListener<K, V> listener, Executor executor) {
159 +
160 + }
161 +
162 + @Override
163 + public void removeListener(MapEventListener<K, V> listener) {
164 +
165 + }
166 +
167 + @Override
168 + public Map<K, V> asJavaMap() {
169 + return null;
170 + }
171 +}
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 +package org.onosproject.pcelabelstore.util;
18 +
19 +import java.util.Collection;
20 +import java.util.Set;
21 +import java.util.concurrent.CompletableFuture;
22 +
23 +import org.onosproject.store.service.AsyncDistributedSet;
24 +import org.onosproject.store.service.SetEventListener;
25 +
26 +/**
27 + * Testing adapter for the distributed set.
28 + */
29 +public class DistributedSetAdapter<E> implements AsyncDistributedSet<E> {
30 + @Override
31 + public CompletableFuture<Void> addListener(SetEventListener<E> listener) {
32 + return null;
33 + }
34 +
35 + @Override
36 + public CompletableFuture<Void> removeListener(SetEventListener<E> listener) {
37 + return null;
38 + }
39 +
40 + @Override
41 + public CompletableFuture<Boolean> add(E element) {
42 + return null;
43 + }
44 +
45 + @Override
46 + public CompletableFuture<Boolean> remove(E element) {
47 + return null;
48 + }
49 +
50 + @Override
51 + public CompletableFuture<Integer> size() {
52 + return null;
53 + }
54 +
55 + @Override
56 + public CompletableFuture<Boolean> isEmpty() {
57 + return null;
58 + }
59 +
60 + @Override
61 + public CompletableFuture<Void> clear() {
62 + return null;
63 + }
64 +
65 + @Override
66 + public CompletableFuture<Boolean> contains(E element) {
67 + return null;
68 + }
69 +
70 + @Override
71 + public CompletableFuture<Boolean> addAll(Collection<? extends E> c) {
72 + return null;
73 + }
74 +
75 + @Override
76 + public CompletableFuture<Boolean> containsAll(Collection<? extends E> c) {
77 + return null;
78 + }
79 +
80 + @Override
81 + public CompletableFuture<Boolean> retainAll(Collection<? extends E> c) {
82 + return null;
83 + }
84 +
85 + @Override
86 + public CompletableFuture<Boolean> removeAll(Collection<? extends E> c) {
87 + return null;
88 + }
89 +
90 + @Override
91 + public CompletableFuture<? extends Set<E>> getAsImmutableSet() {
92 + return null;
93 + }
94 +
95 + @Override
96 + public String name() {
97 + return null;
98 + }
99 +}
1 +/*
2 + * Copyright 2015-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.pcelabelstore.util;
17 +
18 +import java.util.Collection;
19 +import java.util.Map;
20 +import java.util.Set;
21 +import java.util.concurrent.CompletableFuture;
22 +import java.util.function.BiFunction;
23 +
24 +import org.onosproject.store.service.EventuallyConsistentMap;
25 +import org.onosproject.store.service.EventuallyConsistentMapListener;
26 +
27 +/**
28 + * Testing adapter for EventuallyConsistentMap.
29 + */
30 +public class EventuallyConsistentMapAdapter<K, V> implements EventuallyConsistentMap<K, V> {
31 +
32 + @Override
33 + public String name() {
34 + return null;
35 + }
36 +
37 + @Override
38 + public Type primitiveType() {
39 + return Type.EVENTUALLY_CONSISTENT_MAP;
40 + }
41 +
42 + @Override
43 + public int size() {
44 + return 0;
45 + }
46 +
47 + @Override
48 + public boolean isEmpty() {
49 + return false;
50 + }
51 +
52 + @Override
53 + public boolean containsKey(K key) {
54 + return false;
55 + }
56 +
57 + @Override
58 + public boolean containsValue(V value) {
59 + return false;
60 + }
61 +
62 + @Override
63 + public V get(K key) {
64 + return null;
65 + }
66 +
67 + @Override
68 + public void put(K key, V value) {
69 +
70 + }
71 +
72 + @Override
73 + public V remove(K key) {
74 + return null;
75 + }
76 +
77 + @Override
78 + public void remove(K key, V value) {
79 +
80 + }
81 +
82 + @Override
83 + public V compute(K key, BiFunction<K, V, V> recomputeFunction) {
84 + return null;
85 + }
86 +
87 + @Override
88 + public void putAll(Map<? extends K, ? extends V> m) {
89 +
90 + }
91 +
92 + @Override
93 + public void clear() {
94 +
95 + }
96 +
97 + @Override
98 + public Set<K> keySet() {
99 + return null;
100 + }
101 +
102 + @Override
103 + public Collection<V> values() {
104 + return null;
105 + }
106 +
107 + @Override
108 + public Set<Map.Entry<K, V>> entrySet() {
109 + return null;
110 + }
111 +
112 + @Override
113 + public void addListener(EventuallyConsistentMapListener<K, V> listener) {
114 +
115 + }
116 +
117 + @Override
118 + public void removeListener(EventuallyConsistentMapListener<K, V> listener) {
119 +
120 + }
121 +
122 + @Override
123 + public CompletableFuture<Void> destroy() {
124 + return CompletableFuture.completedFuture(null);
125 + }
126 +}
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.pcelabelstore.util;
17 +
18 +import static com.google.common.base.Preconditions.checkNotNull;
19 +
20 +import java.util.Collection;
21 +import java.util.LinkedList;
22 +import java.util.Random;
23 +import java.util.Set;
24 +
25 +import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
26 +import org.onosproject.incubator.net.resource.label.LabelResource;
27 +import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
28 +import org.onosproject.incubator.net.resource.label.LabelResourceDelegate;
29 +import org.onosproject.incubator.net.resource.label.LabelResourceEvent;
30 +import org.onosproject.incubator.net.resource.label.LabelResourceId;
31 +import org.onosproject.incubator.net.resource.label.LabelResourceListener;
32 +import org.onosproject.incubator.net.resource.label.LabelResourcePool;
33 +import org.onosproject.incubator.net.resource.label.LabelResourceProvider;
34 +import org.onosproject.incubator.net.resource.label.LabelResourceProviderRegistry;
35 +import org.onosproject.incubator.net.resource.label.LabelResourceProviderService;
36 +import org.onosproject.incubator.net.resource.label.LabelResourceService;
37 +import org.onosproject.net.Device;
38 +import org.onosproject.net.DeviceId;
39 +import org.onosproject.net.device.DeviceEvent;
40 +import org.onosproject.net.device.DeviceEvent.Type;
41 +import org.onosproject.net.device.DeviceListener;
42 +import org.onosproject.net.provider.AbstractListenerProviderRegistry;
43 +import org.onosproject.net.provider.AbstractProviderService;
44 +
45 +import com.google.common.collect.Multimap;
46 +
47 +/**
48 + * Provides test implementation of class LabelResourceService.
49 + */
50 +public class LabelResourceAdapter
51 + extends AbstractListenerProviderRegistry<LabelResourceEvent, LabelResourceListener,
52 + LabelResourceProvider, LabelResourceProviderService>
53 + implements LabelResourceService, LabelResourceAdminService, LabelResourceProviderRegistry {
54 + public static final long GLOBAL_LABEL_SPACE_MIN = 4097;
55 + public static final long GLOBAL_LABEL_SPACE_MAX = 5121;
56 + public static final long LOCAL_LABEL_SPACE_MIN = 5122;
57 + public static final long LOCAL_LABEL_SPACE_MAX = 9217;
58 +
59 + private Random random = new Random();
60 +
61 + @Override
62 + public boolean createDevicePool(DeviceId deviceId,
63 + LabelResourceId beginLabel,
64 + LabelResourceId endLabel) {
65 + return true;
66 + }
67 +
68 + @Override
69 + public boolean createGlobalPool(LabelResourceId beginLabel,
70 + LabelResourceId endLabel) {
71 + return true;
72 + }
73 +
74 + @Override
75 + public boolean destroyDevicePool(DeviceId deviceId) {
76 + return true;
77 + }
78 +
79 + @Override
80 + public boolean destroyGlobalPool() {
81 + return true;
82 + }
83 +
84 + public long getLabelId(long min, long max) {
85 + return random.nextInt((int) max - (int) min + 1) + (int) min;
86 + }
87 +
88 + @Override
89 + public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
90 + long applyNum) {
91 + Collection<LabelResource> labelList = new LinkedList<>();
92 + LabelResource label = new DefaultLabelResource(deviceId,
93 + LabelResourceId.labelResourceId(
94 + getLabelId(LOCAL_LABEL_SPACE_MIN, LOCAL_LABEL_SPACE_MAX)));
95 + labelList.add(label);
96 + return labelList;
97 + }
98 +
99 + @Override
100 + public Collection<LabelResource> applyFromGlobalPool(long applyNum) {
101 + Collection<LabelResource> labelList = new LinkedList<>();
102 + LabelResource label = new DefaultLabelResource(DeviceId.deviceId("foo"),
103 + LabelResourceId.labelResourceId(
104 + getLabelId(GLOBAL_LABEL_SPACE_MIN, GLOBAL_LABEL_SPACE_MAX)));
105 + labelList.add(label);
106 + return labelList;
107 + }
108 +
109 + @Override
110 + public boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release) {
111 + return true;
112 + }
113 +
114 + @Override
115 + public boolean releaseToGlobalPool(Set<LabelResourceId> release) {
116 + return true;
117 + }
118 +
119 + @Override
120 + public boolean isDevicePoolFull(DeviceId deviceId) {
121 + return false;
122 + }
123 +
124 + @Override
125 + public boolean isGlobalPoolFull() {
126 + return false;
127 + }
128 +
129 + @Override
130 + public long getFreeNumOfDevicePool(DeviceId deviceId) {
131 + return 4;
132 + }
133 +
134 + @Override
135 + public long getFreeNumOfGlobalPool() {
136 + return 4;
137 + }
138 +
139 + @Override
140 + public LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId) {
141 + return null;
142 + }
143 +
144 + @Override
145 + public LabelResourcePool getGlobalLabelResourcePool() {
146 + return null;
147 + }
148 +
149 + private class InternalLabelResourceDelegate implements LabelResourceDelegate {
150 + @Override
151 + public void notify(LabelResourceEvent event) {
152 + post(event);
153 + }
154 +
155 + }
156 +
157 + private class InternalDeviceListener implements DeviceListener {
158 + @Override
159 + public void event(DeviceEvent event) {
160 + Device device = event.subject();
161 + if (Type.DEVICE_REMOVED.equals(event.type())) {
162 + destroyDevicePool(device.id());
163 + }
164 + }
165 + }
166 +
167 + private class InternalLabelResourceProviderService
168 + extends AbstractProviderService<LabelResourceProvider>
169 + implements LabelResourceProviderService {
170 +
171 + protected InternalLabelResourceProviderService(LabelResourceProvider provider) {
172 + super(provider);
173 + }
174 +
175 + @Override
176 + public void deviceLabelResourcePoolDetected(DeviceId deviceId,
177 + LabelResourceId beginLabel,
178 + LabelResourceId endLabel) {
179 + checkNotNull(deviceId, "deviceId is not null");
180 + checkNotNull(beginLabel, "beginLabel is not null");
181 + checkNotNull(endLabel, "endLabel is not null");
182 + createDevicePool(deviceId, beginLabel, endLabel);
183 + }
184 +
185 + @Override
186 + public void deviceLabelResourcePoolDestroyed(DeviceId deviceId) {
187 + checkNotNull(deviceId, "deviceId is not null");
188 + destroyDevicePool(deviceId);
189 + }
190 +
191 + }
192 +
193 + @Override
194 + protected LabelResourceProviderService createProviderService(LabelResourceProvider provider) {
195 + return null;
196 + }
197 +}
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.pcelabelstore.util;
17 +
18 +import java.util.LinkedList;
19 +import java.util.List;
20 +
21 +import org.onosproject.net.device.DeviceListener;
22 +import org.onosproject.net.device.PortStatistics;
23 +import org.onosproject.net.Device;
24 +import org.onosproject.net.Device.Type;
25 +import org.onosproject.net.DeviceId;
26 +import org.onosproject.net.MastershipRole;
27 +import org.onosproject.net.Port;
28 +import org.onosproject.net.PortNumber;
29 +import org.onosproject.net.device.DeviceService;
30 +
31 +/**
32 + * Test fixture for the device service.
33 + */
34 +public class MockDeviceService implements DeviceService {
35 + private List<Device> devices = new LinkedList<>();
36 + private DeviceListener listener;
37 +
38 + /**
39 + * Adds a new device.
40 + *
41 + * @param dev device to be added
42 + */
43 + public void addDevice(Device dev) {
44 + devices.add(dev);
45 + }
46 +
47 + /**
48 + * Removes the specified device.
49 + *
50 + * @param dev device to be removed
51 + */
52 + public void removeDevice(Device dev) {
53 + devices.remove(dev);
54 + }
55 +
56 + @Override
57 + public Device getDevice(DeviceId deviceId) {
58 + for (Device dev : devices) {
59 + if (dev.id().equals(deviceId)) {
60 + return dev;
61 + }
62 + }
63 + return null;
64 + }
65 +
66 + @Override
67 + public Iterable<Device> getAvailableDevices() {
68 + return devices;
69 + }
70 +
71 + @Override
72 + public void addListener(DeviceListener listener) {
73 + this.listener = listener;
74 + }
75 +
76 + /**
77 + * Get the listener.
78 + */
79 + public DeviceListener getListener() {
80 + return listener;
81 + }
82 +
83 + @Override
84 + public void removeListener(DeviceListener listener) {
85 + // TODO Auto-generated method stub
86 +
87 + }
88 +
89 + @Override
90 + public int getDeviceCount() {
91 + // TODO Auto-generated method stub
92 + return 0;
93 + }
94 +
95 + @Override
96 + public Iterable<Device> getDevices() {
97 + // TODO Auto-generated method stub
98 + return null;
99 + }
100 +
101 + @Override
102 + public Iterable<Device> getDevices(Type type) {
103 + // TODO Auto-generated method stub
104 + return null;
105 + }
106 +
107 + @Override
108 + public Iterable<Device> getAvailableDevices(Type type) {
109 + // TODO Auto-generated method stub
110 + return null;
111 + }
112 +
113 + @Override
114 + public MastershipRole getRole(DeviceId deviceId) {
115 + // TODO Auto-generated method stub
116 + return null;
117 + }
118 +
119 + @Override
120 + public List<Port> getPorts(DeviceId deviceId) {
121 + // TODO Auto-generated method stub
122 + return null;
123 + }
124 +
125 + @Override
126 + public List<PortStatistics> getPortStatistics(DeviceId deviceId) {
127 + // TODO Auto-generated method stub
128 + return null;
129 + }
130 +
131 + @Override
132 + public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
133 + // TODO Auto-generated method stub
134 + return null;
135 + }
136 +
137 + @Override
138 + public Port getPort(DeviceId deviceId, PortNumber portNumber) {
139 + // TODO Auto-generated method stub
140 + return null;
141 + }
142 +
143 + @Override
144 + public boolean isAvailable(DeviceId deviceId) {
145 + // TODO Auto-generated method stub
146 + return false;
147 + }
148 +}
1 +package org.onosproject.pcelabelstore.util;
2 +
3 +import java.util.HashMap;
4 +import java.util.Map;
5 +import java.util.Set;
6 +
7 +import org.onosproject.net.DeviceId;
8 +import org.onosproject.net.config.Config;
9 +import org.onosproject.net.config.ConfigApplyDelegate;
10 +import org.onosproject.net.config.ConfigFactory;
11 +import org.onosproject.net.config.NetworkConfigListener;
12 +import org.onosproject.net.config.NetworkConfigRegistry;
13 +import org.onosproject.net.config.NetworkConfigService;
14 +import org.onosproject.net.config.SubjectFactory;
15 +import org.onosproject.pcep.api.DeviceCapability;
16 +
17 +import com.fasterxml.jackson.databind.JsonNode;
18 +import com.fasterxml.jackson.databind.ObjectMapper;
19 +import com.fasterxml.jackson.databind.node.JsonNodeFactory;
20 +import com.fasterxml.jackson.databind.node.ObjectNode;
21 +
22 +/* Mock test for network config registry. */
23 +public class MockNetConfigRegistryAdapter implements NetworkConfigService, NetworkConfigRegistry {
24 + private ConfigFactory cfgFactory;
25 + private Map<DeviceId, DeviceCapability> classConfig = new HashMap<>();
26 +
27 + @Override
28 + public void registerConfigFactory(ConfigFactory configFactory) {
29 + cfgFactory = configFactory;
30 + }
31 +
32 + @Override
33 + public void unregisterConfigFactory(ConfigFactory configFactory) {
34 + cfgFactory = null;
35 + }
36 +
37 + @Override
38 + public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
39 + if (configClass == DeviceCapability.class) {
40 + DeviceCapability devCap = new DeviceCapability();
41 + classConfig.put((DeviceId) subject, devCap);
42 +
43 + JsonNode node = new ObjectNode(new MockJsonNode());
44 + ObjectMapper mapper = new ObjectMapper();
45 + ConfigApplyDelegate delegate = new InternalApplyDelegate();
46 + devCap.init((DeviceId) subject, null, node, mapper, delegate);
47 + return (C) devCap;
48 + }
49 +
50 + return null;
51 + }
52 +
53 + @Override
54 + public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) {
55 + classConfig.remove(subject);
56 + }
57 +
58 + @Override
59 + public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
60 + if (configClass == DeviceCapability.class) {
61 + return (C) classConfig.get(subject);
62 + }
63 + return null;
64 + }
65 +
66 + private class MockJsonNode extends JsonNodeFactory {
67 + }
68 +
69 + // Auxiliary delegate to receive notifications about changes applied to
70 + // the network configuration - by the apps.
71 + private class InternalApplyDelegate implements ConfigApplyDelegate {
72 + @Override
73 + public void onApply(Config config) {
74 + //configs.put(config.subject(), config.node());
75 + }
76 + }
77 +
78 + @Override
79 + public void addListener(NetworkConfigListener listener) {
80 + // TODO Auto-generated method stub
81 +
82 + }
83 +
84 + @Override
85 + public void removeListener(NetworkConfigListener listener) {
86 + // TODO Auto-generated method stub
87 +
88 + }
89 +
90 + @Override
91 + public Set<ConfigFactory> getConfigFactories() {
92 + // TODO Auto-generated method stub
93 + return null;
94 + }
95 +
96 + @Override
97 + public <S, C extends Config<S>> Set<ConfigFactory<S, C>> getConfigFactories(Class<S> subjectClass) {
98 + // TODO Auto-generated method stub
99 + return null;
100 + }
101 +
102 + @Override
103 + public <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass) {
104 + // TODO Auto-generated method stub
105 + return null;
106 + }
107 +
108 + @Override
109 + public Set<Class> getSubjectClasses() {
110 + // TODO Auto-generated method stub
111 + return null;
112 + }
113 +
114 + @Override
115 + public SubjectFactory getSubjectFactory(String subjectClassKey) {
116 + // TODO Auto-generated method stub
117 + return null;
118 + }
119 +
120 + @Override
121 + public SubjectFactory getSubjectFactory(Class subjectClass) {
122 + // TODO Auto-generated method stub
123 + return null;
124 + }
125 +
126 + @Override
127 + public Class<? extends Config> getConfigClass(String subjectClassKey, String configKey) {
128 + // TODO Auto-generated method stub
129 + return null;
130 + }
131 +
132 + @Override
133 + public <S> Set<S> getSubjects(Class<S> subjectClass) {
134 + // TODO Auto-generated method stub
135 + return null;
136 + }
137 +
138 + @Override
139 + public <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass) {
140 + // TODO Auto-generated method stub
141 + return null;
142 + }
143 +
144 + @Override
145 + public <S> Set<? extends Config<S>> getConfigs(S subject) {
146 + // TODO Auto-generated method stub
147 + return null;
148 + }
149 +
150 + @Override
151 + public <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass, JsonNode json) {
152 + // TODO Auto-generated method stub
153 + return null;
154 + }
155 +
156 + @Override
157 + public <S, C extends Config<S>> C applyConfig(String subjectClassKey, S subject, String configKey, JsonNode json) {
158 + // TODO Auto-generated method stub
159 + return null;
160 + }
161 +
162 + @Override
163 + public <S> void removeConfig(String subjectClassKey, S subject, String configKey) {
164 + // TODO Auto-generated method stub
165 +
166 + }
167 +
168 + @Override
169 + public <S> void removeConfig(S subject) {
170 + // TODO Auto-generated method stub
171 +
172 + }
173 +
174 + @Override
175 + public <S> void removeConfig() {
176 + // TODO Auto-generated method stub
177 +
178 + }
179 +}
1 +package org.onosproject.pcelabelstore.util;
2 +
3 +import java.util.Collection;
4 +import java.util.HashMap;
5 +import java.util.LinkedList;
6 +import java.util.Map;
7 +
8 +import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
9 +import org.onosproject.incubator.net.tunnel.LabelStack;
10 +import org.onosproject.incubator.net.tunnel.Tunnel;
11 +import org.onosproject.net.Path;
12 +import org.onosproject.pcep.controller.PccId;
13 +import org.onosproject.pcep.controller.PcepClient;
14 +import org.onosproject.pcep.controller.PcepClientController;
15 +import org.onosproject.pcep.controller.PcepClientListener;
16 +import org.onosproject.pcep.controller.PcepEventListener;
17 +import org.onosproject.pcep.controller.PcepNodeListener;
18 +import org.onosproject.pcepio.protocol.PcepMessage;
19 +import org.onosproject.pcepio.types.PcepValueType;
20 +
21 +public class MockPcepClientController implements PcepClientController {
22 +
23 + Map<PccId, PcepClient> clientMap = new HashMap<>();
24 +
25 + @Override
26 + public Collection<PcepClient> getClients() {
27 + // TODO Auto-generated method stub
28 + return null;
29 + }
30 +
31 + public void addClient(PccId pccId, PcepClient pc) {
32 + clientMap.put(pccId, pc);
33 + return;
34 + }
35 +
36 + @Override
37 + public PcepClient getClient(PccId pccId) {
38 + return clientMap.get(pccId);
39 + }
40 +
41 + @Override
42 + public void addListener(PcepClientListener listener) {
43 + // TODO Auto-generated method stub
44 +
45 + }
46 +
47 + @Override
48 + public void removeListener(PcepClientListener listener) {
49 + // TODO Auto-generated method stub
50 +
51 + }
52 +
53 + @Override
54 + public void addEventListener(PcepEventListener listener) {
55 + // TODO Auto-generated method stub
56 +
57 + }
58 +
59 + @Override
60 + public void removeEventListener(PcepEventListener listener) {
61 + // TODO Auto-generated method stub
62 +
63 + }
64 +
65 + @Override
66 + public void addNodeListener(PcepNodeListener listener) {
67 + // TODO Auto-generated method stub
68 +
69 + }
70 +
71 + @Override
72 + public void removeNodeListener(PcepNodeListener listener) {
73 + // TODO Auto-generated method stub
74 +
75 + }
76 +
77 + @Override
78 + public void writeMessage(PccId pccId, PcepMessage msg) {
79 + // TODO Auto-generated method stub
80 +
81 + }
82 +
83 + @Override
84 + public void processClientMessage(PccId pccId, PcepMessage msg) {
85 + // TODO Auto-generated method stub
86 +
87 + }
88 +
89 + @Override
90 + public void closeConnectedClients() {
91 + // TODO Auto-generated method stub
92 +
93 + }
94 +
95 + @Override
96 + public LabelStack computeLabelStack(Path path) {
97 + // TODO Auto-generated method stub
98 + return null;
99 + }
100 +
101 + @Override
102 + public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
103 + // TODO Auto-generated method stub
104 + return null;
105 + }
106 +
107 + @Override
108 + public boolean allocateLocalLabel(Tunnel tunnel) {
109 + // TODO Auto-generated method stub
110 + return false;
111 + }
112 +
113 +}
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.pcelabelstore.util;
17 +
18 +import java.util.concurrent.ConcurrentHashMap;
19 +import java.util.concurrent.ConcurrentMap;
20 +
21 +import java.util.HashMap;
22 +import java.util.List;
23 +import java.util.Map;
24 +import java.util.stream.Collectors;
25 +
26 +import org.onosproject.incubator.net.resource.label.LabelResourceId;
27 +import org.onosproject.incubator.net.tunnel.TunnelId;
28 +import org.onosproject.net.DeviceId;
29 +import org.onosproject.net.Link;
30 +import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
31 +import org.onosproject.pcelabelstore.api.PceLabelStore;
32 +
33 +/**
34 + * Provides test implementation of PceStore.
35 + */
36 +public class PceLabelStoreAdapter implements PceLabelStore {
37 +
38 + // Mapping device with global node label
39 + private ConcurrentMap<DeviceId, LabelResourceId> globalNodeLabelMap = new ConcurrentHashMap<>();
40 +
41 + // Mapping link with adjacency label
42 + private ConcurrentMap<Link, LabelResourceId> adjLabelMap = new ConcurrentHashMap<>();
43 +
44 + // Mapping tunnel with device local info with tunnel consumer id
45 + private ConcurrentMap<TunnelId, List<LspLocalLabelInfo>> tunnelInfoMap = new ConcurrentHashMap<>();
46 +
47 +
48 + // Locally maintain LSRID to device id mapping for better performance.
49 + private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
50 +
51 + @Override
52 + public boolean existsGlobalNodeLabel(DeviceId id) {
53 + return globalNodeLabelMap.containsKey(id);
54 + }
55 +
56 + @Override
57 + public boolean existsAdjLabel(Link link) {
58 + return adjLabelMap.containsKey(link);
59 + }
60 +
61 + @Override
62 + public boolean existsTunnelInfo(TunnelId tunnelId) {
63 + return tunnelInfoMap.containsKey(tunnelId);
64 + }
65 +
66 + @Override
67 + public int getGlobalNodeLabelCount() {
68 + return globalNodeLabelMap.size();
69 + }
70 +
71 + @Override
72 + public int getAdjLabelCount() {
73 + return adjLabelMap.size();
74 + }
75 +
76 + @Override
77 + public int getTunnelInfoCount() {
78 + return tunnelInfoMap.size();
79 + }
80 +
81 + @Override
82 + public boolean removeTunnelInfo(TunnelId tunnelId) {
83 + tunnelInfoMap.remove(tunnelId);
84 + if (tunnelInfoMap.containsKey(tunnelId)) {
85 + return false;
86 + }
87 + return true;
88 + }
89 +
90 + @Override
91 + public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
92 + return globalNodeLabelMap.entrySet().stream()
93 + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
94 + }
95 +
96 + @Override
97 + public Map<Link, LabelResourceId> getAdjLabels() {
98 + return adjLabelMap.entrySet().stream()
99 + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
100 + }
101 +
102 + @Override
103 + public LabelResourceId getGlobalNodeLabel(DeviceId id) {
104 + return globalNodeLabelMap.get(id);
105 + }
106 +
107 + @Override
108 + public LabelResourceId getAdjLabel(Link link) {
109 + return adjLabelMap.get(link);
110 + }
111 +
112 + @Override
113 + public List<LspLocalLabelInfo> getTunnelInfo(TunnelId tunnelId) {
114 + return tunnelInfoMap.get(tunnelId);
115 + }
116 +
117 + @Override
118 + public void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId) {
119 + globalNodeLabelMap.put(deviceId, labelId);
120 + }
121 +
122 + @Override
123 + public void addAdjLabel(Link link, LabelResourceId labelId) {
124 + adjLabelMap.put(link, labelId);
125 + }
126 +
127 + @Override
128 + public void addTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
129 + tunnelInfoMap.put(tunnelId, lspLocalLabelInfoList);
130 + }
131 +
132 + @Override
133 + public boolean removeGlobalNodeLabel(DeviceId id) {
134 + globalNodeLabelMap.remove(id);
135 + if (globalNodeLabelMap.containsKey(id)) {
136 + return false;
137 + }
138 + return true;
139 + }
140 +
141 + @Override
142 + public boolean removeAdjLabel(Link link) {
143 + adjLabelMap.remove(link);
144 + if (adjLabelMap.containsKey(link)) {
145 + return false;
146 + }
147 + return true;
148 + }
149 +
150 + @Override
151 + public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
152 + // TODO Auto-generated method stub
153 + return false;
154 + }
155 +
156 + @Override
157 + public boolean removeLsrIdDevice(String lsrId) {
158 + // TODO Auto-generated method stub
159 + return false;
160 + }
161 +
162 + @Override
163 + public DeviceId getLsrIdDevice(String lsrId) {
164 + // TODO Auto-generated method stub
165 + return null;
166 + }
167 +
168 + @Override
169 + public boolean addPccLsr(DeviceId lsrId) {
170 + // TODO Auto-generated method stub
171 + return false;
172 + }
173 +
174 + @Override
175 + public boolean removePccLsr(DeviceId lsrId) {
176 + // TODO Auto-generated method stub
177 + return false;
178 + }
179 +
180 + @Override
181 + public boolean hasPccLsr(DeviceId lsrId) {
182 + // TODO Auto-generated method stub
183 + return false;
184 + }
185 +
186 + @Override
187 + public Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos() {
188 + return tunnelInfoMap.entrySet().stream()
189 + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
190 + }
191 +}
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.pcelabelstore.util;
17 +
18 +import static org.junit.Assert.assertNotNull;
19 +
20 +import java.util.HashMap;
21 +import java.util.List;
22 +import java.util.Map;
23 +import java.util.concurrent.RejectedExecutionException;
24 +
25 +import org.jboss.netty.channel.Channel;
26 +import org.onosproject.pcep.controller.ClientCapability;
27 +import org.onosproject.pcep.controller.PccId;
28 +import org.onosproject.pcep.controller.LspKey;
29 +import org.onosproject.pcep.controller.PcepClient;
30 +import org.onosproject.pcep.controller.PcepSyncStatus;
31 +import org.onosproject.pcepio.protocol.PcepFactories;
32 +import org.onosproject.pcepio.protocol.PcepFactory;
33 +import org.onosproject.pcepio.protocol.PcepMessage;
34 +import org.onosproject.pcepio.protocol.PcepStateReport;
35 +import org.onosproject.pcepio.protocol.PcepVersion;
36 +
37 +/**
38 + * Representation of PCEP client adapter.
39 + */
40 +public class PcepClientAdapter implements PcepClient {
41 +
42 + private Channel channel;
43 + protected String channelId;
44 +
45 + private boolean connected;
46 + private PccId pccId;
47 + private ClientCapability capability;
48 +
49 + private PcepVersion pcepVersion;
50 + private PcepSyncStatus lspDbSyncStatus;
51 + private PcepSyncStatus labelDbSyncStatus;
52 + private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
53 +
54 + /**
55 + * Initialize instance with specified parameters.
56 + *
57 + * @param pccId PCC id
58 + * @param pcepVersion PCEP message version
59 + */
60 + public void init(PccId pccId, PcepVersion pcepVersion) {
61 + this.pccId = pccId;
62 + this.pcepVersion = pcepVersion;
63 + }
64 +
65 + @Override
66 + public final void disconnectClient() {
67 + this.channel.close();
68 + }
69 +
70 + @Override
71 + public final void sendMessage(PcepMessage m) {
72 + }
73 +
74 + @Override
75 + public final void sendMessage(List<PcepMessage> msgs) {
76 + try {
77 + PcepMessage pcepMsg = msgs.get(0);
78 + assertNotNull("PCEP MSG should be created.", pcepMsg);
79 + } catch (RejectedExecutionException e) {
80 + throw e;
81 + }
82 + }
83 +
84 + @Override
85 + public final boolean isConnected() {
86 + return this.connected;
87 + }
88 +
89 + @Override
90 + public String channelId() {
91 + return channelId;
92 + }
93 +
94 + @Override
95 + public final PccId getPccId() {
96 + return this.pccId;
97 + };
98 +
99 + @Override
100 + public final String getStringId() {
101 + return this.pccId.toString();
102 + }
103 +
104 + @Override
105 + public final void handleMessage(PcepMessage m) {
106 + }
107 +
108 + @Override
109 + public boolean isOptical() {
110 + return false;
111 + }
112 +
113 + @Override
114 + public PcepFactory factory() {
115 + return PcepFactories.getFactory(pcepVersion);
116 + }
117 +
118 + @Override
119 + public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
120 + this.lspDbSyncStatus = syncStatus;
121 + }
122 +
123 + @Override
124 + public PcepSyncStatus lspDbSyncStatus() {
125 + return lspDbSyncStatus;
126 + }
127 +
128 + @Override
129 + public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
130 + this.labelDbSyncStatus = syncStatus;
131 + }
132 +
133 + @Override
134 + public PcepSyncStatus labelDbSyncStatus() {
135 + return labelDbSyncStatus;
136 + }
137 +
138 + @Override
139 + public void setCapability(ClientCapability capability) {
140 + this.capability = capability;
141 + }
142 +
143 + @Override
144 + public ClientCapability capability() {
145 + return capability;
146 + }
147 +
148 + @Override
149 + public void addNode(PcepClient pc) {
150 + }
151 +
152 + @Override
153 + public void deleteNode(PccId pccId) {
154 + }
155 +
156 + @Override
157 + public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
158 + lspDelegationInfo.put(lspKey, dFlag);
159 + }
160 +
161 + @Override
162 + public Boolean delegationInfo(LspKey lspKey) {
163 + return lspDelegationInfo.get(lspKey);
164 + }
165 +
166 + @Override
167 + public void initializeSyncMsgList(PccId pccId) {
168 + // TODO Auto-generated method stub
169 +
170 + }
171 +
172 + @Override
173 + public List<PcepStateReport> getSyncMsgList(PccId pccId) {
174 + // TODO Auto-generated method stub
175 + return null;
176 + }
177 +
178 + @Override
179 + public void removeSyncMsgList(PccId pccId) {
180 + // TODO Auto-generated method stub
181 +
182 + }
183 +
184 + @Override
185 + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
186 + // TODO Auto-generated method stub
187 +
188 + }
189 +}
1 +/*
2 + * Copyright 2015-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.pcelabelstore.util;
17 +
18 +import org.onosproject.store.service.AtomicCounterBuilder;
19 +import org.onosproject.store.service.AtomicValueBuilder;
20 +import org.onosproject.store.service.ConsistentMapBuilder;
21 +import org.onosproject.store.service.ConsistentTreeMapBuilder;
22 +import org.onosproject.store.service.DistributedSetBuilder;
23 +import org.onosproject.store.service.EventuallyConsistentMapBuilder;
24 +import org.onosproject.store.service.LeaderElectorBuilder;
25 +import org.onosproject.store.service.Serializer;
26 +import org.onosproject.store.service.StorageService;
27 +import org.onosproject.store.service.Topic;
28 +import org.onosproject.store.service.TransactionContextBuilder;
29 +import org.onosproject.store.service.WorkQueue;
30 +
31 +/**
32 + * Adapter for the storage service.
33 + */
34 +public class StorageServiceAdapter implements StorageService {
35 + @Override
36 + public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
37 + return null;
38 + }
39 +
40 + @Override
41 + public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() {
42 + return null;
43 + }
44 +
45 + @Override
46 + public <E> DistributedSetBuilder<E> setBuilder() {
47 + return null;
48 + }
49 +
50 + @Override
51 + public AtomicCounterBuilder atomicCounterBuilder() {
52 + return null;
53 + }
54 +
55 + @Override
56 + public <V> AtomicValueBuilder<V> atomicValueBuilder() {
57 + return null;
58 + }
59 +
60 + @Override
61 + public TransactionContextBuilder transactionContextBuilder() {
62 + return null;
63 + }
64 +
65 + @Override
66 + public LeaderElectorBuilder leaderElectorBuilder() {
67 + return null;
68 + }
69 +
70 + @Override
71 + public <E> WorkQueue<E> getWorkQueue(String name, Serializer serializer) {
72 + return null;
73 + }
74 +
75 + @Override
76 + public <T> Topic<T> getTopic(String name, Serializer serializer) {
77 + // TODO Auto-generated method stub
78 + return null;
79 + }
80 +
81 + @Override
82 + public <V> ConsistentTreeMapBuilder<V> consistentTreeMapBuilder() {
83 + // TODO Auto-generated method stub
84 + return null;
85 + }
86 +}
1 +/*
2 + * Copyright 2015-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.pcelabelstore.util;
17 +
18 +import java.util.concurrent.CompletableFuture;
19 +import java.util.concurrent.atomic.AtomicLong;
20 +
21 +import org.onosproject.store.service.AsyncAtomicCounter;
22 +import org.onosproject.store.service.AtomicCounterBuilder;
23 +
24 +/**
25 + * Test implementation of atomic counter.
26 + */
27 +public final class TestAtomicCounter implements AsyncAtomicCounter {
28 + final AtomicLong value;
29 +
30 + @Override
31 + public String name() {
32 + return null;
33 + }
34 +
35 + private TestAtomicCounter() {
36 + value = new AtomicLong();
37 + }
38 +
39 + @Override
40 + public CompletableFuture<Long> incrementAndGet() {
41 + return CompletableFuture.completedFuture(value.incrementAndGet());
42 + }
43 +
44 + @Override
45 + public CompletableFuture<Long> getAndIncrement() {
46 + return CompletableFuture.completedFuture(value.getAndIncrement());
47 + }
48 +
49 + @Override
50 + public CompletableFuture<Long> getAndAdd(long delta) {
51 + return CompletableFuture.completedFuture(value.getAndAdd(delta));
52 + }
53 +
54 + @Override
55 + public CompletableFuture<Long> addAndGet(long delta) {
56 + return CompletableFuture.completedFuture(value.addAndGet(delta));
57 + }
58 +
59 + @Override
60 + public CompletableFuture<Void> set(long value) {
61 + this.value.set(value);
62 + return CompletableFuture.completedFuture(null);
63 + }
64 +
65 + @Override
66 + public CompletableFuture<Boolean> compareAndSet(long expectedValue, long updateValue) {
67 + return CompletableFuture.completedFuture(value.compareAndSet(expectedValue, updateValue));
68 + }
69 +
70 + @Override
71 + public CompletableFuture<Long> get() {
72 + return CompletableFuture.completedFuture(value.get());
73 + }
74 +
75 + public static AtomicCounterBuilder builder() {
76 + return new Builder();
77 + }
78 +
79 + public static class Builder extends AtomicCounterBuilder {
80 + @Override
81 + public AsyncAtomicCounter build() {
82 + return new TestAtomicCounter();
83 + }
84 + }
85 +}
1 +/*
2 + * Copyright 2015-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.pcelabelstore.util;
17 +
18 +import java.util.Collection;
19 +import java.util.HashMap;
20 +import java.util.LinkedList;
21 +import java.util.List;
22 +import java.util.Map;
23 +import java.util.Set;
24 +import java.util.concurrent.atomic.AtomicBoolean;
25 +import java.util.concurrent.atomic.AtomicLong;
26 +import java.util.concurrent.atomic.AtomicReference;
27 +import java.util.function.BiFunction;
28 +import java.util.function.Function;
29 +import java.util.function.Predicate;
30 +import java.util.stream.Collectors;
31 +
32 +import org.onosproject.store.primitives.ConsistentMapBackedJavaMap;
33 +import org.onosproject.store.service.AsyncConsistentMap;
34 +import org.onosproject.store.service.ConsistentMap;
35 +import org.onosproject.store.service.ConsistentMapBuilder;
36 +import org.onosproject.store.service.MapEvent;
37 +import org.onosproject.store.service.MapEventListener;
38 +import org.onosproject.store.service.Versioned;
39 +
40 +import com.google.common.base.Objects;
41 +
42 +/**
43 + * Test implementation of the consistent map.
44 + */
45 +public final class TestConsistentMap<K, V> extends ConsistentMapAdapter<K, V> {
46 +
47 + private final List<MapEventListener<K, V>> listeners;
48 + private final Map<K, Versioned<V>> map;
49 + private final String mapName;
50 + private final AtomicLong counter = new AtomicLong(0);
51 +
52 + private TestConsistentMap(String mapName) {
53 + map = new HashMap<>();
54 + listeners = new LinkedList<>();
55 + this.mapName = mapName;
56 + }
57 +
58 + private Versioned<V> version(V v) {
59 + return new Versioned<>(v, counter.incrementAndGet(), System.currentTimeMillis());
60 + }
61 +
62 + /**
63 + * Notify all listeners of an event.
64 + */
65 + private void notifyListeners(String mapName,
66 + K key, Versioned<V> newvalue, Versioned<V> oldValue) {
67 + MapEvent<K, V> event = new MapEvent<>(mapName, key, newvalue, oldValue);
68 + listeners.forEach(
69 + listener -> listener.event(event)
70 + );
71 + }
72 +
73 + @Override
74 + public int size() {
75 + return map.size();
76 + }
77 +
78 + @Override
79 + public boolean isEmpty() {
80 + return map.isEmpty();
81 + }
82 +
83 + @Override
84 + public boolean containsKey(K key) {
85 + return map.containsKey(key);
86 + }
87 +
88 + @Override
89 + public boolean containsValue(V value) {
90 + return map.containsValue(value);
91 + }
92 +
93 + @Override
94 + public Versioned<V> get(K key) {
95 + return map.get(key);
96 + }
97 +
98 + @Override
99 + public Versioned<V> computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
100 + AtomicBoolean updated = new AtomicBoolean(false);
101 + Versioned<V> result = map.compute(key, (k, v) -> {
102 + if (v == null) {
103 + updated.set(true);
104 + return version(mappingFunction.apply(key));
105 + }
106 + return v;
107 + });
108 + if (updated.get()) {
109 + notifyListeners(mapName, key, result, null);
110 + }
111 + return result;
112 + }
113 +
114 + @Override
115 + public Versioned<V> compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
116 + AtomicBoolean updated = new AtomicBoolean(false);
117 + AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
118 + Versioned<V> result = map.compute(key, (k, v) -> {
119 + updated.set(true);
120 + previousValue.set(v);
121 + return version(remappingFunction.apply(k, Versioned.valueOrNull(v)));
122 + });
123 + if (updated.get()) {
124 + notifyListeners(mapName, key, result, previousValue.get());
125 + }
126 + return result;
127 + }
128 +
129 + @Override
130 + public Versioned<V> computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
131 + AtomicBoolean updated = new AtomicBoolean(false);
132 + AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
133 + Versioned<V> result = map.compute(key, (k, v) -> {
134 + if (v != null) {
135 + updated.set(true);
136 + previousValue.set(v);
137 + return version(remappingFunction.apply(k, v.value()));
138 + }
139 + return v;
140 + });
141 + if (updated.get()) {
142 + notifyListeners(mapName, key, result, previousValue.get());
143 + }
144 + return result;
145 + }
146 +
147 + @Override
148 + public Versioned<V> computeIf(K key, Predicate<? super V> condition,
149 + BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
150 + AtomicBoolean updated = new AtomicBoolean(false);
151 + AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
152 + Versioned<V> result = map.compute(key, (k, v) -> {
153 + if (condition.test(Versioned.valueOrNull(v))) {
154 + previousValue.set(v);
155 + updated.set(true);
156 + return version(remappingFunction.apply(k, Versioned.valueOrNull(v)));
157 + }
158 + return v;
159 + });
160 + if (updated.get()) {
161 + notifyListeners(mapName, key, result, previousValue.get());
162 + }
163 + return result;
164 + }
165 +
166 + @Override
167 + public Versioned<V> put(K key, V value) {
168 + Versioned<V> newValue = version(value);
169 + Versioned<V> previousValue = map.put(key, newValue);
170 + notifyListeners(mapName, key, newValue, previousValue);
171 + return previousValue;
172 + }
173 +
174 + @Override
175 + public Versioned<V> putAndGet(K key, V value) {
176 + Versioned<V> newValue = version(value);
177 + Versioned<V> previousValue = map.put(key, newValue);
178 + notifyListeners(mapName, key, newValue, previousValue);
179 + return newValue;
180 + }
181 +
182 + @Override
183 + public Versioned<V> remove(K key) {
184 + Versioned<V> result = map.remove(key);
185 + notifyListeners(mapName, key, null, result);
186 + return result;
187 + }
188 +
189 + @Override
190 + public void clear() {
191 + map.keySet().forEach(this::remove);
192 + }
193 +
194 + @Override
195 + public Set<K> keySet() {
196 + return map.keySet();
197 + }
198 +
199 + @Override
200 + public Collection<Versioned<V>> values() {
201 + return map.values()
202 + .stream()
203 + .collect(Collectors.toList());
204 + }
205 +
206 + @Override
207 + public Set<Map.Entry<K, Versioned<V>>> entrySet() {
208 + return map.entrySet();
209 + }
210 +
211 + @Override
212 + public Versioned<V> putIfAbsent(K key, V value) {
213 + Versioned<V> newValue = version(value);
214 + Versioned<V> result = map.putIfAbsent(key, newValue);
215 + if (result == null) {
216 + notifyListeners(mapName, key, newValue, result);
217 + }
218 + return result;
219 + }
220 +
221 + @Override
222 + public boolean remove(K key, V value) {
223 + Versioned<V> existingValue = map.get(key);
224 + if (Objects.equal(Versioned.valueOrNull(existingValue), value)) {
225 + map.remove(key);
226 + notifyListeners(mapName, key, null, existingValue);
227 + return true;
228 + }
229 + return false;
230 + }
231 +
232 + @Override
233 + public boolean remove(K key, long version) {
234 + Versioned<V> existingValue = map.get(key);
235 + if (existingValue == null) {
236 + return false;
237 + }
238 + if (existingValue.version() == version) {
239 + map.remove(key);
240 + notifyListeners(mapName, key, null, existingValue);
241 + return true;
242 + }
243 + return false;
244 + }
245 +
246 + @Override
247 + public Versioned<V> replace(K key, V value) {
248 + Versioned<V> existingValue = map.get(key);
249 + if (existingValue == null) {
250 + return null;
251 + }
252 + Versioned<V> newValue = version(value);
253 + Versioned<V> result = map.put(key, newValue);
254 + notifyListeners(mapName, key, newValue, result);
255 + return result;
256 + }
257 +
258 + @Override
259 + public boolean replace(K key, V oldValue, V newValue) {
260 + Versioned<V> existingValue = map.get(key);
261 + if (existingValue == null || !existingValue.value().equals(oldValue)) {
262 + return false;
263 + }
264 + Versioned<V> value = version(newValue);
265 + Versioned<V> result = map.put(key, value);
266 + notifyListeners(mapName, key, value, result);
267 + return true;
268 + }
269 +
270 + @Override
271 + public boolean replace(K key, long oldVersion, V newValue) {
272 + Versioned<V> existingValue = map.get(key);
273 + if (existingValue == null || existingValue.version() != oldVersion) {
274 + return false;
275 + }
276 + Versioned<V> value = version(newValue);
277 + Versioned<V> result = map.put(key, value);
278 + notifyListeners(mapName, key, value, result);
279 + return true;
280 + }
281 +
282 + @Override
283 + public void addListener(MapEventListener<K, V> listener) {
284 + listeners.add(listener);
285 + }
286 +
287 + @Override
288 + public void removeListener(MapEventListener<K, V> listener) {
289 + listeners.remove(listener);
290 + }
291 +
292 + @Override
293 + public Map<K, V> asJavaMap() {
294 + return new ConsistentMapBackedJavaMap<>(this);
295 + }
296 +
297 + public static Builder builder() {
298 + return new Builder();
299 + }
300 +
301 + public static class Builder<K, V> extends ConsistentMapBuilder<K, V> {
302 +
303 + @Override
304 + public ConsistentMap<K, V> build() {
305 + return new TestConsistentMap<>(name());
306 + }
307 +
308 + @Override
309 + public AsyncConsistentMap<K, V> buildAsyncMap() {
310 + return null;
311 + }
312 +
313 + }
314 +
315 +}
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 +package org.onosproject.pcelabelstore.util;
18 +
19 +import com.google.common.collect.ImmutableSet;
20 +import com.google.common.collect.Sets;
21 +import org.onosproject.store.primitives.DefaultDistributedSet;
22 +import org.onosproject.store.service.AsyncDistributedSet;
23 +import org.onosproject.store.service.DistributedSet;
24 +import org.onosproject.store.service.DistributedSetBuilder;
25 +import org.onosproject.store.service.SetEvent;
26 +import org.onosproject.store.service.SetEventListener;
27 +
28 +import java.util.Collection;
29 +import java.util.HashSet;
30 +import java.util.LinkedList;
31 +import java.util.List;
32 +import java.util.Set;
33 +import java.util.concurrent.CompletableFuture;
34 +
35 +/**
36 + * Test implementation of the distributed set.
37 + */
38 +public final class TestDistributedSet<E> extends DistributedSetAdapter<E> {
39 + private final List<SetEventListener<E>> listeners;
40 + private final Set<E> set;
41 + private final String setName;
42 +
43 + /**
44 + * Public constructor.
45 + *
46 + * @param setName name to be assigned to this set
47 + */
48 + public TestDistributedSet(String setName) {
49 + set = new HashSet<>();
50 + listeners = new LinkedList<>();
51 + this.setName = setName;
52 + }
53 +
54 + /**
55 + * Notify all listeners of a set event.
56 + *
57 + * @param event the SetEvent
58 + */
59 + private void notifyListeners(SetEvent<E> event) {
60 + listeners.forEach(
61 + listener -> listener.event(event)
62 + );
63 + }
64 +
65 + @Override
66 + public CompletableFuture<Void> addListener(SetEventListener<E> listener) {
67 + listeners.add(listener);
68 + return CompletableFuture.completedFuture(null);
69 + }
70 +
71 + @Override
72 + public CompletableFuture<Void> removeListener(SetEventListener<E> listener) {
73 + listeners.remove(listener);
74 + return CompletableFuture.completedFuture(null);
75 + }
76 +
77 + @Override
78 + public CompletableFuture<Boolean> add(E element) {
79 + SetEvent<E> event =
80 + new SetEvent<>(setName, SetEvent.Type.ADD, element);
81 + notifyListeners(event);
82 + return CompletableFuture.completedFuture(set.add(element));
83 + }
84 +
85 + @Override
86 + public CompletableFuture<Boolean> remove(E element) {
87 + SetEvent<E> event =
88 + new SetEvent<>(setName, SetEvent.Type.REMOVE, element);
89 + notifyListeners(event);
90 + return CompletableFuture.completedFuture(set.remove(element));
91 + }
92 +
93 + @Override
94 + public CompletableFuture<Integer> size() {
95 + return CompletableFuture.completedFuture(set.size());
96 + }
97 +
98 + @Override
99 + public CompletableFuture<Boolean> isEmpty() {
100 + return CompletableFuture.completedFuture(set.isEmpty());
101 + }
102 +
103 + @Override
104 + public CompletableFuture<Void> clear() {
105 + removeAll(ImmutableSet.copyOf(set));
106 + return CompletableFuture.completedFuture(null);
107 + }
108 +
109 + @Override
110 + public CompletableFuture<Boolean> contains(E element) {
111 + return CompletableFuture.completedFuture(set.contains(element));
112 + }
113 +
114 + @Override
115 + public CompletableFuture<Boolean> addAll(Collection<? extends E> c) {
116 + c.forEach(this::add);
117 + return CompletableFuture.completedFuture(true);
118 + }
119 +
120 + @Override
121 + public CompletableFuture<Boolean> containsAll(Collection<? extends E> c) {
122 + return CompletableFuture.completedFuture(set.containsAll(c));
123 + }
124 +
125 + @Override
126 + public CompletableFuture<Boolean> retainAll(Collection<? extends E> c) {
127 + Set notInSet2;
128 + notInSet2 = Sets.difference(set, (Set<?>) c);
129 + return removeAll(ImmutableSet.copyOf(notInSet2));
130 + }
131 +
132 + @Override
133 + public CompletableFuture<Boolean> removeAll(Collection<? extends E> c) {
134 + c.forEach(this::remove);
135 + return CompletableFuture.completedFuture(true);
136 + }
137 +
138 + @Override
139 + public CompletableFuture<? extends Set<E>> getAsImmutableSet() {
140 + return CompletableFuture.completedFuture(ImmutableSet.copyOf(set));
141 + }
142 +
143 + @Override
144 + public String name() {
145 + return this.setName;
146 + }
147 +
148 + @Override
149 + public DistributedSet<E> asDistributedSet() {
150 + return new DefaultDistributedSet<>(this, 0);
151 + }
152 +
153 + @Override
154 + public DistributedSet<E> asDistributedSet(long timeoutMillis) {
155 + return new DefaultDistributedSet<>(this, timeoutMillis);
156 + }
157 +
158 + /**
159 + * Returns a new Builder instance.
160 + *
161 + * @return Builder
162 + **/
163 + public static Builder builder() {
164 + return new Builder();
165 + }
166 +
167 + /**
168 + * Builder constructor that instantiates a TestDistributedSet.
169 + *
170 + * @param <E>
171 + */
172 + public static class Builder<E> extends DistributedSetBuilder<E> {
173 + @Override
174 + public AsyncDistributedSet<E> build() {
175 + return new TestDistributedSet(name());
176 + }
177 + }
178 +}
1 +/*
2 + * Copyright 2015-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.pcelabelstore.util;
17 +
18 +import java.util.Collection;
19 +import java.util.HashMap;
20 +import java.util.LinkedList;
21 +import java.util.List;
22 +import java.util.Map;
23 +import java.util.Set;
24 +import java.util.concurrent.ExecutorService;
25 +import java.util.concurrent.ScheduledExecutorService;
26 +import java.util.concurrent.TimeUnit;
27 +import java.util.function.BiFunction;
28 +
29 +import org.onlab.util.KryoNamespace;
30 +import org.onosproject.cluster.NodeId;
31 +import org.onosproject.store.Timestamp;
32 +import org.onosproject.store.service.EventuallyConsistentMap;
33 +import org.onosproject.store.service.EventuallyConsistentMapBuilder;
34 +import org.onosproject.store.service.EventuallyConsistentMapEvent;
35 +import org.onosproject.store.service.EventuallyConsistentMapListener;
36 +
37 +import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
38 +import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE;
39 +
40 +/**
41 + * Testing version of an Eventually Consistent Map.
42 + */
43 +
44 +public final class TestEventuallyConsistentMap<K, V> extends EventuallyConsistentMapAdapter<K, V> {
45 +
46 + private final HashMap<K, V> map;
47 + private final String mapName;
48 + private final List<EventuallyConsistentMapListener<K, V>> listeners;
49 + private final BiFunction<K, V, Collection<NodeId>> peerUpdateFunction;
50 +
51 + private TestEventuallyConsistentMap(String mapName,
52 + BiFunction<K, V, Collection<NodeId>> peerUpdateFunction) {
53 + map = new HashMap<>();
54 + listeners = new LinkedList<>();
55 + this.mapName = mapName;
56 + this.peerUpdateFunction = peerUpdateFunction;
57 + }
58 +
59 + /**
60 + * Notify all listeners of an event.
61 + */
62 + private void notifyListeners(EventuallyConsistentMapEvent<K, V> event) {
63 + listeners.forEach(
64 + listener -> listener.event(event)
65 + );
66 + }
67 +
68 + @Override
69 + public int size() {
70 + return map.size();
71 + }
72 +
73 + @Override
74 + public boolean isEmpty() {
75 + return map.isEmpty();
76 + }
77 +
78 + @Override
79 + public boolean containsKey(K key) {
80 + return map.containsKey(key);
81 + }
82 +
83 + @Override
84 + public boolean containsValue(V value) {
85 + return map.containsValue(value);
86 + }
87 +
88 + @Override
89 + public V get(K key) {
90 + return map.get(key);
91 + }
92 +
93 + @Override
94 + public void put(K key, V value) {
95 + map.put(key, value);
96 + EventuallyConsistentMapEvent<K, V> addEvent =
97 + new EventuallyConsistentMapEvent<>(mapName, PUT, key, value);
98 + notifyListeners(addEvent);
99 + if (peerUpdateFunction != null) {
100 + peerUpdateFunction.apply(key, value);
101 + }
102 + }
103 +
104 + @Override
105 + public V remove(K key) {
106 + V result = map.remove(key);
107 + if (result != null) {
108 + EventuallyConsistentMapEvent<K, V> removeEvent =
109 + new EventuallyConsistentMapEvent<>(mapName, REMOVE,
110 + key, map.get(key));
111 + notifyListeners(removeEvent);
112 + }
113 + return result;
114 + }
115 +
116 + @Override
117 + public void remove(K key, V value) {
118 + boolean removed = map.remove(key, value);
119 + if (removed) {
120 + EventuallyConsistentMapEvent<K, V> removeEvent =
121 + new EventuallyConsistentMapEvent<>(mapName, REMOVE, key, value);
122 + notifyListeners(removeEvent);
123 + }
124 + }
125 +
126 + @Override
127 + public V compute(K key, BiFunction<K, V, V> recomputeFunction) {
128 + return map.compute(key, recomputeFunction);
129 + }
130 +
131 + @Override
132 + public void putAll(Map<? extends K, ? extends V> m) {
133 + map.putAll(m);
134 + }
135 +
136 + @Override
137 + public void clear() {
138 + map.clear();
139 + }
140 +
141 + @Override
142 + public Set<K> keySet() {
143 + return map.keySet();
144 + }
145 +
146 + @Override
147 + public Collection<V> values() {
148 + return map.values();
149 + }
150 +
151 + @Override
152 + public Set<Map.Entry<K, V>> entrySet() {
153 + return map.entrySet();
154 + }
155 +
156 + public static <K, V> Builder<K, V> builder() {
157 + return new Builder<>();
158 + }
159 +
160 + @Override
161 + public void addListener(EventuallyConsistentMapListener<K, V> listener) {
162 + listeners.add(listener);
163 + }
164 +
165 + @Override
166 + public void removeListener(EventuallyConsistentMapListener<K, V> listener) {
167 + listeners.remove(listener);
168 + }
169 +
170 + public static class Builder<K, V> implements EventuallyConsistentMapBuilder<K, V> {
171 + private String name;
172 + private BiFunction<K, V, Collection<NodeId>> peerUpdateFunction;
173 +
174 + @Override
175 + public EventuallyConsistentMapBuilder<K, V> withName(String name) {
176 + this.name = name;
177 + return this;
178 + }
179 +
180 + @Override
181 + public EventuallyConsistentMapBuilder<K, V> withSerializer(KryoNamespace.Builder serializerBuilder) {
182 + return this;
183 + }
184 +
185 + @Override
186 + public EventuallyConsistentMapBuilder<K, V> withSerializer(KryoNamespace serializer) {
187 + return this;
188 + }
189 +
190 + @Override
191 + public EventuallyConsistentMapBuilder<K, V>
192 + withTimestampProvider(BiFunction<K, V, Timestamp> timestampProvider) {
193 + return this;
194 + }
195 +
196 + @Override
197 + public EventuallyConsistentMapBuilder<K, V> withEventExecutor(ExecutorService executor) {
198 + return this;
199 + }
200 +
201 + @Override
202 + public EventuallyConsistentMapBuilder<K, V> withCommunicationExecutor(ExecutorService executor) {
203 + return this;
204 + }
205 +
206 + @Override
207 + public EventuallyConsistentMapBuilder<K, V> withBackgroundExecutor(ScheduledExecutorService executor) {
208 + return this;
209 + }
210 +
211 + @Override
212 + public EventuallyConsistentMapBuilder<K, V>
213 + withPeerUpdateFunction(BiFunction<K, V, Collection<NodeId>> peerUpdateFunction) {
214 + this.peerUpdateFunction = peerUpdateFunction;
215 + return this;
216 + }
217 +
218 + @Override
219 + public EventuallyConsistentMapBuilder<K, V> withTombstonesDisabled() {
220 + return this;
221 + }
222 +
223 + @Override
224 + public EventuallyConsistentMapBuilder<K, V> withAntiEntropyPeriod(long period, TimeUnit unit) {
225 + return this;
226 + }
227 +
228 + @Override
229 + public EventuallyConsistentMapBuilder<K, V> withFasterConvergence() {
230 + return this;
231 + }
232 +
233 + @Override
234 + public EventuallyConsistentMapBuilder<K, V> withPersistence() {
235 + return this;
236 + }
237 +
238 + @Override
239 + public EventuallyConsistentMap<K, V> build() {
240 + if (name == null) {
241 + name = "test";
242 + }
243 + return new TestEventuallyConsistentMap<>(name, peerUpdateFunction);
244 + }
245 + }
246 +
247 +}
248 +
1 /* 1 /*
2 - * Copyright 2016-present Open Networking Laboratory 2 + * Copyright 2015-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.
...@@ -13,58 +13,45 @@ ...@@ -13,58 +13,45 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.util; 16 +package org.onosproject.pcelabelstore.util;
17 17
18 -import java.util.List; 18 +import org.onosproject.store.service.AtomicCounterBuilder;
19 -import com.google.common.collect.ImmutableList; 19 +import org.onosproject.store.service.AtomicValueBuilder;
20 -import org.onosproject.net.DeviceId; 20 +import org.onosproject.store.service.ConsistentMapBuilder;
21 -import org.onosproject.net.flowobjective.FilteringObjective; 21 +import org.onosproject.store.service.DistributedSetBuilder;
22 -import org.onosproject.net.flowobjective.FlowObjectiveService; 22 +import org.onosproject.store.service.EventuallyConsistentMapBuilder;
23 -import org.onosproject.net.flowobjective.ForwardingObjective; 23 +import org.onosproject.store.service.TransactionContextBuilder;
24 -import org.onosproject.net.flowobjective.NextObjective;
25 24
26 -/** 25 +public class TestStorageService extends StorageServiceAdapter {
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 26
35 - }
36 27
37 @Override 28 @Override
38 - public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) { 29 + public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
39 - this.forwardingObjective = forwardingObjective; 30 + return TestEventuallyConsistentMap.builder();
40 } 31 }
41 32
42 @Override 33 @Override
43 - public void next(DeviceId deviceId, NextObjective nextObjective) { 34 + public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() {
44 - 35 + return TestConsistentMap.builder();
45 } 36 }
46 37
47 @Override 38 @Override
48 - public int allocateNextId() { 39 + public <E> DistributedSetBuilder<E> setBuilder() {
49 - return 0; 40 + return TestDistributedSet.builder();
50 } 41 }
51 42
52 @Override 43 @Override
53 - public void initPolicy(String policy) { 44 + public AtomicCounterBuilder atomicCounterBuilder() {
54 - 45 + return TestAtomicCounter.builder();
55 - }
56 -
57 - public ForwardingObjective forwardingObjective() {
58 - return forwardingObjective;
59 } 46 }
60 47
61 @Override 48 @Override
62 - public List<String> getNextMappings() { 49 + public <V> AtomicValueBuilder<V> atomicValueBuilder() {
63 - return ImmutableList.of(); 50 + throw new UnsupportedOperationException("atomicValueBuilder");
64 } 51 }
65 52
66 @Override 53 @Override
67 - public List<String> getPendingNexts() { 54 + public TransactionContextBuilder transactionContextBuilder() {
68 - return ImmutableList.of(); 55 + throw new UnsupportedOperationException("transactionContextBuilder");
69 } 56 }
70 } 57 }
......
...@@ -366,7 +366,6 @@ public class PcepLspObjectVer1 implements PcepLspObject { ...@@ -366,7 +366,6 @@ public class PcepLspObjectVer1 implements PcepLspObject {
366 default: 366 default:
367 // Skip the unknown TLV. 367 // Skip the unknown TLV.
368 cb.skipBytes(hLength); 368 cb.skipBytes(hLength);
369 - tlv = null;
370 log.info("Received unsupported TLV type :" + hType + " in LSP object."); 369 log.info("Received unsupported TLV type :" + hType + " in LSP object.");
371 } 370 }
372 // Check for the padding 371 // Check for the padding
......
...@@ -22,6 +22,15 @@ ...@@ -22,6 +22,15 @@
22 <artifact>mvn:${project.groupId}/onos-bgpio/${project.version}</artifact> 22 <artifact>mvn:${project.groupId}/onos-bgpio/${project.version}</artifact>
23 <artifact>mvn:${project.groupId}/onos-bgp-api/${project.version}</artifact> 23 <artifact>mvn:${project.groupId}/onos-bgp-api/${project.version}</artifact>
24 <artifact>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</artifact> 24 <artifact>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</artifact>
25 + <artifact>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</artifact>
25 <artifact>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</artifact> 26 <artifact>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</artifact>
26 <artifact>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</artifact> 27 <artifact>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</artifact>
28 + <artifact>mvn:${project.groupId}/onos-pcepio/${project.version}</artifact>
29 + <artifact>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</artifact>
30 + <artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
31 + <artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
32 + <artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
33 + <artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
34 + <artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
35 + <artifact>mvn:${project.groupId}/onos-app-pcerest/${project.version}</artifact>
27 </app> 36 </app>
......
...@@ -21,7 +21,16 @@ ...@@ -21,7 +21,16 @@
21 <bundle>mvn:${project.groupId}/onos-bgpio/${project.version}</bundle> 21 <bundle>mvn:${project.groupId}/onos-bgpio/${project.version}</bundle>
22 <bundle>mvn:${project.groupId}/onos-bgp-api/${project.version}</bundle> 22 <bundle>mvn:${project.groupId}/onos-bgp-api/${project.version}</bundle>
23 <bundle>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</bundle> 23 <bundle>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</bundle>
24 + <bundle>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</bundle>
24 <bundle>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</bundle> 25 <bundle>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</bundle>
25 <bundle>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</bundle> 26 <bundle>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</bundle>
27 + <bundle>mvn:${project.groupId}/onos-pcepio/${project.version}</bundle>
28 + <bundle>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</bundle>
29 + <bundle>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</bundle>
30 + <bundle>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</bundle>
31 + <bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
32 + <bundle>mvn:${project.groupId}/onos-app-pce/${project.version}</bundle>
33 + <bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
34 + <bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
26 </feature> 35 </feature>
27 </features> 36 </features>
......
...@@ -46,5 +46,20 @@ ...@@ -46,5 +46,20 @@
46 <artifactId>onos-bgp-provider-topology</artifactId> 46 <artifactId>onos-bgp-provider-topology</artifactId>
47 <version>${project.version}</version> 47 <version>${project.version}</version>
48 </dependency> 48 </dependency>
49 + <dependency>
50 + <groupId>org.onosproject</groupId>
51 + <artifactId>onos-app-pce</artifactId>
52 + <version>${project.version}</version>
53 + </dependency>
54 + <dependency>
55 + <groupId>org.onosproject</groupId>
56 + <artifactId>onos-app-pceweb</artifactId>
57 + <version>${project.version}</version>
58 + </dependency>
59 + <dependency>
60 + <groupId>org.onosproject</groupId>
61 + <artifactId>onos-app-pcerest</artifactId>
62 + <version>${project.version}</version>
63 + </dependency>
49 </dependencies> 64 </dependencies>
50 </project> 65 </project>
......
...@@ -10,7 +10,6 @@ BUNDLES = [ ...@@ -10,7 +10,6 @@ BUNDLES = [
10 '//protocols/pcep/ctl:onos-protocols-pcep-ctl', 10 '//protocols/pcep/ctl:onos-protocols-pcep-ctl',
11 '//providers/pcep/topology:onos-providers-pcep-topology', 11 '//providers/pcep/topology:onos-providers-pcep-topology',
12 '//providers/pcep/tunnel:onos-providers-pcep-tunnel', 12 '//providers/pcep/tunnel:onos-providers-pcep-tunnel',
13 - '//providers/pcep/packet:onos-providers-pcep-packet',
14 '//providers/bgpcep/flow:onos-providers-bgpcep-flow', 13 '//providers/bgpcep/flow:onos-providers-bgpcep-flow',
15 '//apps/pce/app:onos-apps-pce-app', 14 '//apps/pce/app:onos-apps-pce-app',
16 '//apps/pce/pceweb:onos-apps-pce-pceweb', 15 '//apps/pce/pceweb:onos-apps-pce-pceweb',
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
30 <artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact> 30 <artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
31 <artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact> 31 <artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
32 <artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact> 32 <artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
33 - <artifact>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</artifact>
34 <artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact> 33 <artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact>
35 <artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact> 34 <artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
36 <artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact> 35 <artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
31 <bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle> 31 <bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
32 <bundle>mvn:${project.groupId}/onos-app-pce/${project.version}</bundle> 32 <bundle>mvn:${project.groupId}/onos-app-pce/${project.version}</bundle>
33 <bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle> 33 <bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
34 - <bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle>
35 <bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle> 34 <bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle>
36 <bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle> 35 <bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
37 </feature> 36 </feature>
......
...@@ -5,7 +5,6 @@ BUNDLES = [ ...@@ -5,7 +5,6 @@ BUNDLES = [
5 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', 5 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
6 '//protocols/pcep/ctl:onos-protocols-pcep-ctl', 6 '//protocols/pcep/ctl:onos-protocols-pcep-ctl',
7 '//apps/pcep-api:onos-apps-pcep-api', 7 '//apps/pcep-api:onos-apps-pcep-api',
8 - '//providers/pcep/packet:onos-providers-pcep-packet',
9 ] 8 ]
10 9
11 onos_app ( 10 onos_app (
......
1 -COMPILE_DEPS = [
2 - '//lib:CORE_DEPS',
3 - '//protocols/pcep/api:onos-protocols-pcep-api',
4 -]
5 -
6 -osgi_jar_with_tests (
7 - deps = COMPILE_DEPS,
8 -)
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 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18 - <modelVersion>4.0.0</modelVersion>
19 - <parent>
20 - <groupId>org.onosproject</groupId>
21 - <artifactId>onos-pcep-providers</artifactId>
22 - <version>1.7.0-SNAPSHOT</version>
23 - </parent>
24 - <artifactId>onos-pcep-provider-packet</artifactId>
25 - <packaging>bundle</packaging>
26 - <description>PCEP packet provider</description>
27 - <dependencies>
28 - <dependency>
29 - <groupId>org.onosproject</groupId>
30 - <artifactId>onos-pcep-controller-api</artifactId>
31 - </dependency>
32 - </dependencies>
33 -</project>
1 -package org.onosproject.provider.pcep.packet.impl;
2 -
3 -import static org.slf4j.LoggerFactory.getLogger;
4 -
5 -import org.apache.felix.scr.annotations.Activate;
6 -import org.apache.felix.scr.annotations.Component;
7 -import org.apache.felix.scr.annotations.Deactivate;
8 -import org.apache.felix.scr.annotations.Reference;
9 -import org.apache.felix.scr.annotations.ReferenceCardinality;
10 -import org.apache.felix.scr.annotations.Service;
11 -import org.onlab.packet.Ethernet;
12 -import org.onlab.packet.IPv4;
13 -import org.onlab.packet.MacAddress;
14 -import org.onlab.packet.TCP;
15 -import org.onosproject.net.ConnectPoint;
16 -import org.onosproject.net.DeviceId;
17 -import org.onosproject.net.PortNumber;
18 -import org.onosproject.net.device.DeviceService;
19 -import org.onosproject.net.packet.DefaultInboundPacket;
20 -import org.onosproject.net.packet.DefaultPacketContext;
21 -import org.onosproject.net.packet.InboundPacket;
22 -import org.onosproject.net.packet.OutboundPacket;
23 -import org.onosproject.net.packet.PacketProvider;
24 -import org.onosproject.net.packet.PacketProviderRegistry;
25 -import org.onosproject.net.packet.PacketProviderService;
26 -import org.onosproject.net.provider.AbstractProvider;
27 -import org.onosproject.net.provider.ProviderId;
28 -import org.onosproject.pcep.controller.PccId;
29 -import org.onosproject.pcep.controller.PcepClientController;
30 -import org.onosproject.pcep.controller.PcepPacketListener;
31 -import org.slf4j.Logger;
32 -
33 -/**
34 - * Provider which uses an PCEP controller to process packets.
35 - */
36 -@Component(immediate = true)
37 -@Service
38 -public class PcepPacketProvider extends AbstractProvider implements PacketProvider {
39 -
40 - private static final Logger log = getLogger(PcepPacketProvider.class);
41 - static final String PROVIDER_ID = "org.onosproject.provider.packet.pcep";
42 -
43 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
44 - protected PacketProviderRegistry packetProviderRegistry;
45 -
46 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
47 - protected PcepClientController pcepClientController;
48 -
49 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
50 - protected DeviceService deviceService;
51 -
52 - PacketProviderService packetProviderService;
53 -
54 - private InnerPacketProvider listener = new InnerPacketProvider();
55 - public static final String LSRID = "lsrId";
56 - public static final int PCEP_PORT = 4189;
57 -
58 - /**
59 - * Creates a Packet provider.
60 - */
61 - public PcepPacketProvider() {
62 - super(new ProviderId("pcep", PROVIDER_ID));
63 - }
64 -
65 - @Activate
66 - public void activate() {
67 - packetProviderService = packetProviderRegistry.register(this);
68 - pcepClientController.addPacketListener(listener);
69 - log.info("Started");
70 - }
71 -
72 - @Deactivate
73 - public void deactivate() {
74 - packetProviderRegistry.unregister(this);
75 - pcepClientController.removePacketListener(listener);
76 - log.info("Stopped");
77 - }
78 -
79 - private class InnerPacketProvider implements PcepPacketListener {
80 - @Override
81 - public void sendPacketIn(PccId pccId) {
82 - TCP tcp = new TCP();
83 - // Set the well known PCEP port. To be used to decide to process/discard the packet while processing.
84 - tcp.setDestinationPort(PCEP_PORT);
85 -
86 - IPv4 ipv4 = new IPv4();
87 - ipv4.setProtocol(IPv4.PROTOCOL_TCP);
88 - ipv4.setPayload(tcp);
89 -
90 - Ethernet eth = new Ethernet();
91 - eth.setEtherType(Ethernet.TYPE_IPV4);
92 - eth.setDestinationMACAddress(MacAddress.NONE);
93 - eth.setPayload(ipv4);
94 -
95 - // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
96 - String lsrId = String.valueOf(pccId.ipAddress());
97 - DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
98 -
99 - InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId,
100 - PortNumber.portNumber(PCEP_PORT)),
101 - eth, null);
102 -
103 - packetProviderService.processPacket(new PcepPacketContext(inPkt, null));
104 - }
105 - }
106 -
107 - // Minimal PacketContext to make core and applications happy.
108 - private final class PcepPacketContext extends DefaultPacketContext {
109 - private PcepPacketContext(InboundPacket inPkt, OutboundPacket outPkt) {
110 - super(System.currentTimeMillis(), inPkt, outPkt, false);
111 - }
112 -
113 - @Override
114 - public void send() {
115 - // We don't send anything out.
116 - }
117 - }
118 -
119 - @Override
120 - public void emit(OutboundPacket packet) {
121 - // Nothing to emit
122 - }
123 -}
...@@ -27,6 +27,5 @@ ...@@ -27,6 +27,5 @@
27 <module>topology</module> 27 <module>topology</module>
28 <module>tunnel</module> 28 <module>tunnel</module>
29 <module>app</module> 29 <module>app</module>
30 - <module>packet</module>
31 </modules> 30 </modules>
32 </project> 31 </project>
...\ No newline at end of file ...\ No newline at end of file
......
1 COMPILE_DEPS = [ 1 COMPILE_DEPS = [
2 '//lib:CORE_DEPS', 2 '//lib:CORE_DEPS',
3 + '//incubator/api:onos-incubator-api',
3 '//protocols/ovsdb/api:onos-protocols-ovsdb-api', 4 '//protocols/ovsdb/api:onos-protocols-ovsdb-api',
4 '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc', 5 '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
5 '//apps/pcep-api:onos-apps-pcep-api', 6 '//apps/pcep-api:onos-apps-pcep-api',
......
...@@ -25,6 +25,10 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -25,6 +25,10 @@ import java.util.concurrent.ConcurrentHashMap;
25 import org.apache.felix.scr.annotations.Activate; 25 import org.apache.felix.scr.annotations.Activate;
26 import org.apache.felix.scr.annotations.Deactivate; 26 import org.apache.felix.scr.annotations.Deactivate;
27 import org.onlab.packet.IpAddress; 27 import org.onlab.packet.IpAddress;
28 +import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
29 +import org.onosproject.incubator.net.tunnel.LabelStack;
30 +import org.onosproject.incubator.net.tunnel.Tunnel;
31 +import org.onosproject.net.Path;
28 import org.onosproject.pcep.controller.ClientCapability; 32 import org.onosproject.pcep.controller.ClientCapability;
29 import org.onosproject.pcep.controller.PccId; 33 import org.onosproject.pcep.controller.PccId;
30 import org.onosproject.pcep.controller.PcepClient; 34 import org.onosproject.pcep.controller.PcepClient;
...@@ -32,7 +36,6 @@ import org.onosproject.pcep.controller.PcepClientController; ...@@ -32,7 +36,6 @@ import org.onosproject.pcep.controller.PcepClientController;
32 import org.onosproject.pcep.controller.PcepClientListener; 36 import org.onosproject.pcep.controller.PcepClientListener;
33 import org.onosproject.pcep.controller.PcepEventListener; 37 import org.onosproject.pcep.controller.PcepEventListener;
34 import org.onosproject.pcep.controller.PcepNodeListener; 38 import org.onosproject.pcep.controller.PcepNodeListener;
35 -import org.onosproject.pcep.controller.PcepPacketListener;
36 import org.onosproject.pcep.controller.driver.PcepAgent; 39 import org.onosproject.pcep.controller.driver.PcepAgent;
37 import org.onosproject.pcepio.protocol.PcepError; 40 import org.onosproject.pcepio.protocol.PcepError;
38 import org.onosproject.pcepio.protocol.PcepErrorInfo; 41 import org.onosproject.pcepio.protocol.PcepErrorInfo;
...@@ -41,6 +44,7 @@ import org.onosproject.pcepio.protocol.PcepErrorObject; ...@@ -41,6 +44,7 @@ import org.onosproject.pcepio.protocol.PcepErrorObject;
41 import org.onosproject.pcepio.protocol.PcepFactory; 44 import org.onosproject.pcepio.protocol.PcepFactory;
42 import org.onosproject.pcepio.protocol.PcepMessage; 45 import org.onosproject.pcepio.protocol.PcepMessage;
43 import org.onosproject.pcepio.protocol.PcepVersion; 46 import org.onosproject.pcepio.protocol.PcepVersion;
47 +import org.onosproject.pcepio.types.PcepValueType;
44 48
45 import com.google.common.collect.Sets; 49 import com.google.common.collect.Sets;
46 50
...@@ -290,14 +294,20 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -290,14 +294,20 @@ public class PcepClientControllerAdapter implements PcepClientController {
290 } 294 }
291 295
292 @Override 296 @Override
293 - public void addPacketListener(PcepPacketListener listener) { 297 + public LabelStack computeLabelStack(Path path) {
294 // TODO Auto-generated method stub 298 // TODO Auto-generated method stub
295 - 299 + return null;
296 } 300 }
297 301
298 @Override 302 @Override
299 - public void removePacketListener(PcepPacketListener listener) { 303 + public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
300 // TODO Auto-generated method stub 304 // TODO Auto-generated method stub
305 + return null;
306 + }
301 307
308 + @Override
309 + public boolean allocateLocalLabel(Tunnel tunnel) {
310 + // TODO Auto-generated method stub
311 + return false;
302 } 312 }
303 } 313 }
......
...@@ -24,13 +24,16 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -24,13 +24,16 @@ import java.util.concurrent.ConcurrentHashMap;
24 24
25 import org.apache.felix.scr.annotations.Activate; 25 import org.apache.felix.scr.annotations.Activate;
26 import org.apache.felix.scr.annotations.Deactivate; 26 import org.apache.felix.scr.annotations.Deactivate;
27 +import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
28 +import org.onosproject.incubator.net.tunnel.LabelStack;
29 +import org.onosproject.incubator.net.tunnel.Tunnel;
30 +import org.onosproject.net.Path;
27 import org.onosproject.pcep.controller.PccId; 31 import org.onosproject.pcep.controller.PccId;
28 import org.onosproject.pcep.controller.PcepClient; 32 import org.onosproject.pcep.controller.PcepClient;
29 import org.onosproject.pcep.controller.PcepClientController; 33 import org.onosproject.pcep.controller.PcepClientController;
30 import org.onosproject.pcep.controller.PcepClientListener; 34 import org.onosproject.pcep.controller.PcepClientListener;
31 import org.onosproject.pcep.controller.PcepEventListener; 35 import org.onosproject.pcep.controller.PcepEventListener;
32 import org.onosproject.pcep.controller.PcepNodeListener; 36 import org.onosproject.pcep.controller.PcepNodeListener;
33 -import org.onosproject.pcep.controller.PcepPacketListener;
34 import org.onosproject.pcep.controller.driver.PcepAgent; 37 import org.onosproject.pcep.controller.driver.PcepAgent;
35 import org.onosproject.pcepio.protocol.PcepError; 38 import org.onosproject.pcepio.protocol.PcepError;
36 import org.onosproject.pcepio.protocol.PcepErrorInfo; 39 import org.onosproject.pcepio.protocol.PcepErrorInfo;
...@@ -39,6 +42,7 @@ import org.onosproject.pcepio.protocol.PcepErrorObject; ...@@ -39,6 +42,7 @@ import org.onosproject.pcepio.protocol.PcepErrorObject;
39 import org.onosproject.pcepio.protocol.PcepFactory; 42 import org.onosproject.pcepio.protocol.PcepFactory;
40 import org.onosproject.pcepio.protocol.PcepMessage; 43 import org.onosproject.pcepio.protocol.PcepMessage;
41 import org.onosproject.pcepio.protocol.PcepVersion; 44 import org.onosproject.pcepio.protocol.PcepVersion;
45 +import org.onosproject.pcepio.types.PcepValueType;
42 46
43 import com.google.common.collect.Sets; 47 import com.google.common.collect.Sets;
44 48
...@@ -58,7 +62,6 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -58,7 +62,6 @@ public class PcepClientControllerAdapter implements PcepClientController {
58 62
59 protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); 63 protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
60 public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet(); 64 public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
61 - protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet();
62 65
63 @Activate 66 @Activate
64 public void activate() { 67 public void activate() {
...@@ -118,16 +121,6 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -118,16 +121,6 @@ public class PcepClientControllerAdapter implements PcepClientController {
118 } 121 }
119 122
120 @Override 123 @Override
121 - public void addPacketListener(PcepPacketListener listener) {
122 - pcepPacketListener.add(listener);
123 - }
124 -
125 - @Override
126 - public void removePacketListener(PcepPacketListener listener) {
127 - pcepPacketListener.remove(listener);
128 - }
129 -
130 - @Override
131 public void writeMessage(PccId pccId, PcepMessage msg) { 124 public void writeMessage(PccId pccId, PcepMessage msg) {
132 this.getClient(pccId).sendMessage(msg); 125 this.getClient(pccId).sendMessage(msg);
133 } 126 }
...@@ -292,4 +285,22 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -292,4 +285,22 @@ public class PcepClientControllerAdapter implements PcepClientController {
292 return false; 285 return false;
293 } 286 }
294 } 287 }
288 +
289 + @Override
290 + public LabelStack computeLabelStack(Path path) {
291 + // TODO Auto-generated method stub
292 + return null;
293 + }
294 +
295 + @Override
296 + public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
297 + // TODO Auto-generated method stub
298 + return null;
299 + }
300 +
301 + @Override
302 + public boolean allocateLocalLabel(Tunnel tunnel) {
303 + // TODO Auto-generated method stub
304 + return false;
305 + }
295 } 306 }
......