@Test public void testComputeLabelStack() { labelId = LabelResourceId.labelResourceId(4097); pceStore.addGlobalNodeLabel(D1.deviceId(), labelId); labelId = LabelResourceId.labelResourceId(4098); pceStore.addGlobalNodeLabel(D2.deviceId(), labelId); labelId = LabelResourceId.labelResourceId(4099); pceStore.addGlobalNodeLabel(D3.deviceId(), labelId); labelId = LabelResourceId.labelResourceId(4100); pceStore.addGlobalNodeLabel(D4.deviceId(), labelId); labelId = LabelResourceId.labelResourceId(4101); pceStore.addGlobalNodeLabel(D5.deviceId(), labelId); labelId = LabelResourceId.labelResourceId(5122); pceStore.addAdjLabel(link1, labelId); labelId = LabelResourceId.labelResourceId(5123); pceStore.addAdjLabel(link2, labelId); labelId = LabelResourceId.labelResourceId(5124); pceStore.addAdjLabel(link3, labelId); labelId = LabelResourceId.labelResourceId(5125); pceStore.addAdjLabel(link4, labelId); LabelStack labelStack = srTeHandler.computeLabelStack(path1); List<LabelResourceId> labelList = labelStack.labelResources(); Iterator<LabelResourceId> iterator = labelList.iterator(); labelId = iterator.next(); assertThat(labelId, is(LabelResourceId.labelResourceId(5122))); labelId = iterator.next(); assertThat(labelId, is(LabelResourceId.labelResourceId(4098))); labelId = iterator.next(); assertThat(labelId, is(LabelResourceId.labelResourceId(5123))); labelId = iterator.next(); assertThat(labelId, is(LabelResourceId.labelResourceId(4099))); labelId = iterator.next(); assertThat(labelId, is(LabelResourceId.labelResourceId(5124))); labelId = iterator.next(); assertThat(labelId, is(LabelResourceId.labelResourceId(4100))); labelId = iterator.next(); assertThat(labelId, is(LabelResourceId.labelResourceId(5125))); labelId = iterator.next(); assertThat(labelId, is(LabelResourceId.labelResourceId(4101))); }
public LabelStack computeLabelStack(Path path) { checkNotNull(path, PATH_NULL); List<LabelResourceId> labelStack = new LinkedList<>(); List<Link> linkList = path.links(); if ((linkList != null) && (linkList.size() > 0)) { Link link = null; LabelResourceId nodeLabelId = null; LabelResourceId adjLabelId = null; DeviceId deviceId = null; for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) { link = iterator.next(); adjLabelId = pceStore.getAdjLabel(link); if (adjLabelId == null) { log.error("Adjacency label id is null for a link {}.", link.toString()); return null; } labelStack.add(adjLabelId); deviceId = link.dst().deviceId(); nodeLabelId = pceStore.getGlobalNodeLabel(deviceId); if (nodeLabelId == null) { log.error("Unable to find node label for a device id {} in store.", deviceId.toString()); return null; } labelStack.add(nodeLabelId); } } else { log.debug("Empty link in path."); return null; } return new DefaultLabelStack(labelStack); }
PceccSrTeBeHandler { public LabelStack computeLabelStack(Path path) { checkNotNull(path, PATH_NULL); List<LabelResourceId> labelStack = new LinkedList<>(); List<Link> linkList = path.links(); if ((linkList != null) && (linkList.size() > 0)) { Link link = null; LabelResourceId nodeLabelId = null; LabelResourceId adjLabelId = null; DeviceId deviceId = null; for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) { link = iterator.next(); adjLabelId = pceStore.getAdjLabel(link); if (adjLabelId == null) { log.error("Adjacency label id is null for a link {}.", link.toString()); return null; } labelStack.add(adjLabelId); deviceId = link.dst().deviceId(); nodeLabelId = pceStore.getGlobalNodeLabel(deviceId); if (nodeLabelId == null) { log.error("Unable to find node label for a device id {} in store.", deviceId.toString()); return null; } labelStack.add(nodeLabelId); } } else { log.debug("Empty link in path."); return null; } return new DefaultLabelStack(labelStack); } }
PceccSrTeBeHandler { public LabelStack computeLabelStack(Path path) { checkNotNull(path, PATH_NULL); List<LabelResourceId> labelStack = new LinkedList<>(); List<Link> linkList = path.links(); if ((linkList != null) && (linkList.size() > 0)) { Link link = null; LabelResourceId nodeLabelId = null; LabelResourceId adjLabelId = null; DeviceId deviceId = null; for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) { link = iterator.next(); adjLabelId = pceStore.getAdjLabel(link); if (adjLabelId == null) { log.error("Adjacency label id is null for a link {}.", link.toString()); return null; } labelStack.add(adjLabelId); deviceId = link.dst().deviceId(); nodeLabelId = pceStore.getGlobalNodeLabel(deviceId); if (nodeLabelId == null) { log.error("Unable to find node label for a device id {} in store.", deviceId.toString()); return null; } labelStack.add(nodeLabelId); } } else { log.debug("Empty link in path."); return null; } return new DefaultLabelStack(labelStack); } private  PceccSrTeBeHandler(); }
PceccSrTeBeHandler { public LabelStack computeLabelStack(Path path) { checkNotNull(path, PATH_NULL); List<LabelResourceId> labelStack = new LinkedList<>(); List<Link> linkList = path.links(); if ((linkList != null) && (linkList.size() > 0)) { Link link = null; LabelResourceId nodeLabelId = null; LabelResourceId adjLabelId = null; DeviceId deviceId = null; for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) { link = iterator.next(); adjLabelId = pceStore.getAdjLabel(link); if (adjLabelId == null) { log.error("Adjacency label id is null for a link {}.", link.toString()); return null; } labelStack.add(adjLabelId); deviceId = link.dst().deviceId(); nodeLabelId = pceStore.getGlobalNodeLabel(deviceId); if (nodeLabelId == null) { log.error("Unable to find node label for a device id {} in store.", deviceId.toString()); return null; } labelStack.add(nodeLabelId); } } else { log.debug("Empty link in path."); return null; } return new DefaultLabelStack(labelStack); } 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 LabelStack computeLabelStack(Path path) { checkNotNull(path, PATH_NULL); List<LabelResourceId> labelStack = new LinkedList<>(); List<Link> linkList = path.links(); if ((linkList != null) && (linkList.size() > 0)) { Link link = null; LabelResourceId nodeLabelId = null; LabelResourceId adjLabelId = null; DeviceId deviceId = null; for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) { link = iterator.next(); adjLabelId = pceStore.getAdjLabel(link); if (adjLabelId == null) { log.error("Adjacency label id is null for a link {}.", link.toString()); return null; } labelStack.add(adjLabelId); deviceId = link.dst().deviceId(); nodeLabelId = pceStore.getGlobalNodeLabel(deviceId); if (nodeLabelId == null) { log.error("Unable to find node label for a device id {} in store.", deviceId.toString()); return null; } labelStack.add(nodeLabelId); } } else { log.debug("Empty link in path."); return null; } return new DefaultLabelStack(labelStack); } 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);  }