Committed by
Gerrit Code Review
[ONOS-4843] [ONOS-4815]Tunnels are creating even though bandwidth not satisfied …
…for RSVP in resilience case Change-Id: Ia119620d285055b85f66815c144bcd22ef27f2e8
Showing
5 changed files
with
40 additions
and
36 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."); | ... | ... |
| ... | @@ -508,7 +508,7 @@ public class PceManager implements PceService { | ... | @@ -508,7 +508,7 @@ public class PceManager implements PceService { |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | if (existingBwValue != null) { | 510 | if (existingBwValue != null) { |
| 511 | - if (bwConstraintValue == 0) { | 511 | + if (bwConstraintValue == 0 && bwConstraint != null) { |
| 512 | bwConstraintValue = existingBwValue.bps(); | 512 | bwConstraintValue = existingBwValue.bps(); |
| 513 | } | 513 | } |
| 514 | //If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation | 514 | //If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation |
| ... | @@ -862,7 +862,12 @@ public class PceManager implements PceService { | ... | @@ -862,7 +862,12 @@ public class PceManager implements PceService { |
| 862 | // 1. Release old tunnel's bandwidth. | 862 | // 1. Release old tunnel's bandwidth. |
| 863 | resourceService.release(pceStore.getTunnelInfo(oldTunnel.tunnelId()).tunnelConsumerId()); | 863 | resourceService.release(pceStore.getTunnelInfo(oldTunnel.tunnelId()).tunnelConsumerId()); |
| 864 | 864 | ||
| 865 | - // 2. Release new tunnel's bandwidth | 865 | + // 2. Release new tunnel's bandwidth, if new tunnel bandwidth is allocated |
| 866 | + if (pceStore.getTunnelInfo(newTunnel.tunnelId()) == null) { | ||
| 867 | + //If bandwidth for new tunnel is not allocated i,e 0 then no need to allocate | ||
| 868 | + return; | ||
| 869 | + } | ||
| 870 | + | ||
| 866 | ResourceConsumer consumer = pceStore.getTunnelInfo(newTunnel.tunnelId()).tunnelConsumerId(); | 871 | ResourceConsumer consumer = pceStore.getTunnelInfo(newTunnel.tunnelId()).tunnelConsumerId(); |
| 867 | resourceService.release(consumer); | 872 | resourceService.release(consumer); |
| 868 | 873 | ||
| ... | @@ -1205,7 +1210,7 @@ public class PceManager implements PceService { | ... | @@ -1205,7 +1210,7 @@ public class PceManager implements PceService { |
| 1205 | localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID))); | 1210 | localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID))); |
| 1206 | } | 1211 | } |
| 1207 | // If not zero bandwidth, and delegated (initiated LSPs will also be delegated). | 1212 | // If not zero bandwidth, and delegated (initiated LSPs will also be delegated). |
| 1208 | - if (Double.parseDouble(tunnel.annotations().value(BANDWIDTH)) != 0.0 | 1213 | + if (Float.parseFloat(tunnel.annotations().value(BANDWIDTH)) != 0 |
| 1209 | && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) { | 1214 | && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) { |
| 1210 | releaseBandwidth(tunnel); | 1215 | releaseBandwidth(tunnel); |
| 1211 | } | 1216 | } | ... | ... |
| ... | @@ -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 | } | ... | ... |
| ... | @@ -1244,14 +1244,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1244,14 +1244,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
| 1244 | tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); | 1244 | tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); |
| 1245 | llOptionalTlv.add(tlv); | 1245 | llOptionalTlv.add(tlv); |
| 1246 | } | 1246 | } |
| 1247 | - | ||
| 1248 | boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false | 1247 | boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false |
| 1249 | : Boolean.valueOf(tunnel.annotations() | 1248 | : Boolean.valueOf(tunnel.annotations() |
| 1250 | .value(DELEGATE)); | 1249 | .value(DELEGATE)); |
| 1251 | boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false | 1250 | boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false |
| 1252 | : Boolean.valueOf(tunnel.annotations() | 1251 | : Boolean.valueOf(tunnel.annotations() |
| 1253 | .value(PCE_INIT)); | 1252 | .value(PCE_INIT)); |
| 1254 | - | ||
| 1255 | // build lsp object | 1253 | // build lsp object |
| 1256 | PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true) | 1254 | PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true) |
| 1257 | .setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID))) | 1255 | .setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID))) |
| ... | @@ -1260,7 +1258,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1260,7 +1258,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
| 1260 | .setOptionalTlv(llOptionalTlv).build(); | 1258 | .setOptionalTlv(llOptionalTlv).build(); |
| 1261 | // build ero object | 1259 | // build ero object |
| 1262 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); | 1260 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); |
| 1263 | - | ||
| 1264 | float iBandwidth = DEFAULT_BANDWIDTH_VALUE; | 1261 | float iBandwidth = DEFAULT_BANDWIDTH_VALUE; |
| 1265 | if (tunnel.annotations().value(BANDWIDTH) != null) { | 1262 | if (tunnel.annotations().value(BANDWIDTH) != null) { |
| 1266 | iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); | 1263 | iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); |
| ... | @@ -1455,10 +1452,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1455,10 +1452,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
| 1455 | } | 1452 | } |
| 1456 | 1453 | ||
| 1457 | private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv, | 1454 | private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv, |
| 1458 | - float bandwidth, LspType lspType, String costType, boolean isPceInit) { | 1455 | + String bandwidth, LspType lspType, String costType, boolean isPceInit) { |
| 1459 | - | ||
| 1460 | Builder builder = DefaultAnnotations.builder(); | 1456 | Builder builder = DefaultAnnotations.builder(); |
| 1461 | - | ||
| 1462 | /* | 1457 | /* |
| 1463 | * [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 |
| 1464 | * 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. |
| ... | @@ -1471,8 +1466,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1471,8 +1466,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
| 1471 | builder.set(PCE_INIT, String.valueOf(isPceInit)); | 1466 | builder.set(PCE_INIT, String.valueOf(isPceInit)); |
| 1472 | } | 1467 | } |
| 1473 | 1468 | ||
| 1469 | + if (bandwidth != null) { | ||
| 1470 | + builder.set(BANDWIDTH, bandwidth); | ||
| 1471 | + } | ||
| 1472 | + | ||
| 1474 | SparseAnnotations annotations = builder | 1473 | SparseAnnotations annotations = builder |
| 1475 | - .set(BANDWIDTH, (new Float(bandwidth)).toString()) | ||
| 1476 | .set(LSP_SIG_TYPE, lspType.name()) | 1474 | .set(LSP_SIG_TYPE, lspType.name()) |
| 1477 | .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId())) | 1475 | .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId())) |
| 1478 | .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) | 1476 | .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) |
| ... | @@ -1598,6 +1596,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1598,6 +1596,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
| 1598 | new LspKey(lspObj.getPlspId(), ipv4LspIdenTlv.getLspId()), lspObj.getDFlag()); | 1596 | new LspKey(lspObj.getPlspId(), ipv4LspIdenTlv.getLspId()), lspObj.getDFlag()); |
| 1599 | } | 1597 | } |
| 1600 | Tunnel tunnel = null; | 1598 | Tunnel tunnel = null; |
| 1599 | + SparseAnnotations oldTunnelAnnotations = null; | ||
| 1601 | // Asynchronous status change message from PCC for LSP reported earlier. | 1600 | // Asynchronous status change message from PCC for LSP reported earlier. |
| 1602 | for (Tunnel tunnelObj : tunnelQueryResult) { | 1601 | for (Tunnel tunnelObj : tunnelQueryResult) { |
| 1603 | if (tunnelObj.annotations().value(PLSP_ID) == null) { | 1602 | if (tunnelObj.annotations().value(PLSP_ID) == null) { |
| ... | @@ -1615,13 +1614,17 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1615,13 +1614,17 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
| 1615 | } | 1614 | } |
| 1616 | continue; | 1615 | continue; |
| 1617 | } | 1616 | } |
| 1618 | - if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId()) && (Integer | 1617 | + if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId())) { |
| 1619 | - .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) { | 1618 | + if ((Integer |
| 1620 | - tunnel = tunnelObj; | 1619 | + .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) { |
| 1621 | - break; | 1620 | + tunnel = tunnelObj; |
| 1621 | + } | ||
| 1622 | + if ((Integer | ||
| 1623 | + .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) != ipv4LspIdenTlv.getLspId())) { | ||
| 1624 | + oldTunnelAnnotations = (SparseAnnotations) tunnelObj.annotations(); | ||
| 1625 | + } | ||
| 1622 | } | 1626 | } |
| 1623 | } | 1627 | } |
| 1624 | - | ||
| 1625 | DefaultTunnelDescription td; | 1628 | DefaultTunnelDescription td; |
| 1626 | SparseAnnotations annotations = null; | 1629 | SparseAnnotations annotations = null; |
| 1627 | State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); | 1630 | State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); |
| ... | @@ -1638,7 +1641,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1638,7 +1641,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
| 1638 | log.error("Ingress deviceId not found"); | 1641 | log.error("Ingress deviceId not found"); |
| 1639 | return; | 1642 | return; |
| 1640 | } | 1643 | } |
| 1641 | - annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType, lspObj.getCFlag()); | 1644 | + String tempBandwidth = null; |
| 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()); | ||
| 1642 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( | 1652 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( |
| 1643 | 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack, | 1653 | 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack, |
| 1644 | annotations); | 1654 | annotations); |
| ... | @@ -1696,15 +1706,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1696,15 +1706,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
| 1696 | NetworkResource labelStack, | 1706 | NetworkResource labelStack, |
| 1697 | StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) { | 1707 | StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) { |
| 1698 | SparseAnnotations annotations = null; | 1708 | SparseAnnotations annotations = null; |
| 1699 | - Float bandwidth = 0.0f; | ||
| 1700 | DefaultTunnelDescription td; | 1709 | DefaultTunnelDescription td; |
| 1701 | - if (tunnel.annotations().value(BANDWIDTH) != null) { | ||
| 1702 | - bandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); | ||
| 1703 | - } | ||
| 1704 | boolean isPceInit = tunnel.annotations().value(PCE_INIT) == null ? false : | 1710 | boolean isPceInit = tunnel.annotations().value(PCE_INIT) == null ? false : |
| 1705 | Boolean.valueOf((tunnel.annotations().value(PCE_INIT))).booleanValue(); | 1711 | Boolean.valueOf((tunnel.annotations().value(PCE_INIT))).booleanValue(); |
| 1706 | annotations = getAnnotations(lspObj, ipv4LspIdenTlv, | 1712 | annotations = getAnnotations(lspObj, ipv4LspIdenTlv, |
| 1707 | - bandwidth, lspType, | 1713 | + tunnel.annotations().value(BANDWIDTH), lspType, |
| 1708 | tunnel.annotations().value(COST_TYPE), isPceInit); | 1714 | tunnel.annotations().value(COST_TYPE), isPceInit); |
| 1709 | td = new DefaultTunnelDescription(null, tunnel.src(), tunnel.dst(), MPLS, new DefaultGroupId( | 1715 | td = new DefaultTunnelDescription(null, tunnel.src(), tunnel.dst(), MPLS, new DefaultGroupId( |
| 1710 | 0), tunnel.providerId(), tunnel.tunnelName(), | 1716 | 0), tunnel.providerId(), tunnel.tunnelName(), | ... | ... |
| ... | @@ -89,7 +89,6 @@ import org.onosproject.pcep.controller.ClientCapability; | ... | @@ -89,7 +89,6 @@ import org.onosproject.pcep.controller.ClientCapability; |
| 89 | import org.onosproject.pcep.controller.LspKey; | 89 | import org.onosproject.pcep.controller.LspKey; |
| 90 | import org.onosproject.pcep.controller.PccId; | 90 | import org.onosproject.pcep.controller.PccId; |
| 91 | 91 | ||
| 92 | -import com.esotericsoftware.minlog.Log; | ||
| 93 | import com.google.common.collect.FluentIterable; | 92 | import com.google.common.collect.FluentIterable; |
| 94 | import com.google.common.collect.ImmutableSet; | 93 | import com.google.common.collect.ImmutableSet; |
| 95 | 94 | ||
| ... | @@ -225,7 +224,6 @@ public class PcepTunnelAddedTest { | ... | @@ -225,7 +224,6 @@ public class PcepTunnelAddedTest { |
| 225 | tunnel.path(), | 224 | tunnel.path(), |
| 226 | tunnel.resource(), | 225 | tunnel.resource(), |
| 227 | tunnel.annotations()); | 226 | tunnel.annotations()); |
| 228 | - Log.info("tunnel.annotations().toString() " + tunnel.annotations().toString()); | ||
| 229 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); | 227 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); |
| 230 | return id; | 228 | return id; |
| 231 | } | 229 | } |
| ... | @@ -251,7 +249,6 @@ public class PcepTunnelAddedTest { | ... | @@ -251,7 +249,6 @@ public class PcepTunnelAddedTest { |
| 251 | tunnel.resource(), | 249 | tunnel.resource(), |
| 252 | tunnel.annotations()); | 250 | tunnel.annotations()); |
| 253 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); | 251 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); |
| 254 | - Log.info("tunnelService.tunnelIdAsKeyStore ++ " + tunnelService.tunnelIdAsKeyStore.toString()); | ||
| 255 | } | 252 | } |
| 256 | 253 | ||
| 257 | @Override | 254 | @Override |
| ... | @@ -269,7 +266,6 @@ public class PcepTunnelAddedTest { | ... | @@ -269,7 +266,6 @@ public class PcepTunnelAddedTest { |
| 269 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { | 266 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { |
| 270 | TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | 267 | TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); |
| 271 | tunnelIdAsKeyStore.put(tunnelId, tunnel); | 268 | tunnelIdAsKeyStore.put(tunnelId, tunnel); |
| 272 | - Log.info("tunnelIdAsKeyStore insetup :: " + tunnelIdAsKeyStore.toString()); | ||
| 273 | return tunnelId; | 269 | return tunnelId; |
| 274 | } | 270 | } |
| 275 | 271 | ... | ... |
-
Please register or login to post a comment