@Test public void testReleaseAdjacencyLabel() { assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true)); assertThat(srTeHandler.releaseAdjacencyLabel(link1), is(true)); LabelResourceId labelId = pceStore.getAdjLabel(link1); assertThat(labelId, is(nullValue())); assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true)); assertThat(srTeHandler.releaseAdjacencyLabel(link2), is(true)); labelId = pceStore.getAdjLabel(link2); assertThat(labelId, is(nullValue())); }
public boolean releaseAdjacencyLabel(Link link) { checkNotNull(link, LINK_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getAdjLabel(link); if (labelId == null) { log.error("Unabel to retrieve label for a link {} from store.", link.toString()); return false; } DeviceId srcDeviceId = link.src().deviceId(); installAdjLabelRule(srcDeviceId, labelId, link.src().port(), link.dst().port(), Objective.Operation.REMOVE); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); DefaultLabelResource defaultLabelResource = new DefaultLabelResource(srcDeviceId, labelId); release.put(srcDeviceId, defaultLabelResource); if (!labelRsrcService.releaseToDevicePool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeAdjLabel(link)) { log.error("Unable to remove adjacency label id {} from store.", labelId.toString()); retValue = false; } return retValue; }
PceccSrTeBeHandler { public boolean releaseAdjacencyLabel(Link link) { checkNotNull(link, LINK_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getAdjLabel(link); if (labelId == null) { log.error("Unabel to retrieve label for a link {} from store.", link.toString()); return false; } DeviceId srcDeviceId = link.src().deviceId(); installAdjLabelRule(srcDeviceId, labelId, link.src().port(), link.dst().port(), Objective.Operation.REMOVE); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); DefaultLabelResource defaultLabelResource = new DefaultLabelResource(srcDeviceId, labelId); release.put(srcDeviceId, defaultLabelResource); if (!labelRsrcService.releaseToDevicePool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeAdjLabel(link)) { log.error("Unable to remove adjacency label id {} from store.", labelId.toString()); retValue = false; } return retValue; } }
PceccSrTeBeHandler { public boolean releaseAdjacencyLabel(Link link) { checkNotNull(link, LINK_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getAdjLabel(link); if (labelId == null) { log.error("Unabel to retrieve label for a link {} from store.", link.toString()); return false; } DeviceId srcDeviceId = link.src().deviceId(); installAdjLabelRule(srcDeviceId, labelId, link.src().port(), link.dst().port(), Objective.Operation.REMOVE); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); DefaultLabelResource defaultLabelResource = new DefaultLabelResource(srcDeviceId, labelId); release.put(srcDeviceId, defaultLabelResource); if (!labelRsrcService.releaseToDevicePool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeAdjLabel(link)) { log.error("Unable to remove adjacency label id {} from store.", labelId.toString()); retValue = false; } return retValue; } private  PceccSrTeBeHandler(); }
PceccSrTeBeHandler { public boolean releaseAdjacencyLabel(Link link) { checkNotNull(link, LINK_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getAdjLabel(link); if (labelId == null) { log.error("Unabel to retrieve label for a link {} from store.", link.toString()); return false; } DeviceId srcDeviceId = link.src().deviceId(); installAdjLabelRule(srcDeviceId, labelId, link.src().port(), link.dst().port(), Objective.Operation.REMOVE); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); DefaultLabelResource defaultLabelResource = new DefaultLabelResource(srcDeviceId, labelId); release.put(srcDeviceId, defaultLabelResource); if (!labelRsrcService.releaseToDevicePool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeAdjLabel(link)) { log.error("Unable to remove adjacency 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 releaseAdjacencyLabel(Link link) { checkNotNull(link, LINK_NULL); checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); boolean retValue = true; LabelResourceId labelId = pceStore.getAdjLabel(link); if (labelId == null) { log.error("Unabel to retrieve label for a link {} from store.", link.toString()); return false; } DeviceId srcDeviceId = link.src().deviceId(); installAdjLabelRule(srcDeviceId, labelId, link.src().port(), link.dst().port(), Objective.Operation.REMOVE); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); DefaultLabelResource defaultLabelResource = new DefaultLabelResource(srcDeviceId, labelId); release.put(srcDeviceId, defaultLabelResource); if (!labelRsrcService.releaseToDevicePool(release)) { log.error("Unable to release label id {} from label manager.", labelId.toString()); retValue = false; } if (!pceStore.removeAdjLabel(link)) { log.error("Unable to remove adjacency 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);  }