From cc27e4f4df5cd15f87dd9da0a48d79f6b12622e1 Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Thu, 14 Dec 2023 15:23:10 +0100 Subject: [PATCH] PCE graph spectrum assignment slight refactoring JIRA: TRNSPRTPCE-772 Signed-off-by: guillaume.lambert Change-Id: Ib4210d7fe451e9be673f11eb9860e07a2665f351 --- .../pce/graph/PostAlgoPathValidator.java | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java index 32624da2f..537d3022c 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java @@ -1009,41 +1009,44 @@ public class PostAlgoPathValidator { Set pceNodes = new LinkedHashSet<>(); for (PceGraphEdge edge : path.getEdgeList()) { - PceLink link = edge.link(); - LOG.debug("Processing {} to {}", link.getSourceId().getValue(), link.getDestId().getValue()); - if (allPceNodes.containsKey(link.getSourceId())) { - pceNodes.add(allPceNodes.get(link.getSourceId())); + NodeId srcId = edge.link().getSourceId(); + NodeId dstId = edge.link().getDestId(); + LOG.debug("Processing {} to {}", srcId.getValue(), dstId.getValue()); + if (allPceNodes.containsKey(srcId)) { + pceNodes.add(allPceNodes.get(srcId)); } - if (allPceNodes.containsKey(link.getDestId())) { - pceNodes.add(allPceNodes.get(link.getDestId())); + if (allPceNodes.containsKey(dstId)) { + pceNodes.add(allPceNodes.get(dstId)); } } for (PceNode pceNode : pceNodes) { LOG.debug("Processing PCE node {}", pceNode); + pceNodeFreqMap = pceNode.getBitSetData(); + LOG.debug("Pce node bitset {}", pceNodeFreqMap); + if (pceNodeFreqMap != null) { + result.and(pceNodeFreqMap); + LOG.debug("intermediate bitset {}", result); + } String pceNodeVersion = pceNode.getVersion(); - NodeId pceNodeId = pceNode.getNodeId(); BigDecimal sltWdthGran = pceNode.getSlotWidthGranularity(); - BigDecimal ctralFreqGran = pceNode.getCentralFreqGranularity(); if (StringConstants.OPENROADM_DEVICE_VERSION_1_2_1.equals(pceNodeVersion)) { - LOG.debug("Node {}: version is {} and slot width granularity is {} -> fixed grid mode", - pceNodeId, pceNodeVersion, sltWdthGran); + LOG.debug("Node {}: version is {} with slot width granularity {} - fixed grid mode", + pceNode.getNodeId(), pceNodeVersion, sltWdthGran); isFlexGrid = false; + continue; } - if (sltWdthGran.setScale(0, RoundingMode.CEILING).equals(GridConstant.SLOT_WIDTH_50) - && ctralFreqGran.setScale(0, RoundingMode.CEILING).equals(GridConstant.SLOT_WIDTH_50)) { - LOG.debug("Node {}: version is {} with slot width granularity {} and central " - + "frequency granularity is {} -> fixed grid mode", - pceNodeId, pceNodeVersion, sltWdthGran, ctralFreqGran); - isFlexGrid = false; + if (!sltWdthGran.setScale(0, RoundingMode.CEILING).equals(GridConstant.SLOT_WIDTH_50)) { + continue; } - pceNodeFreqMap = pceNode.getBitSetData(); - LOG.debug("Pce node bitset {}", pceNodeFreqMap); - if (pceNodeFreqMap != null) { - result.and(pceNodeFreqMap); - LOG.debug("intermediate bitset {}", result); + BigDecimal ctralFreqGran = pceNode.getCentralFreqGranularity(); + if (!ctralFreqGran.setScale(0, RoundingMode.CEILING).equals(GridConstant.SLOT_WIDTH_50)) { + continue; } - + LOG.debug( + "Node {}: version is {} with slot width and central frequency granularities {} {} - fixed grid mode", + pceNode.getNodeId(), pceNodeVersion, sltWdthGran, ctralFreqGran); + isFlexGrid = false; } LOG.debug("Bitset result {}", result); return computeBestSpectrumAssignment(result, spectralWidthSlotNumber, isFlexGrid); -- 2.36.6