@Test public void testReleaseNodeLabelSuccess() { testAllocateNodeLabel(); String lsrId1 = "11.1.1.1"; assertThat(srTeHandler.releaseNodeLabel(D1.deviceId(), lsrId1), is(true)); LabelResourceId labelId = pceStore.getGlobalNodeLabel(D1.deviceId()); assertThat(labelId, is(nullValue())); String lsrId2 = "12.1.1.1"; assertThat(srTeHandler.releaseNodeLabel(D2.deviceId(), lsrId2), is(true)); labelId = pceStore.getGlobalNodeLabel(D2.deviceId()); assertThat(labelId, is(nullValue())); String lsrId3 = "13.1.1.1"; assertThat(srTeHandler.releaseNodeLabel(D3.deviceId(), lsrId3), is(true)); labelId = pceStore.getGlobalNodeLabel(D3.deviceId()); assertThat(labelId, is(nullValue())); String lsrId4 = "14.1.1.1"; assertThat(srTeHandler.releaseNodeLabel(D4.deviceId(), lsrId4), is(true)); labelId = pceStore.getGlobalNodeLabel(D4.deviceId()); assertThat(labelId, is(nullValue())); String lsrId5 = "15.1.1.1"; assertThat(srTeHandler.releaseNodeLabel(D5.deviceId(), lsrId5), is(true)); labelId = pceStore.getGlobalNodeLabel(D5.deviceId()); assertThat(labelId, is(nullValue())); }
public boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId) { checkNotNull(specificDeviceId, DEVICE_ID_NULL); checkNotNull(specificLsrId, LSR_ID_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getGlobalNodeLabel(specificDeviceId); if (labelId == null) { log.error("Unable to retrieve label of a device id {} from store.", specificDeviceId.toString()); return false; } for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) { DeviceId otherDevId = element.getKey(); if (!specificDeviceId.equals(otherDevId)) { advertiseNodeLabelRule(otherDevId, labelId, IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH), Objective.Operation.REMOVE, false); } } Set<LabelResourceId> release = new HashSet<>(); release.add(labelId); if (!labelRsrcService.releaseToGlobalPool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeGlobalNodeLabel(specificDeviceId)) { log.error("Unable to remove global node label id {} from store.", labelId.toString()); retValue = false; } return retValue; }
PceccSrTeBeHandler { public boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId) { checkNotNull(specificDeviceId, DEVICE_ID_NULL); checkNotNull(specificLsrId, LSR_ID_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getGlobalNodeLabel(specificDeviceId); if (labelId == null) { log.error("Unable to retrieve label of a device id {} from store.", specificDeviceId.toString()); return false; } for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) { DeviceId otherDevId = element.getKey(); if (!specificDeviceId.equals(otherDevId)) { advertiseNodeLabelRule(otherDevId, labelId, IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH), Objective.Operation.REMOVE, false); } } Set<LabelResourceId> release = new HashSet<>(); release.add(labelId); if (!labelRsrcService.releaseToGlobalPool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeGlobalNodeLabel(specificDeviceId)) { log.error("Unable to remove global node label id {} from store.", labelId.toString()); retValue = false; } return retValue; } }
PceccSrTeBeHandler { public boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId) { checkNotNull(specificDeviceId, DEVICE_ID_NULL); checkNotNull(specificLsrId, LSR_ID_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getGlobalNodeLabel(specificDeviceId); if (labelId == null) { log.error("Unable to retrieve label of a device id {} from store.", specificDeviceId.toString()); return false; } for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) { DeviceId otherDevId = element.getKey(); if (!specificDeviceId.equals(otherDevId)) { advertiseNodeLabelRule(otherDevId, labelId, IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH), Objective.Operation.REMOVE, false); } } Set<LabelResourceId> release = new HashSet<>(); release.add(labelId); if (!labelRsrcService.releaseToGlobalPool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeGlobalNodeLabel(specificDeviceId)) { log.error("Unable to remove global node label id {} from store.", labelId.toString()); retValue = false; } return retValue; } private  PceccSrTeBeHandler(); }
PceccSrTeBeHandler { public boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId) { checkNotNull(specificDeviceId, DEVICE_ID_NULL); checkNotNull(specificLsrId, LSR_ID_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getGlobalNodeLabel(specificDeviceId); if (labelId == null) { log.error("Unable to retrieve label of a device id {} from store.", specificDeviceId.toString()); return false; } for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) { DeviceId otherDevId = element.getKey(); if (!specificDeviceId.equals(otherDevId)) { advertiseNodeLabelRule(otherDevId, labelId, IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH), Objective.Operation.REMOVE, false); } } Set<LabelResourceId> release = new HashSet<>(); release.add(labelId); if (!labelRsrcService.releaseToGlobalPool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeGlobalNodeLabel(specificDeviceId)) { log.error("Unable to remove global node label id {} from store.", labelId.toString()); retValue = false; } return retValue; } private  PceccSrTeBeHandler(); static PceccSrTeBeHandler getInstance(); void initialize(LabelResourceAdminService labelRsrcAdminService, LabelResourceService labelRsrcService,
                           FlowObjectiveService flowObjectiveService, ApplicationId appId, PceStore pceStore,
                           DeviceService deviceService); boolean reserveGlobalPool(long beginLabel, long endLabel); String getLsrId(DeviceId deviceId); boolean allocateNodeLabel(DeviceId specificDeviceId, String specificLsrId); boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId); boolean allocateAdjacencyLabel(Link link); boolean releaseAdjacencyLabel(Link link); LabelStack computeLabelStack(Path path); void advertiseNodeLabelRule(DeviceId deviceId, LabelResourceId labelId, IpPrefix ipPrefix,
                                       Objective.Operation type, boolean bBos); void installAdjLabelRule(DeviceId deviceId, LabelResourceId labelId, PortNumber srcPortNum,
                                    PortNumber dstPortNum, Objective.Operation type); }
PceccSrTeBeHandler { public boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId) { checkNotNull(specificDeviceId, DEVICE_ID_NULL); checkNotNull(specificLsrId, LSR_ID_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getGlobalNodeLabel(specificDeviceId); if (labelId == null) { log.error("Unable to retrieve label of a device id {} from store.", specificDeviceId.toString()); return false; } for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) { DeviceId otherDevId = element.getKey(); if (!specificDeviceId.equals(otherDevId)) { advertiseNodeLabelRule(otherDevId, labelId, IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH), Objective.Operation.REMOVE, false); } } Set<LabelResourceId> release = new HashSet<>(); release.add(labelId); if (!labelRsrcService.releaseToGlobalPool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeGlobalNodeLabel(specificDeviceId)) { log.error("Unable to remove global node label id {} from store.", labelId.toString()); retValue = false; } return retValue; } private  PceccSrTeBeHandler(); static PceccSrTeBeHandler getInstance(); void initialize(LabelResourceAdminService labelRsrcAdminService, LabelResourceService labelRsrcService,
                           FlowObjectiveService flowObjectiveService, ApplicationId appId, PceStore pceStore,
                           DeviceService deviceService); boolean reserveGlobalPool(long beginLabel, long endLabel); String getLsrId(DeviceId deviceId); boolean allocateNodeLabel(DeviceId specificDeviceId, String specificLsrId); boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId); boolean allocateAdjacencyLabel(Link link); boolean releaseAdjacencyLabel(Link link); LabelStack computeLabelStack(Path path); void advertiseNodeLabelRule(DeviceId deviceId, LabelResourceId labelId, IpPrefix ipPrefix,
                                       Objective.Operation type, boolean bBos); void installAdjLabelRule(DeviceId deviceId, LabelResourceId labelId, PortNumber srcPortNum,
                                    PortNumber dstPortNum, Objective.Operation type);  }