@Test public void testReleaseLabel() { assertThat(pceccHandler.allocateLabel(tunnel), is(true)); pceccHandler.releaseLabel(tunnel); pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); assertThat(pceccTunnelInfo, is(nullValue())); }
public void releaseLabel(Tunnel tunnel) { boolean isLastLabelToPush = false; checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); if (pceccTunnelInfo != null) { List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList(); if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) { for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) { LspLocalLabelInfo lspLocalLabelInfo = iterator.next(); DeviceId deviceId = lspLocalLabelInfo.deviceId(); LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId(); LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId(); PortNumber inPort = lspLocalLabelInfo.inPort(); PortNumber outPort = lspLocalLabelInfo.outPort(); if (!iterator.hasNext()) { isLastLabelToPush = true; } if ((inLabelId != null) && (inPort != null)) { installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE); } if ((outLabelId != null) && (outPort != null)) { installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE); } if ((iterator.hasNext()) && (inLabelId != null)) { LabelResource labelRsc = new DefaultLabelResource(deviceId, inLabelId); release.put(deviceId, labelRsc); } } } if (!release.isEmpty()) { labelRsrcService.releaseToDevicePool(release); } if (pceccTunnelInfo.tunnelConsumerId() == null) { pceStore.removeTunnelInfo(tunnel.tunnelId()); } } else { log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString()); } }
BasicPceccHandler { public void releaseLabel(Tunnel tunnel) { boolean isLastLabelToPush = false; checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); if (pceccTunnelInfo != null) { List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList(); if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) { for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) { LspLocalLabelInfo lspLocalLabelInfo = iterator.next(); DeviceId deviceId = lspLocalLabelInfo.deviceId(); LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId(); LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId(); PortNumber inPort = lspLocalLabelInfo.inPort(); PortNumber outPort = lspLocalLabelInfo.outPort(); if (!iterator.hasNext()) { isLastLabelToPush = true; } if ((inLabelId != null) && (inPort != null)) { installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE); } if ((outLabelId != null) && (outPort != null)) { installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE); } if ((iterator.hasNext()) && (inLabelId != null)) { LabelResource labelRsc = new DefaultLabelResource(deviceId, inLabelId); release.put(deviceId, labelRsc); } } } if (!release.isEmpty()) { labelRsrcService.releaseToDevicePool(release); } if (pceccTunnelInfo.tunnelConsumerId() == null) { pceStore.removeTunnelInfo(tunnel.tunnelId()); } } else { log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString()); } } }
BasicPceccHandler { public void releaseLabel(Tunnel tunnel) { boolean isLastLabelToPush = false; checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); if (pceccTunnelInfo != null) { List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList(); if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) { for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) { LspLocalLabelInfo lspLocalLabelInfo = iterator.next(); DeviceId deviceId = lspLocalLabelInfo.deviceId(); LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId(); LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId(); PortNumber inPort = lspLocalLabelInfo.inPort(); PortNumber outPort = lspLocalLabelInfo.outPort(); if (!iterator.hasNext()) { isLastLabelToPush = true; } if ((inLabelId != null) && (inPort != null)) { installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE); } if ((outLabelId != null) && (outPort != null)) { installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE); } if ((iterator.hasNext()) && (inLabelId != null)) { LabelResource labelRsc = new DefaultLabelResource(deviceId, inLabelId); release.put(deviceId, labelRsc); } } } if (!release.isEmpty()) { labelRsrcService.releaseToDevicePool(release); } if (pceccTunnelInfo.tunnelConsumerId() == null) { pceStore.removeTunnelInfo(tunnel.tunnelId()); } } else { log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString()); } } private  BasicPceccHandler(); }
BasicPceccHandler { public void releaseLabel(Tunnel tunnel) { boolean isLastLabelToPush = false; checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); if (pceccTunnelInfo != null) { List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList(); if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) { for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) { LspLocalLabelInfo lspLocalLabelInfo = iterator.next(); DeviceId deviceId = lspLocalLabelInfo.deviceId(); LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId(); LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId(); PortNumber inPort = lspLocalLabelInfo.inPort(); PortNumber outPort = lspLocalLabelInfo.outPort(); if (!iterator.hasNext()) { isLastLabelToPush = true; } if ((inLabelId != null) && (inPort != null)) { installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE); } if ((outLabelId != null) && (outPort != null)) { installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE); } if ((iterator.hasNext()) && (inLabelId != null)) { LabelResource labelRsc = new DefaultLabelResource(deviceId, inLabelId); release.put(deviceId, labelRsc); } } } if (!release.isEmpty()) { labelRsrcService.releaseToDevicePool(release); } if (pceccTunnelInfo.tunnelConsumerId() == null) { pceStore.removeTunnelInfo(tunnel.tunnelId()); } } else { log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString()); } } private  BasicPceccHandler(); static BasicPceccHandler getInstance(); void initialize(LabelResourceService labelRsrcService, FlowObjectiveService flowObjectiveService,
                           ApplicationId appId, PceStore pceStore); boolean allocateLabel(Tunnel tunnel); void updatePceccTunnelInfoInStore(DeviceId srcDeviceId, DeviceId dstDeviceId, LabelResourceId labelId,
                                                PortNumber dstPort, Tunnel tunnel, boolean isLastLabelToPush); void releaseLabel(Tunnel tunnel); }
BasicPceccHandler { public void releaseLabel(Tunnel tunnel) { boolean isLastLabelToPush = false; checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL); checkNotNull(pceStore, PCE_STORE_NULL); Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create(); PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); if (pceccTunnelInfo != null) { List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList(); if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) { for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) { LspLocalLabelInfo lspLocalLabelInfo = iterator.next(); DeviceId deviceId = lspLocalLabelInfo.deviceId(); LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId(); LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId(); PortNumber inPort = lspLocalLabelInfo.inPort(); PortNumber outPort = lspLocalLabelInfo.outPort(); if (!iterator.hasNext()) { isLastLabelToPush = true; } if ((inLabelId != null) && (inPort != null)) { installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE); } if ((outLabelId != null) && (outPort != null)) { installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush, Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE); } if ((iterator.hasNext()) && (inLabelId != null)) { LabelResource labelRsc = new DefaultLabelResource(deviceId, inLabelId); release.put(deviceId, labelRsc); } } } if (!release.isEmpty()) { labelRsrcService.releaseToDevicePool(release); } if (pceccTunnelInfo.tunnelConsumerId() == null) { pceStore.removeTunnelInfo(tunnel.tunnelId()); } } else { log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString()); } } private  BasicPceccHandler(); static BasicPceccHandler getInstance(); void initialize(LabelResourceService labelRsrcService, FlowObjectiveService flowObjectiveService,
                           ApplicationId appId, PceStore pceStore); boolean allocateLabel(Tunnel tunnel); void updatePceccTunnelInfoInStore(DeviceId srcDeviceId, DeviceId dstDeviceId, LabelResourceId labelId,
                                                PortNumber dstPort, Tunnel tunnel, boolean isLastLabelToPush); void releaseLabel(Tunnel tunnel);  }