Committed by
Gerrit Code Review
[ONOS] cherry pick from onos1.6 to master all defects merges
Change-Id: I0ff6595a55b1104cf59a270ac2b10a7f831f6555
Showing
12 changed files
with
130 additions
and
76 deletions
| ... | @@ -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); | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -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 | ... | ... |
-
Please register or login to post a comment