Priyanka B
Committed by Gerrit Code Review

[ONOS] cherry pick from onos1.6 to master all defects merges

Change-Id: I0ff6595a55b1104cf59a270ac2b10a7f831f6555
...@@ -65,16 +65,13 @@ public class PceUpdatePathCommand extends AbstractShellCommand { ...@@ -65,16 +65,13 @@ public class PceUpdatePathCommand extends AbstractShellCommand {
65 constrntList.add(BandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit.valueOf("BPS"))); 65 constrntList.add(BandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit.valueOf("BPS")));
66 } 66 }
67 67
68 - // Assign cost 68 + // Cost validation
69 - if (cost != 0) { 69 + if ((cost < 1) || (cost > 2)) {
70 - // Cost validation 70 + error("The cost attribute value is either IGP cost(1) or TE cost(2).");
71 - if ((cost < 1) || (cost > 2)) { 71 + return;
72 - error("The cost attribute value is either IGP cost(1) or TE cost(2).");
73 - return;
74 - }
75 - CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1];
76 - constrntList.add(CostConstraint.of(costType));
77 } 72 }
73 + CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1];
74 + constrntList.add(CostConstraint.of(costType));
78 75
79 if (!service.updatePath(TunnelId.valueOf(id), constrntList)) { 76 if (!service.updatePath(TunnelId.valueOf(id), constrntList)) {
80 error("Path updation failed."); 77 error("Path updation failed.");
......
...@@ -269,7 +269,6 @@ public final class BasicPceccHandler { ...@@ -269,7 +269,6 @@ public final class BasicPceccHandler {
269 * @param tunnel tunnel between ingress to egress 269 * @param tunnel tunnel between ingress to egress
270 */ 270 */
271 public void releaseLabel(Tunnel tunnel) { 271 public void releaseLabel(Tunnel tunnel) {
272 - boolean isLastLabelToPush = false;
273 272
274 checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); 273 checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
275 checkNotNull(pceStore, PCE_STORE_NULL); 274 checkNotNull(pceStore, PCE_STORE_NULL);
...@@ -287,19 +286,14 @@ public final class BasicPceccHandler { ...@@ -287,19 +286,14 @@ public final class BasicPceccHandler {
287 PortNumber inPort = lspLocalLabelInfo.inPort(); 286 PortNumber inPort = lspLocalLabelInfo.inPort();
288 PortNumber outPort = lspLocalLabelInfo.outPort(); 287 PortNumber outPort = lspLocalLabelInfo.outPort();
289 288
290 - // Check whether this is last link label to push
291 - if (!iterator.hasNext()) {
292 - isLastLabelToPush = true;
293 - }
294 -
295 // Push into device 289 // Push into device
296 if ((inLabelId != null) && (inPort != null)) { 290 if ((inLabelId != null) && (inPort != null)) {
297 - installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush, 291 + installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), false,
298 Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE); 292 Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE);
299 } 293 }
300 294
301 if ((outLabelId != null) && (outPort != null)) { 295 if ((outLabelId != null) && (outPort != null)) {
302 - installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush, 296 + installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), false,
303 Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE); 297 Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE);
304 } 298 }
305 299
...@@ -331,7 +325,7 @@ public final class BasicPceccHandler { ...@@ -331,7 +325,7 @@ public final class BasicPceccHandler {
331 } 325 }
332 326
333 // Install a rule for pushing local labels to the device which is specific to path. 327 // Install a rule for pushing local labels to the device which is specific to path.
334 - private void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId, 328 + private synchronized void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId,
335 PortNumber portNum, TunnelId tunnelId, 329 PortNumber portNum, TunnelId tunnelId,
336 Boolean isBos, Long labelType, 330 Boolean isBos, Long labelType,
337 Objective.Operation type) { 331 Objective.Operation type) {
......
...@@ -110,14 +110,14 @@ import org.slf4j.LoggerFactory; ...@@ -110,14 +110,14 @@ import org.slf4j.LoggerFactory;
110 import com.google.common.collect.ImmutableList; 110 import com.google.common.collect.ImmutableList;
111 import com.google.common.collect.ImmutableSet; 111 import com.google.common.collect.ImmutableSet;
112 112
113 -import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; 113 +import static org.onosproject.incubator.net.tunnel.Tunnel.State.ACTIVE;
114 import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; 114 import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
115 import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; 115 import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
116 import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; 116 import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
117 +import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
117 import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; 118 import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
118 import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; 119 import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING;
119 import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; 120 import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
120 -
121 import static org.onosproject.pce.pceservice.PcepAnnotationKeys.BANDWIDTH; 121 import static org.onosproject.pce.pceservice.PcepAnnotationKeys.BANDWIDTH;
122 import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID; 122 import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID;
123 import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LSP_SIG_TYPE; 123 import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LSP_SIG_TYPE;
...@@ -509,7 +509,7 @@ public class PceManager implements PceService { ...@@ -509,7 +509,7 @@ public class PceManager implements PceService {
509 } 509 }
510 510
511 if (existingBwValue != null) { 511 if (existingBwValue != null) {
512 - if (bwConstraintValue == 0) { 512 + if (bwConstraintValue == 0 && bwConstraint != null) {
513 bwConstraintValue = existingBwValue.bps(); 513 bwConstraintValue = existingBwValue.bps();
514 } 514 }
515 //If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation 515 //If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation
...@@ -621,6 +621,12 @@ public class PceManager implements PceService { ...@@ -621,6 +621,12 @@ public class PceManager implements PceService {
621 return false; 621 return false;
622 } 622 }
623 623
624 + LspType lspType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
625 + // Release basic PCECC labels.
626 + if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) {
627 + crHandler.releaseLabel(tunnel);
628 + }
629 +
624 // 2. Call tunnel service. 630 // 2. Call tunnel service.
625 return tunnelService.downTunnel(appId, tunnel.tunnelId()); 631 return tunnelService.downTunnel(appId, tunnel.tunnelId());
626 } 632 }
...@@ -641,7 +647,7 @@ public class PceManager implements PceService { ...@@ -641,7 +647,7 @@ public class PceManager implements PceService {
641 * 647 *
642 * @return value of local LSP identifier 648 * @return value of local LSP identifier
643 */ 649 */
644 - private short getNextLocalLspId() { 650 + private synchronized short getNextLocalLspId() {
645 // If there is any free id use it. Otherwise generate new id. 651 // If there is any free id use it. Otherwise generate new id.
646 if (localLspIdFreeList.isEmpty()) { 652 if (localLspIdFreeList.isEmpty()) {
647 return (short) localLspIdIdGen.getNewId(); 653 return (short) localLspIdIdGen.getNewId();
...@@ -778,7 +784,7 @@ public class PceManager implements PceService { ...@@ -778,7 +784,7 @@ public class PceManager implements PceService {
778 bwToAllocate = 0; 784 bwToAllocate = 0;
779 if ((shBwConstraint != null) && (shBwConstraint.links().contains(link))) { 785 if ((shBwConstraint != null) && (shBwConstraint.links().contains(link))) {
780 if (additionalBwValue != null) { 786 if (additionalBwValue != null) {
781 - bwToAllocate = bandwidthConstraint - additionalBwValue; 787 + bwToAllocate = additionalBwValue;
782 } 788 }
783 } else { 789 } else {
784 bwToAllocate = bandwidthConstraint; 790 bwToAllocate = bandwidthConstraint;
...@@ -857,7 +863,12 @@ public class PceManager implements PceService { ...@@ -857,7 +863,12 @@ public class PceManager implements PceService {
857 // 1. Release old tunnel's bandwidth. 863 // 1. Release old tunnel's bandwidth.
858 resourceService.release(pceStore.getTunnelInfo(oldTunnel.tunnelId()).tunnelConsumerId()); 864 resourceService.release(pceStore.getTunnelInfo(oldTunnel.tunnelId()).tunnelConsumerId());
859 865
860 - // 2. Release new tunnel's bandwidth 866 + // 2. Release new tunnel's bandwidth, if new tunnel bandwidth is allocated
867 + if (pceStore.getTunnelInfo(newTunnel.tunnelId()) == null) {
868 + //If bandwidth for new tunnel is not allocated i,e 0 then no need to allocate
869 + return;
870 + }
871 +
861 ResourceConsumer consumer = pceStore.getTunnelInfo(newTunnel.tunnelId()).tunnelConsumerId(); 872 ResourceConsumer consumer = pceStore.getTunnelInfo(newTunnel.tunnelId()).tunnelConsumerId();
862 resourceService.release(consumer); 873 resourceService.release(consumer);
863 874
...@@ -1148,6 +1159,22 @@ public class PceManager implements PceService { ...@@ -1148,6 +1159,22 @@ public class PceManager implements PceService {
1148 } 1159 }
1149 } 1160 }
1150 1161
1162 + //In CR case, release labels when new tunnel for it is updated.
1163 + if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR && tunnel.state() == ACTIVE
1164 + && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) {
1165 + Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
1166 +
1167 + for (Tunnel t : tunnels) {
1168 + if (tunnel.annotations().value(PLSP_ID).equals(t.annotations().value(PLSP_ID))
1169 + && !tunnel.annotations().value(LOCAL_LSP_ID)
1170 + .equals(t.annotations().value(LOCAL_LSP_ID))) {
1171 + // Release basic PCECC labels.
1172 + crHandler.releaseLabel(t);
1173 + break;
1174 + }
1175 + }
1176 + }
1177 +
1151 if (tunnel.state() == UNSTABLE) { 1178 if (tunnel.state() == UNSTABLE) {
1152 /* 1179 /*
1153 * During LSP DB sync if PCC doesn't report LSP which was PCE initiated, it's state is turned into 1180 * During LSP DB sync if PCC doesn't report LSP which was PCE initiated, it's state is turned into
...@@ -1183,23 +1210,16 @@ public class PceManager implements PceService { ...@@ -1183,23 +1210,16 @@ public class PceManager implements PceService {
1183 if (lspType != WITH_SIGNALLING) { 1210 if (lspType != WITH_SIGNALLING) {
1184 localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID))); 1211 localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID)));
1185 } 1212 }
1186 -
1187 // If not zero bandwidth, and delegated (initiated LSPs will also be delegated). 1213 // If not zero bandwidth, and delegated (initiated LSPs will also be delegated).
1188 - if (bwConstraintValue != 0) { 1214 + if (Float.parseFloat(tunnel.annotations().value(BANDWIDTH)) != 0
1189 - releaseBandwidth(event.subject()); 1215 + && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) {
1190 - 1216 + releaseBandwidth(tunnel);
1191 - // Release basic PCECC labels. 1217 + }
1192 - if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) { 1218 +
1193 - // Delete stored tunnel consumer id from PCE store (while still retaining label list.) 1219 + if (pceStore.getTunnelInfo(tunnel.tunnelId()) != null) {
1194 - PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); 1220 + pceStore.removeTunnelInfo(tunnel.tunnelId());
1195 - pceccTunnelInfo.tunnelConsumerId(null);
1196 - if (mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) {
1197 - crHandler.releaseLabel(tunnel);
1198 - }
1199 - } else {
1200 - pceStore.removeTunnelInfo(tunnel.tunnelId());
1201 - }
1202 } 1221 }
1222 +
1203 break; 1223 break;
1204 1224
1205 default: 1225 default:
......
...@@ -44,6 +44,7 @@ import org.onosproject.pce.pceservice.constraint.CapabilityConstraint; ...@@ -44,6 +44,7 @@ import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
44 import org.onosproject.pce.pceservice.constraint.CostConstraint; 44 import org.onosproject.pce.pceservice.constraint.CostConstraint;
45 import org.onosproject.pce.pceservice.TunnelConsumerId; 45 import org.onosproject.pce.pceservice.TunnelConsumerId;
46 import org.onosproject.pce.pceservice.LspType; 46 import org.onosproject.pce.pceservice.LspType;
47 +import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint;
47 import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; 48 import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
48 import org.onosproject.pce.pcestore.api.PceStore; 49 import org.onosproject.pce.pcestore.api.PceStore;
49 import org.onosproject.store.serializers.KryoNamespaces; 50 import org.onosproject.store.serializers.KryoNamespaces;
...@@ -142,6 +143,7 @@ public class DistributedPceStore implements PceStore { ...@@ -142,6 +143,7 @@ public class DistributedPceStore implements PceStore {
142 CostConstraint.class, 143 CostConstraint.class,
143 CostConstraint.Type.class, 144 CostConstraint.Type.class,
144 BandwidthConstraint.class, 145 BandwidthConstraint.class,
146 + SharedBandwidthConstraint.class,
145 CapabilityConstraint.class, 147 CapabilityConstraint.class,
146 CapabilityConstraint.CapabilityType.class, 148 CapabilityConstraint.CapabilityType.class,
147 LspType.class) 149 LspType.class)
......
...@@ -115,8 +115,8 @@ public final class PceccTunnelInfo { ...@@ -115,8 +115,8 @@ public final class PceccTunnelInfo {
115 public String toString() { 115 public String toString() {
116 return MoreObjects.toStringHelper(getClass()) 116 return MoreObjects.toStringHelper(getClass())
117 .omitNullValues() 117 .omitNullValues()
118 - .add("DeviceLabelInfoList", lspLocalLabelInfoList.toString()) 118 + .add("DeviceLabelInfoList", lspLocalLabelInfoList)
119 - .add("TunnelConsumerId", tunnelConsumerId.toString()) 119 + .add("TunnelConsumerId", tunnelConsumerId)
120 .toString(); 120 .toString();
121 } 121 }
122 } 122 }
......
...@@ -641,6 +641,8 @@ public class PceManagerTest { ...@@ -641,6 +641,8 @@ public class PceManagerTest {
641 build4RouterTopo(false, false, false, false, 5); 641 build4RouterTopo(false, false, false, false, 5);
642 List<Constraint> constraints = new LinkedList<Constraint>(); 642 List<Constraint> constraints = new LinkedList<Constraint>();
643 CostConstraint costConstraint = new CostConstraint(TE_COST); 643 CostConstraint costConstraint = new CostConstraint(TE_COST);
644 + BandwidthConstraint bwConst = new BandwidthConstraint(Bandwidth.bps(3));
645 + constraints.add(bwConst);
644 constraints.add(costConstraint); 646 constraints.add(costConstraint);
645 647
646 pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING); 648 pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING);
......
...@@ -61,7 +61,7 @@ public class BgpMessageDecoder extends FrameDecoder { ...@@ -61,7 +61,7 @@ public class BgpMessageDecoder extends FrameDecoder {
61 BgpMessage message = reader.readFrom(buffer, bgpHeader); 61 BgpMessage message = reader.readFrom(buffer, bgpHeader);
62 msgList.add(message); 62 msgList.add(message);
63 } 63 }
64 - 64 + ctx.setAttachment(null);
65 return msgList; 65 return msgList;
66 } catch (Exception e) { 66 } catch (Exception e) {
67 log.debug("Bgp protocol message decode error"); 67 log.debug("Bgp protocol message decode error");
......
...@@ -279,7 +279,7 @@ public class PcepLabelUpdateVer1 implements PcepLabelUpdate { ...@@ -279,7 +279,7 @@ public class PcepLabelUpdateVer1 implements PcepLabelUpdate {
279 } 279 }
280 280
281 llLabelList = labelDownload.getLabelList(); 281 llLabelList = labelDownload.getLabelList();
282 - if (llLabelList == null) { 282 + if (llLabelList == null || llLabelList.isEmpty()) {
283 throw new PcepParseException("Label list is mandatory object for Label Download."); 283 throw new PcepParseException("Label list is mandatory object for Label Download.");
284 } else { 284 } else {
285 ListIterator<PcepLabelObject> listIterator = llLabelList.listIterator(); 285 ListIterator<PcepLabelObject> listIterator = llLabelList.listIterator();
......
...@@ -63,8 +63,6 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; ...@@ -63,8 +63,6 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
63 import org.onosproject.core.CoreService; 63 import org.onosproject.core.CoreService;
64 import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; 64 import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
65 import org.onosproject.incubator.net.resource.label.LabelResourceId; 65 import org.onosproject.incubator.net.resource.label.LabelResourceId;
66 -import org.onosproject.mastership.MastershipEvent;
67 -import org.onosproject.mastership.MastershipListener;
68 import org.onosproject.mastership.MastershipService; 66 import org.onosproject.mastership.MastershipService;
69 import org.onosproject.net.AnnotationKeys; 67 import org.onosproject.net.AnnotationKeys;
70 import org.onosproject.net.ConnectPoint; 68 import org.onosproject.net.ConnectPoint;
...@@ -79,6 +77,8 @@ import org.onosproject.net.config.basics.BandwidthCapacity; ...@@ -79,6 +77,8 @@ import org.onosproject.net.config.basics.BandwidthCapacity;
79 import org.onosproject.net.device.DefaultDeviceDescription; 77 import org.onosproject.net.device.DefaultDeviceDescription;
80 import org.onosproject.net.device.DefaultPortDescription; 78 import org.onosproject.net.device.DefaultPortDescription;
81 import org.onosproject.net.device.DeviceDescription; 79 import org.onosproject.net.device.DeviceDescription;
80 +import org.onosproject.net.device.DeviceEvent;
81 +import org.onosproject.net.device.DeviceListener;
82 import org.onosproject.net.device.DeviceProvider; 82 import org.onosproject.net.device.DeviceProvider;
83 import org.onosproject.net.device.DeviceProviderRegistry; 83 import org.onosproject.net.device.DeviceProviderRegistry;
84 import org.onosproject.net.device.DeviceProviderService; 84 import org.onosproject.net.device.DeviceProviderService;
...@@ -140,7 +140,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi ...@@ -140,7 +140,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
140 private DeviceProviderService deviceProviderService; 140 private DeviceProviderService deviceProviderService;
141 private LinkProviderService linkProviderService; 141 private LinkProviderService linkProviderService;
142 142
143 - private InternalMastershipListener masterListener = new InternalMastershipListener(); 143 + private DeviceListener deviceListener = new InternalDeviceListener();
144 private InternalBgpProvider listener = new InternalBgpProvider(); 144 private InternalBgpProvider listener = new InternalBgpProvider();
145 private static final String UNKNOWN = "unknown"; 145 private static final String UNKNOWN = "unknown";
146 public static final long IDENTIFIER_SET = 0x100000000L; 146 public static final long IDENTIFIER_SET = 0x100000000L;
...@@ -169,7 +169,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi ...@@ -169,7 +169,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
169 deviceProviderService = deviceProviderRegistry.register(this); 169 deviceProviderService = deviceProviderRegistry.register(this);
170 linkProviderService = linkProviderRegistry.register(this); 170 linkProviderService = linkProviderRegistry.register(this);
171 controller.addListener(listener); 171 controller.addListener(listener);
172 - mastershipService.addListener(masterListener); 172 + deviceService.addListener(deviceListener);
173 controller.addLinkListener(listener); 173 controller.addLinkListener(listener);
174 } 174 }
175 175
...@@ -182,25 +182,28 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi ...@@ -182,25 +182,28 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
182 linkProviderService = null; 182 linkProviderService = null;
183 controller.removeListener(listener); 183 controller.removeListener(listener);
184 controller.removeLinkListener(listener); 184 controller.removeLinkListener(listener);
185 - mastershipService.removeListener(masterListener); 185 + deviceService.removeListener(deviceListener);
186 } 186 }
187 187
188 - private class InternalMastershipListener implements MastershipListener { 188 + private class InternalDeviceListener implements DeviceListener {
189 @Override 189 @Override
190 - public void event(MastershipEvent event) { 190 + public void event(DeviceEvent event) {
191 - if (event.type() == MastershipEvent.Type.MASTER_CHANGED) { 191 + Device device = event.subject();
192 - if (mastershipService.getMasterFor(event.subject()) != null) { 192 +
193 - //Only for L3 device create label pool for that device 193 + switch (event.type()) {
194 - Device device = deviceService.getDevice(event.subject()); 194 + case DEVICE_ADDED:
195 - if (device == null) { 195 + if (!mastershipService.isLocalMaster(device.id())) {
196 - log.debug("Device {} doesn't exist", event.subject()); 196 + break;
197 - return;
198 } 197 }
199 - //Reserve device label pool for L3 devices 198 +
199 + // Reserve device label pool for L3 devices
200 if (device.annotations().value(LSRID) != null) { 200 if (device.annotations().value(LSRID) != null) {
201 - createDevicePool(event.subject()); 201 + createDevicePool(device.id());
202 } 202 }
203 - } 203 + break;
204 +
205 + default:
206 + break;
204 } 207 }
205 } 208 }
206 } 209 }
...@@ -460,6 +463,10 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi ...@@ -460,6 +463,10 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
460 } 463 }
461 464
462 linkProviderService.linkVanished(linkDes); 465 linkProviderService.linkVanished(linkDes);
466 +
467 + linkDes = new DefaultLinkDescription(linkDes.dst(), linkDes.src(), Link.Type.DIRECT,
468 + false, linkDes.annotations());
469 + linkProviderService.linkVanished(linkDes);
463 } 470 }
464 } 471 }
465 472
......
...@@ -53,10 +53,7 @@ import org.onosproject.bgpio.types.LinkStateAttributes; ...@@ -53,10 +53,7 @@ import org.onosproject.bgpio.types.LinkStateAttributes;
53 import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; 53 import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
54 import org.onosproject.incubator.net.resource.label.LabelResourceId; 54 import org.onosproject.incubator.net.resource.label.LabelResourceId;
55 import org.onosproject.incubator.net.resource.label.LabelResourcePool; 55 import org.onosproject.incubator.net.resource.label.LabelResourcePool;
56 -import org.onosproject.mastership.MastershipEvent;
57 -import org.onosproject.mastership.MastershipListener;
58 import org.onosproject.mastership.MastershipServiceAdapter; 56 import org.onosproject.mastership.MastershipServiceAdapter;
59 -import org.onosproject.mastership.MastershipEvent.Type;
60 import org.onosproject.net.link.LinkServiceAdapter; 57 import org.onosproject.net.link.LinkServiceAdapter;
61 import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; 58 import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv;
62 import org.onosproject.bgpio.types.RouteDistinguisher; 59 import org.onosproject.bgpio.types.RouteDistinguisher;
...@@ -68,8 +65,8 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth; ...@@ -68,8 +65,8 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
68 import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; 65 import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
69 import org.onosproject.bgpio.util.Constants; 66 import org.onosproject.bgpio.util.Constants;
70 import org.onosproject.cluster.NodeId; 67 import org.onosproject.cluster.NodeId;
71 -import org.onosproject.cluster.RoleInfo;
72 import org.onosproject.net.ConnectPoint; 68 import org.onosproject.net.ConnectPoint;
69 +import org.onosproject.net.DefaultAnnotations;
73 import org.onosproject.net.DefaultDevice; 70 import org.onosproject.net.DefaultDevice;
74 import org.onosproject.net.DefaultLink; 71 import org.onosproject.net.DefaultLink;
75 import org.onosproject.net.Device; 72 import org.onosproject.net.Device;
...@@ -81,8 +78,9 @@ import org.onosproject.net.config.Config; ...@@ -81,8 +78,9 @@ import org.onosproject.net.config.Config;
81 import org.onosproject.net.config.ConfigApplyDelegate; 78 import org.onosproject.net.config.ConfigApplyDelegate;
82 import org.onosproject.net.config.ConfigFactory; 79 import org.onosproject.net.config.ConfigFactory;
83 import org.onosproject.net.config.NetworkConfigRegistryAdapter; 80 import org.onosproject.net.config.NetworkConfigRegistryAdapter;
84 -import org.onosproject.net.config.basics.BandwidthCapacity;
85 import org.onosproject.net.device.DeviceDescription; 81 import org.onosproject.net.device.DeviceDescription;
82 +import org.onosproject.net.device.DeviceEvent;
83 +import org.onosproject.net.device.DeviceListener;
86 import org.onosproject.net.device.DeviceProvider; 84 import org.onosproject.net.device.DeviceProvider;
87 import org.onosproject.net.device.DeviceProviderRegistry; 85 import org.onosproject.net.device.DeviceProviderRegistry;
88 import org.onosproject.net.device.DeviceProviderService; 86 import org.onosproject.net.device.DeviceProviderService;
...@@ -94,6 +92,7 @@ import org.onosproject.net.link.LinkProvider; ...@@ -94,6 +92,7 @@ import org.onosproject.net.link.LinkProvider;
94 import org.onosproject.net.link.LinkProviderRegistry; 92 import org.onosproject.net.link.LinkProviderRegistry;
95 import org.onosproject.net.link.LinkProviderService; 93 import org.onosproject.net.link.LinkProviderService;
96 import org.onosproject.net.provider.ProviderId; 94 import org.onosproject.net.provider.ProviderId;
95 +import org.onosproject.net.config.basics.BandwidthCapacity;
97 import org.onosproject.net.resource.Resource; 96 import org.onosproject.net.resource.Resource;
98 import org.onosproject.net.resource.ResourceAdminService; 97 import org.onosproject.net.resource.ResourceAdminService;
99 import org.onosproject.net.resource.ResourceId; 98 import org.onosproject.net.resource.ResourceId;
...@@ -122,7 +121,7 @@ public class BgpTopologyProviderTest { ...@@ -122,7 +121,7 @@ public class BgpTopologyProviderTest {
122 private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter(); 121 private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter();
123 private MockLabelResourceService labelResourceAdminService = new MockLabelResourceService(); 122 private MockLabelResourceService labelResourceAdminService = new MockLabelResourceService();
124 private Map<DeviceId, Device> deviceMap = new HashMap<>(); 123 private Map<DeviceId, Device> deviceMap = new HashMap<>();
125 - private MastershipListener listener; 124 + private DeviceListener listener;
126 125
127 @Before 126 @Before
128 public void startUp() throws TestUtilsException { 127 public void startUp() throws TestUtilsException {
...@@ -134,7 +133,7 @@ public class BgpTopologyProviderTest { ...@@ -134,7 +133,7 @@ public class BgpTopologyProviderTest {
134 provider.labelResourceAdminService = labelResourceAdminService; 133 provider.labelResourceAdminService = labelResourceAdminService;
135 provider.mastershipService = mastershipService; 134 provider.mastershipService = mastershipService;
136 provider.networkConfigService = networkConfigService; 135 provider.networkConfigService = networkConfigService;
137 - listener = TestUtils.getField(provider, "masterListener"); 136 + listener = TestUtils.getField(provider, "deviceListener");
138 provider.activate(); 137 provider.activate();
139 assertThat("device provider should be registered", not(nodeRegistry.provider)); 138 assertThat("device provider should be registered", not(nodeRegistry.provider));
140 assertThat("link provider should be registered", not(linkRegistry.linkProvider)); 139 assertThat("link provider should be registered", not(linkRegistry.linkProvider));
...@@ -887,10 +886,14 @@ public class BgpTopologyProviderTest { ...@@ -887,10 +886,14 @@ public class BgpTopologyProviderTest {
887 l.addNode(nodeNlri, details); 886 l.addNode(nodeNlri, details);
888 assertThat(nodeRegistry.connected.size(), is(1)); 887 assertThat(nodeRegistry.connected.size(), is(1));
889 } 888 }
889 + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
890 +
891 + newBuilder.set("lsrId", "1.1.1.1");
890 892
891 - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), 893 + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, nodeRegistry.connected.iterator().next(),
892 - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); 894 + Device.Type.ROUTER, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build());
893 895
896 + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
894 listener.event(event); 897 listener.event(event);
895 assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); 898 assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
896 } 899 }
...@@ -926,9 +929,16 @@ public class BgpTopologyProviderTest { ...@@ -926,9 +929,16 @@ public class BgpTopologyProviderTest {
926 for (BgpNodeListener l : controller.nodeListener) { 929 for (BgpNodeListener l : controller.nodeListener) {
927 l.addNode(nodeNlri, details); 930 l.addNode(nodeNlri, details);
928 assertThat(nodeRegistry.connected.size(), is(1)); 931 assertThat(nodeRegistry.connected.size(), is(1));
929 - // Check label resource reserved for that device 932 +
930 - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), 933 + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
931 - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); 934 +
935 + newBuilder.set("lsrId", "1.1.1.1");
936 +
937 + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId,
938 + nodeRegistry.connected.iterator().next(), Device.Type.ROUTER, UNKNOWN,
939 + UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build());
940 +
941 + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
932 listener.event(event); 942 listener.event(event);
933 assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); 943 assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
934 944
...@@ -988,8 +998,15 @@ public class BgpTopologyProviderTest { ...@@ -988,8 +998,15 @@ public class BgpTopologyProviderTest {
988 l.addNode(nodeNlri, details); 998 l.addNode(nodeNlri, details);
989 assertThat(nodeRegistry.connected.size(), is(1)); 999 assertThat(nodeRegistry.connected.size(), is(1));
990 //Check label resource reserved for that device 1000 //Check label resource reserved for that device
991 - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), 1001 + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
992 - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); 1002 +
1003 + newBuilder.set("lsrId", "1.1.1.1");
1004 +
1005 + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId,
1006 + nodeRegistry.connected.iterator().next(), Device.Type.ROUTER,
1007 + UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build());
1008 +
1009 + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
993 listener.event(event); 1010 listener.event(event);
994 assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); 1011 assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
995 l.addNode(remNodeNlri, details); 1012 l.addNode(remNodeNlri, details);
......
...@@ -449,28 +449,30 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -449,28 +449,30 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
449 return; 449 return;
450 } 450 }
451 451
452 - // If delegation flag is set then only send update message[means delegated PCE can send update msg for that
453 - // LSP].If annotation is null D flag is not set else it is set.
454 - Short localLspId = 0;
455 - for (Tunnel t : tunnels) {
456 - if (!t.tunnelId().equals(tunnel.tunnelId()) && t.tunnelName().equals(tunnel.tunnelName())) {
457 - localLspId = Short.valueOf(t.annotations().value(LOCAL_LSP_ID));
458 - }
459 - }
460 -
461 - if (localLspId == 0) {
462 - log.error("Local LSP ID for old tunnel not found");
463 - return;
464 - }
465 -
466 //PCInitiate tunnels are always have D flag set, else check for tunnels who are delegated via LspKey 452 //PCInitiate tunnels are always have D flag set, else check for tunnels who are delegated via LspKey
467 if (pc.capability().statefulPceCapability()) { 453 if (pc.capability().statefulPceCapability()) {
468 if (tunnel.annotations().value(PCE_INIT) != null && tunnel.annotations().value(PCE_INIT).equals("true")) { 454 if (tunnel.annotations().value(PCE_INIT) != null && tunnel.annotations().value(PCE_INIT).equals("true")) {
469 pcepUpdateTunnel(tunnel, path, pc); 455 pcepUpdateTunnel(tunnel, path, pc);
470 - } else if (pc.delegationInfo( 456 + } else {
471 - new LspKey(Integer.valueOf(tunnel.annotations().value(PLSP_ID)), 457 + // If delegation flag is set then only send update message[means delegated PCE can send update msg for
472 - localLspId.shortValue())) != null) { 458 + // that LSP. If annotation is null D flag is not set else it is set.
473 - pcepUpdateTunnel(tunnel, path, pc); 459 + Short localLspId = 0;
460 + for (Tunnel t : tunnels) {
461 + if (!t.tunnelId().equals(tunnel.tunnelId()) && t.tunnelName().equals(tunnel.tunnelName())) {
462 + localLspId = Short.valueOf(t.annotations().value(LOCAL_LSP_ID));
463 + }
464 + }
465 +
466 + if (localLspId == 0) {
467 + log.error("Local LSP ID for old tunnel not found");
468 + return;
469 + }
470 +
471 + if (pc.delegationInfo(new LspKey(Integer.valueOf(tunnel.annotations().value(PLSP_ID)),
472 + localLspId.shortValue())) != null) {
473 +
474 + pcepUpdateTunnel(tunnel, path, pc);
475 + }
474 } 476 }
475 } 477 }
476 } 478 }
...@@ -571,18 +573,22 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -571,18 +573,22 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
571 return tunnelId; 573 return tunnelId;
572 } 574 }
573 575
574 - private void tunnelUpdated(Tunnel tunnel, Path path) { 576 + private void tunnelUpdated(Tunnel tunnel, Path path, State tunnelState) {
575 - handleTunnelUpdate(tunnel, path); 577 + handleTunnelUpdate(tunnel, path, tunnelState);
576 } 578 }
577 579
578 //Handles tunnel updated using tunnel admin service[specially to update annotations]. 580 //Handles tunnel updated using tunnel admin service[specially to update annotations].
579 - private void handleTunnelUpdate(Tunnel tunnel, Path path) { 581 + private void handleTunnelUpdate(Tunnel tunnel, Path path, State tunnelState) {
580 582
581 if (tunnel.type() == MPLS) { 583 if (tunnel.type() == MPLS) {
582 pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.tunnelId()); 584 pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.tunnelId());
583 585
584 - tunnelAdminService.updateTunnel(tunnel, path); 586 + TunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(),
587 + tunnel.type(), tunnel.groupId(), tunnel.providerId(),
588 + tunnel.tunnelName(), path, tunnel.resource(),
589 + (SparseAnnotations) tunnel.annotations());
585 590
591 + service.tunnelUpdated(td, tunnelState);
586 return; 592 return;
587 } 593 }
588 594
...@@ -1059,7 +1065,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1059,7 +1065,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1059 tunnel.path(), 1065 tunnel.path(),
1060 tunnel.resource(), 1066 tunnel.resource(),
1061 tunnel.annotations()); 1067 tunnel.annotations());
1062 - break; 1068 + break;
1063 } 1069 }
1064 } 1070 }
1065 1071
...@@ -1238,14 +1244,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1238,14 +1244,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1238 tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); 1244 tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
1239 llOptionalTlv.add(tlv); 1245 llOptionalTlv.add(tlv);
1240 } 1246 }
1241 -
1242 boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false 1247 boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false
1243 : Boolean.valueOf(tunnel.annotations() 1248 : Boolean.valueOf(tunnel.annotations()
1244 .value(DELEGATE)); 1249 .value(DELEGATE));
1245 boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false 1250 boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false
1246 : Boolean.valueOf(tunnel.annotations() 1251 : Boolean.valueOf(tunnel.annotations()
1247 .value(PCE_INIT)); 1252 .value(PCE_INIT));
1248 -
1249 // build lsp object 1253 // build lsp object
1250 PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true) 1254 PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true)
1251 .setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID))) 1255 .setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID)))
...@@ -1254,7 +1258,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1254,7 +1258,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1254 .setOptionalTlv(llOptionalTlv).build(); 1258 .setOptionalTlv(llOptionalTlv).build();
1255 // build ero object 1259 // build ero object
1256 PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); 1260 PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build();
1257 -
1258 float iBandwidth = DEFAULT_BANDWIDTH_VALUE; 1261 float iBandwidth = DEFAULT_BANDWIDTH_VALUE;
1259 if (tunnel.annotations().value(BANDWIDTH) != null) { 1262 if (tunnel.annotations().value(BANDWIDTH) != null) {
1260 iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); 1263 iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH));
...@@ -1449,10 +1452,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1449,10 +1452,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1449 } 1452 }
1450 1453
1451 private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv, 1454 private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv,
1452 - float bandwidth, LspType lspType, String costType) { 1455 + String bandwidth, LspType lspType, String costType, boolean isPceInit) {
1453 -
1454 Builder builder = DefaultAnnotations.builder(); 1456 Builder builder = DefaultAnnotations.builder();
1455 -
1456 /* 1457 /*
1457 * [RFC 5440] The absence of the METRIC object MUST be interpreted by the PCE as a path computation request 1458 * [RFC 5440] The absence of the METRIC object MUST be interpreted by the PCE as a path computation request
1458 * for which no constraints need be applied to any of the metrics. 1459 * for which no constraints need be applied to any of the metrics.
...@@ -1461,8 +1462,16 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1461,8 +1462,16 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1461 builder.set(COST_TYPE, costType); 1462 builder.set(COST_TYPE, costType);
1462 } 1463 }
1463 1464
1465 + if (isPceInit) {
1466 + builder.set(PCE_INIT, String.valueOf(isPceInit));
1467 + }
1468 +
1469 + if (bandwidth != null) {
1470 + builder.set(BANDWIDTH, bandwidth);
1471 + }
1472 +
1464 SparseAnnotations annotations = builder 1473 SparseAnnotations annotations = builder
1465 - .set(BANDWIDTH, (new Float(bandwidth)).toString()).set(LSP_SIG_TYPE, lspType.name()) 1474 + .set(LSP_SIG_TYPE, lspType.name())
1466 .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId())) 1475 .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId()))
1467 .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) 1476 .set(PLSP_ID, String.valueOf(lspObj.getPlspId()))
1468 .set(LOCAL_LSP_ID, String.valueOf(ipv4LspIdenTlv.getLspId())) 1477 .set(LOCAL_LSP_ID, String.valueOf(ipv4LspIdenTlv.getLspId()))
...@@ -1502,7 +1511,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1502,7 +1511,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1502 log.error("ERO object is null in report message."); 1511 log.error("ERO object is null in report message.");
1503 return; 1512 return;
1504 } 1513 }
1505 -
1506 PcepAttribute attributes = msgPath.getPcepAttribute(); 1514 PcepAttribute attributes = msgPath.getPcepAttribute();
1507 float bandwidth = 0; 1515 float bandwidth = 0;
1508 int cost = 0; 1516 int cost = 0;
...@@ -1529,6 +1537,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1529,6 +1537,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1529 bandwidth = attributes.getBandwidthObject().getBandwidth(); 1537 bandwidth = attributes.getBandwidthObject().getBandwidth();
1530 } 1538 }
1531 } 1539 }
1540 + PcepLspObject lspObj = stateRpt.getLspObject();
1532 List<Object> eroSubObjList = buildPathFromEroObj(eroObj, providerId); 1541 List<Object> eroSubObjList = buildPathFromEroObj(eroObj, providerId);
1533 List<Link> links = new ArrayList<>(); 1542 List<Link> links = new ArrayList<>();
1534 List<LabelResourceId> labels = new ArrayList<>(); 1543 List<LabelResourceId> labels = new ArrayList<>();
...@@ -1539,18 +1548,20 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1539,18 +1548,20 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1539 labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue())); 1548 labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue()));
1540 } 1549 }
1541 } 1550 }
1542 - Path path = new DefaultPath(providerId, links, cost, EMPTY); 1551 + Path path = null;
1552 + if (!links.isEmpty()) {
1553 + path = new DefaultPath(providerId, links, cost, EMPTY);
1554 + } else if (!lspObj.getRFlag()) {
1555 + return;
1556 + }
1543 NetworkResource labelStack = new DefaultLabelStack(labels); 1557 NetworkResource labelStack = new DefaultLabelStack(labels);
1544 // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action 1558 // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action
1545 // from PCE. 1559 // from PCE.
1546 PcepSrpObject srpObj = stateRpt.getSrpObject(); 1560 PcepSrpObject srpObj = stateRpt.getSrpObject();
1547 LspType lspType = getLspType(srpObj); 1561 LspType lspType = getLspType(srpObj);
1548 -
1549 - PcepLspObject lspObj = stateRpt.getLspObject();
1550 ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); 1562 ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator();
1551 StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null; 1563 StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null;
1552 SymbolicPathNameTlv pathNameTlv = null; 1564 SymbolicPathNameTlv pathNameTlv = null;
1553 -
1554 while (listTlvIterator.hasNext()) { 1565 while (listTlvIterator.hasNext()) {
1555 PcepValueType tlv = listTlvIterator.next(); 1566 PcepValueType tlv = listTlvIterator.next();
1556 switch (tlv.getType()) { 1567 switch (tlv.getType()) {
...@@ -1577,7 +1588,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1577,7 +1588,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1577 IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint 1588 IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint
1578 .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4EgressAddress())); 1589 .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4EgressAddress()));
1579 Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst); 1590 Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst);
1580 -
1581 // Store delegation flag info and that LSP info because only delegated PCE sends update message 1591 // Store delegation flag info and that LSP info because only delegated PCE sends update message
1582 // Storing if D flag is set, if not dont store. while checking whether delegation if annotation for D flag 1592 // Storing if D flag is set, if not dont store. while checking whether delegation if annotation for D flag
1583 // not present then non-delegated , if present it is delegated. 1593 // not present then non-delegated , if present it is delegated.
...@@ -1586,6 +1596,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1586,6 +1596,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1586 new LspKey(lspObj.getPlspId(), ipv4LspIdenTlv.getLspId()), lspObj.getDFlag()); 1596 new LspKey(lspObj.getPlspId(), ipv4LspIdenTlv.getLspId()), lspObj.getDFlag());
1587 } 1597 }
1588 Tunnel tunnel = null; 1598 Tunnel tunnel = null;
1599 + SparseAnnotations oldTunnelAnnotations = null;
1589 // Asynchronous status change message from PCC for LSP reported earlier. 1600 // Asynchronous status change message from PCC for LSP reported earlier.
1590 for (Tunnel tunnelObj : tunnelQueryResult) { 1601 for (Tunnel tunnelObj : tunnelQueryResult) {
1591 if (tunnelObj.annotations().value(PLSP_ID) == null) { 1602 if (tunnelObj.annotations().value(PLSP_ID) == null) {
...@@ -1603,13 +1614,17 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1603,13 +1614,17 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1603 } 1614 }
1604 continue; 1615 continue;
1605 } 1616 }
1606 - if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId()) && (Integer 1617 + if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId())) {
1607 - .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) { 1618 + if ((Integer
1608 - tunnel = tunnelObj; 1619 + .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) {
1609 - break; 1620 + tunnel = tunnelObj;
1621 + }
1622 + if ((Integer
1623 + .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) != ipv4LspIdenTlv.getLspId())) {
1624 + oldTunnelAnnotations = (SparseAnnotations) tunnelObj.annotations();
1625 + }
1610 } 1626 }
1611 } 1627 }
1612 -
1613 DefaultTunnelDescription td; 1628 DefaultTunnelDescription td;
1614 SparseAnnotations annotations = null; 1629 SparseAnnotations annotations = null;
1615 State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); 1630 State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]);
...@@ -1621,24 +1636,27 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1621,24 +1636,27 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1621 */ 1636 */
1622 return; 1637 return;
1623 } 1638 }
1624 -
1625 DeviceId deviceId = getDevice(pccId); 1639 DeviceId deviceId = getDevice(pccId);
1626 if (deviceId == null) { 1640 if (deviceId == null) {
1627 log.error("Ingress deviceId not found"); 1641 log.error("Ingress deviceId not found");
1628 return; 1642 return;
1629 } 1643 }
1630 - annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType); 1644 + String tempBandwidth = null;
1631 - 1645 + String temoCostType = null;
1646 + if (oldTunnelAnnotations != null) {
1647 + tempBandwidth = oldTunnelAnnotations.value(BANDWIDTH);
1648 + temoCostType = oldTunnelAnnotations.value(COST_TYPE);
1649 + }
1650 + annotations = getAnnotations(lspObj, ipv4LspIdenTlv, tempBandwidth, lspType,
1651 + temoCostType, lspObj.getCFlag());
1632 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( 1652 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
1633 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack, 1653 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack,
1634 annotations); 1654 annotations);
1635 -
1636 // Do not support PCC initiated LSP after LSP DB sync is completed. 1655 // Do not support PCC initiated LSP after LSP DB sync is completed.
1637 if (!lspObj.getSFlag() && !lspObj.getCFlag()) { 1656 if (!lspObj.getSFlag() && !lspObj.getCFlag()) {
1638 log.error("Received PCC initiated LSP while not in sync."); 1657 log.error("Received PCC initiated LSP while not in sync.");
1639 return; 1658 return;
1640 } 1659 }
1641 -
1642 /* 1660 /*
1643 * If ONOS instance is master for PCC then set delegated flag as annotation and add the tunnel to store. 1661 * If ONOS instance is master for PCC then set delegated flag as annotation and add the tunnel to store.
1644 * Because all LSPs need not be delegated, hence mastership for the PCC is confirmed whereas not the 1662 * Because all LSPs need not be delegated, hence mastership for the PCC is confirmed whereas not the
...@@ -1670,43 +1688,54 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1670,43 +1688,54 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1670 pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); 1688 pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
1671 } else if (!mastershipService.isLocalMaster(deviceId) && lspObj.getDFlag()) { 1689 } else if (!mastershipService.isLocalMaster(deviceId) && lspObj.getDFlag()) {
1672 //Start timer then update the tunnel with D flag 1690 //Start timer then update the tunnel with D flag
1673 - tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); 1691 + tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId, tunnelState, ipv4LspIdenTlv);
1674 } 1692 }
1675 return; 1693 return;
1676 } 1694 }
1677 -
1678 //delegated owner will update can be a master or non-master 1695 //delegated owner will update can be a master or non-master
1679 - if (lspObj.getDFlag()) { 1696 + if (lspObj.getDFlag() && !lspObj.getRFlag()) {
1680 - 1697 + tunnelUpdateForDelegatedLsp(tunnel, lspObj,
1681 - if (tunnel.annotations().value(BANDWIDTH) != null) { 1698 + lspType, tunnelState, pccId, labelStack, ipv4LspIdenTlv);
1682 - bandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); 1699 + return;
1683 - }
1684 - annotations = getAnnotations(lspObj, ipv4LspIdenTlv,
1685 - bandwidth, lspType,
1686 - tunnel.annotations().value(COST_TYPE));
1687 - td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
1688 - 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())),
1689 - tunnel.path(), labelStack, annotations);
1690 - tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId);
1691 } 1700 }
1692 - removeOrUpdatetunnel(tunnel, pccId, lspObj, providerId, tunnelState); 1701 + removeOrUpdatetunnel(tunnel, lspObj, providerId, tunnelState, ipv4LspIdenTlv);
1693 - return;
1694 } 1702 }
1695 1703
1696 - private void removeOrUpdatetunnel(Tunnel tunnel, PccId pccId, PcepLspObject lspObj, ProviderId providerId, 1704 + private void tunnelUpdateForDelegatedLsp(Tunnel tunnel, PcepLspObject lspObj,
1697 - State tunnelState) { 1705 + LspType lspType, State tunnelState, PccId pccId,
1706 + NetworkResource labelStack,
1707 + StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) {
1708 + SparseAnnotations annotations = null;
1709 + DefaultTunnelDescription td;
1710 + boolean isPceInit = tunnel.annotations().value(PCE_INIT) == null ? false :
1711 + Boolean.valueOf((tunnel.annotations().value(PCE_INIT))).booleanValue();
1712 + annotations = getAnnotations(lspObj, ipv4LspIdenTlv,
1713 + tunnel.annotations().value(BANDWIDTH), lspType,
1714 + tunnel.annotations().value(COST_TYPE), isPceInit);
1715 + td = new DefaultTunnelDescription(null, tunnel.src(), tunnel.dst(), MPLS, new DefaultGroupId(
1716 + 0), tunnel.providerId(), tunnel.tunnelName(),
1717 + tunnel.path(), labelStack, annotations);
1718 + tunnelUpdateInDelegatedCase(pccId, annotations, td, tunnel.providerId(), tunnelState, ipv4LspIdenTlv);
1719 + }
1720 +
1721 + private void removeOrUpdatetunnel(Tunnel tunnel, PcepLspObject lspObj, ProviderId providerId,
1722 + State tunnelState, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) {
1698 DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(), 1723 DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(),
1699 tunnel.type(), tunnel.groupId(), providerId, tunnel.tunnelName(), tunnel.path(), 1724 tunnel.type(), tunnel.groupId(), providerId, tunnel.tunnelName(), tunnel.path(),
1700 (SparseAnnotations) tunnel.annotations()); 1725 (SparseAnnotations) tunnel.annotations());
1701 if (lspObj.getRFlag()) { 1726 if (lspObj.getRFlag()) {
1702 tunnelRemoved(td); 1727 tunnelRemoved(td);
1703 } else { 1728 } else {
1729 + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, tunnel.path(), LSP_STATE_RPT);
1730 + pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv);
1731 + pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
1704 tunnelUpdated(td, tunnelState); 1732 tunnelUpdated(td, tunnelState);
1705 } 1733 }
1706 } 1734 }
1707 1735
1708 private void tunnelUpdateInDelegatedCase(PccId pccId, SparseAnnotations annotations, 1736 private void tunnelUpdateInDelegatedCase(PccId pccId, SparseAnnotations annotations,
1709 - DefaultTunnelDescription td, ProviderId providerId) { 1737 + DefaultTunnelDescription td, ProviderId providerId, State tunnelState,
1738 + StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv) {
1710 //Wait for 2sec then query tunnel based on ingress PLSP-ID and local LSP-ID 1739 //Wait for 2sec then query tunnel based on ingress PLSP-ID and local LSP-ID
1711 1740
1712 /* 1741 /*
...@@ -1717,7 +1746,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1717,7 +1746,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1717 1746
1718 // Thread is started after 2 seconds first time later periodically after 2 seconds to update the tunnel 1747 // Thread is started after 2 seconds first time later periodically after 2 seconds to update the tunnel
1719 executor.scheduleAtFixedRate(new UpdateDelegation(td, providerId, annotations, pccId, 1748 executor.scheduleAtFixedRate(new UpdateDelegation(td, providerId, annotations, pccId,
1720 - executor), DELAY, DELAY, TimeUnit.SECONDS); 1749 + executor, tunnelState, ipv4LspIdentifiersTlv), DELAY, DELAY, TimeUnit.SECONDS);
1721 } 1750 }
1722 1751
1723 /** 1752 /**
...@@ -1733,7 +1762,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1733,7 +1762,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1733 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); 1762 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects();
1734 if (0 == llSubObj.size()) { 1763 if (0 == llSubObj.size()) {
1735 log.error("ERO in report message does not have hop information"); 1764 log.error("ERO in report message does not have hop information");
1736 - return null; 1765 + return new ArrayList<>();
1737 } 1766 }
1738 ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); 1767 ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator();
1739 1768
...@@ -1787,10 +1816,29 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1787,10 +1816,29 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1787 1816
1788 if (srEroSubObj.getSt() == PcepNaiIpv4Adjacency.ST_TYPE) { 1817 if (srEroSubObj.getSt() == PcepNaiIpv4Adjacency.ST_TYPE) {
1789 PcepNaiIpv4Adjacency nai = (PcepNaiIpv4Adjacency) (srEroSubObj.getNai()); 1818 PcepNaiIpv4Adjacency nai = (PcepNaiIpv4Adjacency) (srEroSubObj.getNai());
1790 - IpAddress srcIp = IpAddress.valueOf(nai.getLocalIpv4Addr()); 1819 + int srcIp = nai.getLocalIpv4Addr();
1791 - src = new ConnectPoint(IpElementId.ipElement(srcIp), PortNumber.portNumber(0)); 1820 + int dstIp = nai.getRemoteIpv4Addr();
1792 - IpAddress dstIp = IpAddress.valueOf(nai.getRemoteIpv4Addr()); 1821 + Iterable<Link> links = linkService.getActiveLinks();
1793 - dst = new ConnectPoint(IpElementId.ipElement(dstIp), PortNumber.portNumber(0)); 1822 + for (Link l : links) {
1823 + long lSrc = l.src().port().toLong();
1824 + long lDst = l.dst().port().toLong();
1825 + if (lSrc == srcIp) {
1826 + src = l.src();
1827 + } else if (lDst == srcIp) {
1828 + src = l.dst();
1829 + }
1830 + if (lSrc == dstIp) {
1831 + dst = l.src();
1832 + } else if (lDst == dstIp) {
1833 + dst = l.dst();
1834 + }
1835 + if (src != null && dst != null) {
1836 + break;
1837 + }
1838 + }
1839 + if (src == null || dst == null) {
1840 + return new ArrayList<>();
1841 + }
1794 Link link = DefaultLink.builder() 1842 Link link = DefaultLink.builder()
1795 .providerId(providerId) 1843 .providerId(providerId)
1796 .src(src) 1844 .src(src)
...@@ -1803,7 +1851,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1803,7 +1851,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1803 // the other sub objects are not required 1851 // the other sub objects are not required
1804 } 1852 }
1805 } 1853 }
1806 -
1807 return subObjList; 1854 return subObjList;
1808 } 1855 }
1809 1856
...@@ -1861,7 +1908,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1861,7 +1908,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1861 return service.tunnelQueryById(tunnelId); 1908 return service.tunnelQueryById(tunnelId);
1862 } 1909 }
1863 1910
1864 -
1865 private DeviceId getDevice(PccId pccId) { 1911 private DeviceId getDevice(PccId pccId) {
1866 // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID. 1912 // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
1867 IpAddress lsrId = pccId.ipAddress(); 1913 IpAddress lsrId = pccId.ipAddress();
...@@ -1888,6 +1934,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1888,6 +1934,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1888 SparseAnnotations annotations; 1934 SparseAnnotations annotations;
1889 PccId pccId; 1935 PccId pccId;
1890 ScheduledExecutorService executor; 1936 ScheduledExecutorService executor;
1937 + State tunnelState;
1938 + StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv;
1891 1939
1892 /** 1940 /**
1893 * Creates an instance of UpdateDelegation. 1941 * Creates an instance of UpdateDelegation.
...@@ -1899,12 +1947,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1899,12 +1947,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1899 * @param executor service of delegated owner 1947 * @param executor service of delegated owner
1900 */ 1948 */
1901 public UpdateDelegation(DefaultTunnelDescription td, ProviderId providerId, SparseAnnotations annotations, 1949 public UpdateDelegation(DefaultTunnelDescription td, ProviderId providerId, SparseAnnotations annotations,
1902 - PccId pccId, ScheduledExecutorService executor) { 1950 + PccId pccId, ScheduledExecutorService executor, State tunnelState,
1951 + StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv) {
1903 this.td = td; 1952 this.td = td;
1904 this.providerId = providerId; 1953 this.providerId = providerId;
1905 this.annotations = annotations; 1954 this.annotations = annotations;
1906 this.pccId = pccId; 1955 this.pccId = pccId;
1907 this.executor = executor; 1956 this.executor = executor;
1957 + this.tunnelState = tunnelState;
1958 + this.ipv4LspIdentifiersTlv = ipv4LspIdentifiersTlv;
1908 } 1959 }
1909 1960
1910 //Temporary using annotations later will use projection/network config service 1961 //Temporary using annotations later will use projection/network config service
...@@ -1930,7 +1981,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1930,7 +1981,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1930 if (tempTunnelId != null) { 1981 if (tempTunnelId != null) {
1931 Tunnel tunnel = new DefaultTunnel(providerId, td.src(), td.dst(), MPLS, new DefaultGroupId(0), 1982 Tunnel tunnel = new DefaultTunnel(providerId, td.src(), td.dst(), MPLS, new DefaultGroupId(0),
1932 tempTunnelId, td.tunnelName(), td.path(), annotations); 1983 tempTunnelId, td.tunnelName(), td.path(), annotations);
1933 - tunnelUpdated(tunnel, td.path()); 1984 + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, tunnel.path(), LSP_STATE_RPT);
1985 + pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdentifiersTlv);
1986 + pcepTunnelData.setLspDFlag(Boolean.valueOf(tunnel.annotations().value(DELEGATE)));
1987 + pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
1988 + tunnelUpdated(tunnel, td.path(), tunnelState);
1934 executor.shutdown(); 1989 executor.shutdown();
1935 try { 1990 try {
1936 executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS); 1991 executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS);
......
...@@ -36,6 +36,7 @@ import java.util.Collection; ...@@ -36,6 +36,7 @@ import java.util.Collection;
36 import java.util.Collections; 36 import java.util.Collections;
37 import java.util.HashMap; 37 import java.util.HashMap;
38 import java.util.HashSet; 38 import java.util.HashSet;
39 +import java.util.Iterator;
39 import java.util.LinkedList; 40 import java.util.LinkedList;
40 import java.util.List; 41 import java.util.List;
41 import java.util.concurrent.TimeUnit; 42 import java.util.concurrent.TimeUnit;
...@@ -237,6 +238,17 @@ public class PcepTunnelAddedTest { ...@@ -237,6 +238,17 @@ public class PcepTunnelAddedTest {
237 238
238 @Override 239 @Override
239 public void tunnelUpdated(TunnelDescription tunnel, State state) { 240 public void tunnelUpdated(TunnelDescription tunnel, State state) {
241 + TunnelId id = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
242 + Tunnel storedTunnel = new DefaultTunnel(ProviderId.NONE,
243 + tunnel.src(), tunnel.dst(),
244 + tunnel.type(),
245 + tunnel.groupId(),
246 + id,
247 + tunnel.tunnelName(),
248 + tunnel.path(),
249 + tunnel.resource(),
250 + tunnel.annotations());
251 + tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel);
240 } 252 }
241 253
242 @Override 254 @Override
...@@ -592,8 +604,11 @@ public class PcepTunnelAddedTest { ...@@ -592,8 +604,11 @@ public class PcepTunnelAddedTest {
592 604
593 controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); 605 controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message);
594 TimeUnit.MILLISECONDS.sleep(4000); 606 TimeUnit.MILLISECONDS.sleep(4000);
595 - assertThat(registry.tunnelIdCounter, is((long) 1)); 607 + assertThat(registry.tunnelIdCounter, is((long) 2));
596 - assertThat(tunnelService.tunnelIdAsKeyStore.values().iterator().next().annotations().value(DELEGATE), 608 +
609 + Iterator<Tunnel> iterator = tunnelService.tunnelIdAsKeyStore.values().iterator();
610 + iterator.next();
611 + assertThat(iterator.next().annotations().value(DELEGATE),
597 is("true")); 612 is("true"));
598 } 613 }
599 614
......