@Test public void resilencyTest3() { build4RouterTopo(true, false, false, false, 10); List<Constraint> constraints = new LinkedList<Constraint>(); CostConstraint costConstraint = new CostConstraint(COST); constraints.add(costConstraint); BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10)); constraints.add(localBwConst); boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING); assertThat(result, is(true)); List<Event> reasons = new LinkedList<>(); LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2); reasons.add(linkEvent); linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1); reasons.add(linkEvent); final TopologyEvent event = new TopologyEvent( TopologyEvent.Type.TOPOLOGY_CHANGED, topology, reasons); Set<TopologyEdge> tempEdges = new HashSet<>(); tempEdges.add(new DefaultTopologyEdge(D2, D4, link2)); tempEdges.add(new DefaultTopologyEdge(D1, D2, link1)); topologyService.changeInTopology(getGraph(null, tempEdges)); listener.event(event); List<Link> links = new LinkedList<>(); links.add(link3); links.add(link4); assertThat(pathService.paths().iterator().next().links(), is(links)); assertThat(pathService.paths().iterator().next().cost(), is((double) 180)); }
@Override public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType) { checkNotNull(src); checkNotNull(dst); checkNotNull(tunnelName); checkNotNull(lspType); Device srcDevice = deviceService.getDevice(src); Device dstDevice = deviceService.getDevice(dst); if (srcDevice == null || dstDevice == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } String srcLsrId = srcDevice.annotations().value(LSRID); String dstLsrId = dstDevice.annotations().value(LSRID); if (srcLsrId == null || dstLsrId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(srcLsrId), DeviceCapability.class); if (cfg == null) { log.debug("No session to ingress."); pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } TunnelEndPoint srcEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(srcLsrId)); TunnelEndPoint dstEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dstLsrId)); double bwConstraintValue = 0; CostConstraint costConstraint = null; if (constraints != null) { constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); Iterator<Constraint> iterator = constraints.iterator(); while (iterator.hasNext()) { Constraint constraint = iterator.next(); if (constraint instanceof BandwidthConstraint) { bwConstraintValue = ((BandwidthConstraint) constraint).bandwidth().bps(); } else if (constraint instanceof CostConstraint) { costConstraint = (CostConstraint) constraint; } } if (costConstraint != null) { constraints.remove(costConstraint); constraints.add(costConstraint); } } else { constraints = new LinkedList<>(); constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); } Set<Path> computedPathSet = computePath(src, dst, constraints); if (computedPathSet.isEmpty()) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } Builder annotationBuilder = DefaultAnnotations.builder(); if (bwConstraintValue != 0) { annotationBuilder.set(BANDWIDTH, String.valueOf(bwConstraintValue)); } if (costConstraint != null) { annotationBuilder.set(COST_TYPE, String.valueOf(costConstraint.type())); } annotationBuilder.set(LSP_SIG_TYPE, lspType.name()); annotationBuilder.set(PCE_INIT, TRUE); annotationBuilder.set(DELEGATE, TRUE); Path computedPath = computedPathSet.iterator().next(); LabelStack labelStack = null; if (lspType == SR_WITHOUT_SIGNALLING) { labelStack = srTeHandler.computeLabelStack(computedPath); if (labelStack == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } if (lspType != WITH_SIGNALLING) { annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(getNextLocalLspId())); } Tunnel tunnel = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null, TunnelName.tunnelName(tunnelName), computedPath, labelStack, annotationBuilder.build()); TunnelConsumerId consumerId = null; if (bwConstraintValue != 0) { consumerId = reserveBandwidth(computedPath, bwConstraintValue, null); if (consumerId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } TunnelId tunnelId = tunnelService.setupTunnel(appId, src, tunnel, computedPath); if (tunnelId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); if (consumerId != null) { resourceService.release(consumerId); } return false; } if (consumerId != null) { PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId); pceStore.addTunnelInfo(tunnelId, pceccTunnelInfo); } return true; }
PceManager implements PceService { @Override public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType) { checkNotNull(src); checkNotNull(dst); checkNotNull(tunnelName); checkNotNull(lspType); Device srcDevice = deviceService.getDevice(src); Device dstDevice = deviceService.getDevice(dst); if (srcDevice == null || dstDevice == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } String srcLsrId = srcDevice.annotations().value(LSRID); String dstLsrId = dstDevice.annotations().value(LSRID); if (srcLsrId == null || dstLsrId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(srcLsrId), DeviceCapability.class); if (cfg == null) { log.debug("No session to ingress."); pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } TunnelEndPoint srcEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(srcLsrId)); TunnelEndPoint dstEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dstLsrId)); double bwConstraintValue = 0; CostConstraint costConstraint = null; if (constraints != null) { constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); Iterator<Constraint> iterator = constraints.iterator(); while (iterator.hasNext()) { Constraint constraint = iterator.next(); if (constraint instanceof BandwidthConstraint) { bwConstraintValue = ((BandwidthConstraint) constraint).bandwidth().bps(); } else if (constraint instanceof CostConstraint) { costConstraint = (CostConstraint) constraint; } } if (costConstraint != null) { constraints.remove(costConstraint); constraints.add(costConstraint); } } else { constraints = new LinkedList<>(); constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); } Set<Path> computedPathSet = computePath(src, dst, constraints); if (computedPathSet.isEmpty()) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } Builder annotationBuilder = DefaultAnnotations.builder(); if (bwConstraintValue != 0) { annotationBuilder.set(BANDWIDTH, String.valueOf(bwConstraintValue)); } if (costConstraint != null) { annotationBuilder.set(COST_TYPE, String.valueOf(costConstraint.type())); } annotationBuilder.set(LSP_SIG_TYPE, lspType.name()); annotationBuilder.set(PCE_INIT, TRUE); annotationBuilder.set(DELEGATE, TRUE); Path computedPath = computedPathSet.iterator().next(); LabelStack labelStack = null; if (lspType == SR_WITHOUT_SIGNALLING) { labelStack = srTeHandler.computeLabelStack(computedPath); if (labelStack == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } if (lspType != WITH_SIGNALLING) { annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(getNextLocalLspId())); } Tunnel tunnel = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null, TunnelName.tunnelName(tunnelName), computedPath, labelStack, annotationBuilder.build()); TunnelConsumerId consumerId = null; if (bwConstraintValue != 0) { consumerId = reserveBandwidth(computedPath, bwConstraintValue, null); if (consumerId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } TunnelId tunnelId = tunnelService.setupTunnel(appId, src, tunnel, computedPath); if (tunnelId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); if (consumerId != null) { resourceService.release(consumerId); } return false; } if (consumerId != null) { PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId); pceStore.addTunnelInfo(tunnelId, pceccTunnelInfo); } return true; } }
PceManager implements PceService { @Override public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType) { checkNotNull(src); checkNotNull(dst); checkNotNull(tunnelName); checkNotNull(lspType); Device srcDevice = deviceService.getDevice(src); Device dstDevice = deviceService.getDevice(dst); if (srcDevice == null || dstDevice == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } String srcLsrId = srcDevice.annotations().value(LSRID); String dstLsrId = dstDevice.annotations().value(LSRID); if (srcLsrId == null || dstLsrId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(srcLsrId), DeviceCapability.class); if (cfg == null) { log.debug("No session to ingress."); pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } TunnelEndPoint srcEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(srcLsrId)); TunnelEndPoint dstEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dstLsrId)); double bwConstraintValue = 0; CostConstraint costConstraint = null; if (constraints != null) { constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); Iterator<Constraint> iterator = constraints.iterator(); while (iterator.hasNext()) { Constraint constraint = iterator.next(); if (constraint instanceof BandwidthConstraint) { bwConstraintValue = ((BandwidthConstraint) constraint).bandwidth().bps(); } else if (constraint instanceof CostConstraint) { costConstraint = (CostConstraint) constraint; } } if (costConstraint != null) { constraints.remove(costConstraint); constraints.add(costConstraint); } } else { constraints = new LinkedList<>(); constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); } Set<Path> computedPathSet = computePath(src, dst, constraints); if (computedPathSet.isEmpty()) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } Builder annotationBuilder = DefaultAnnotations.builder(); if (bwConstraintValue != 0) { annotationBuilder.set(BANDWIDTH, String.valueOf(bwConstraintValue)); } if (costConstraint != null) { annotationBuilder.set(COST_TYPE, String.valueOf(costConstraint.type())); } annotationBuilder.set(LSP_SIG_TYPE, lspType.name()); annotationBuilder.set(PCE_INIT, TRUE); annotationBuilder.set(DELEGATE, TRUE); Path computedPath = computedPathSet.iterator().next(); LabelStack labelStack = null; if (lspType == SR_WITHOUT_SIGNALLING) { labelStack = srTeHandler.computeLabelStack(computedPath); if (labelStack == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } if (lspType != WITH_SIGNALLING) { annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(getNextLocalLspId())); } Tunnel tunnel = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null, TunnelName.tunnelName(tunnelName), computedPath, labelStack, annotationBuilder.build()); TunnelConsumerId consumerId = null; if (bwConstraintValue != 0) { consumerId = reserveBandwidth(computedPath, bwConstraintValue, null); if (consumerId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } TunnelId tunnelId = tunnelService.setupTunnel(appId, src, tunnel, computedPath); if (tunnelId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); if (consumerId != null) { resourceService.release(consumerId); } return false; } if (consumerId != null) { PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId); pceStore.addTunnelInfo(tunnelId, pceccTunnelInfo); } return true; } PceManager(); }
PceManager implements PceService { @Override public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType) { checkNotNull(src); checkNotNull(dst); checkNotNull(tunnelName); checkNotNull(lspType); Device srcDevice = deviceService.getDevice(src); Device dstDevice = deviceService.getDevice(dst); if (srcDevice == null || dstDevice == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } String srcLsrId = srcDevice.annotations().value(LSRID); String dstLsrId = dstDevice.annotations().value(LSRID); if (srcLsrId == null || dstLsrId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(srcLsrId), DeviceCapability.class); if (cfg == null) { log.debug("No session to ingress."); pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } TunnelEndPoint srcEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(srcLsrId)); TunnelEndPoint dstEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dstLsrId)); double bwConstraintValue = 0; CostConstraint costConstraint = null; if (constraints != null) { constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); Iterator<Constraint> iterator = constraints.iterator(); while (iterator.hasNext()) { Constraint constraint = iterator.next(); if (constraint instanceof BandwidthConstraint) { bwConstraintValue = ((BandwidthConstraint) constraint).bandwidth().bps(); } else if (constraint instanceof CostConstraint) { costConstraint = (CostConstraint) constraint; } } if (costConstraint != null) { constraints.remove(costConstraint); constraints.add(costConstraint); } } else { constraints = new LinkedList<>(); constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); } Set<Path> computedPathSet = computePath(src, dst, constraints); if (computedPathSet.isEmpty()) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } Builder annotationBuilder = DefaultAnnotations.builder(); if (bwConstraintValue != 0) { annotationBuilder.set(BANDWIDTH, String.valueOf(bwConstraintValue)); } if (costConstraint != null) { annotationBuilder.set(COST_TYPE, String.valueOf(costConstraint.type())); } annotationBuilder.set(LSP_SIG_TYPE, lspType.name()); annotationBuilder.set(PCE_INIT, TRUE); annotationBuilder.set(DELEGATE, TRUE); Path computedPath = computedPathSet.iterator().next(); LabelStack labelStack = null; if (lspType == SR_WITHOUT_SIGNALLING) { labelStack = srTeHandler.computeLabelStack(computedPath); if (labelStack == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } if (lspType != WITH_SIGNALLING) { annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(getNextLocalLspId())); } Tunnel tunnel = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null, TunnelName.tunnelName(tunnelName), computedPath, labelStack, annotationBuilder.build()); TunnelConsumerId consumerId = null; if (bwConstraintValue != 0) { consumerId = reserveBandwidth(computedPath, bwConstraintValue, null); if (consumerId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } TunnelId tunnelId = tunnelService.setupTunnel(appId, src, tunnel, computedPath); if (tunnelId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); if (consumerId != null) { resourceService.release(consumerId); } return false; } if (consumerId != null) { PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId); pceStore.addTunnelInfo(tunnelId, pceccTunnelInfo); } return true; } PceManager(); @Override boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints,
                             LspType lspType); @Override boolean updatePath(TunnelId tunnelId, List<Constraint> constraints); @Override boolean releasePath(TunnelId tunnelId); @Override Iterable<Tunnel> queryAllPath(); @Override Tunnel queryPath(TunnelId tunnelId); void allocateNodeLabel(Device specificDevice); void releaseNodeLabel(Device specificDevice); void allocateAdjacencyLabel(Link link); void releaseAdjacencyLabel(Link link); }
PceManager implements PceService { @Override public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType) { checkNotNull(src); checkNotNull(dst); checkNotNull(tunnelName); checkNotNull(lspType); Device srcDevice = deviceService.getDevice(src); Device dstDevice = deviceService.getDevice(dst); if (srcDevice == null || dstDevice == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } String srcLsrId = srcDevice.annotations().value(LSRID); String dstLsrId = dstDevice.annotations().value(LSRID); if (srcLsrId == null || dstLsrId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(srcLsrId), DeviceCapability.class); if (cfg == null) { log.debug("No session to ingress."); pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } TunnelEndPoint srcEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(srcLsrId)); TunnelEndPoint dstEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dstLsrId)); double bwConstraintValue = 0; CostConstraint costConstraint = null; if (constraints != null) { constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); Iterator<Constraint> iterator = constraints.iterator(); while (iterator.hasNext()) { Constraint constraint = iterator.next(); if (constraint instanceof BandwidthConstraint) { bwConstraintValue = ((BandwidthConstraint) constraint).bandwidth().bps(); } else if (constraint instanceof CostConstraint) { costConstraint = (CostConstraint) constraint; } } if (costConstraint != null) { constraints.remove(costConstraint); constraints.add(costConstraint); } } else { constraints = new LinkedList<>(); constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name()))); } Set<Path> computedPathSet = computePath(src, dst, constraints); if (computedPathSet.isEmpty()) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } Builder annotationBuilder = DefaultAnnotations.builder(); if (bwConstraintValue != 0) { annotationBuilder.set(BANDWIDTH, String.valueOf(bwConstraintValue)); } if (costConstraint != null) { annotationBuilder.set(COST_TYPE, String.valueOf(costConstraint.type())); } annotationBuilder.set(LSP_SIG_TYPE, lspType.name()); annotationBuilder.set(PCE_INIT, TRUE); annotationBuilder.set(DELEGATE, TRUE); Path computedPath = computedPathSet.iterator().next(); LabelStack labelStack = null; if (lspType == SR_WITHOUT_SIGNALLING) { labelStack = srTeHandler.computeLabelStack(computedPath); if (labelStack == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } if (lspType != WITH_SIGNALLING) { annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(getNextLocalLspId())); } Tunnel tunnel = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null, TunnelName.tunnelName(tunnelName), computedPath, labelStack, annotationBuilder.build()); TunnelConsumerId consumerId = null; if (bwConstraintValue != 0) { consumerId = reserveBandwidth(computedPath, bwConstraintValue, null); if (consumerId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); return false; } } TunnelId tunnelId = tunnelService.setupTunnel(appId, src, tunnel, computedPath); if (tunnelId == null) { pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); if (consumerId != null) { resourceService.release(consumerId); } return false; } if (consumerId != null) { PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId); pceStore.addTunnelInfo(tunnelId, pceccTunnelInfo); } return true; } PceManager(); @Override boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints,
                             LspType lspType); @Override boolean updatePath(TunnelId tunnelId, List<Constraint> constraints); @Override boolean releasePath(TunnelId tunnelId); @Override Iterable<Tunnel> queryAllPath(); @Override Tunnel queryPath(TunnelId tunnelId); void allocateNodeLabel(Device specificDevice); void releaseNodeLabel(Device specificDevice); void allocateAdjacencyLabel(Link link); void releaseAdjacencyLabel(Link link); static final long GLOBAL_LABEL_SPACE_MIN; static final long GLOBAL_LABEL_SPACE_MAX; static final String PCE_SERVICE_APP; static final String DEVICE_TYPE; static final String L3_DEVICE; static final int PCEP_PORT; static final int INITIAL_DELAY; static final int PERIODIC_DELAY; }