X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fgraph%2FPostAlgoPathValidator.java;h=960ae3bc1e6e407399d5aa99b40b042e11631d6a;hb=66f6af8141d231619ad9d6e6133910e14f3a32e2;hp=39e278e9344641c3d00e336edcde55bd0700b401;hpb=e458fb786a55cfdfe85e25a2083b67e9d38e21a9;p=transportpce.git 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 39e278e93..960ae3bc1 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 @@ -9,6 +9,7 @@ package org.opendaylight.transportpce.pce.graph; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; @@ -16,6 +17,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.jgrapht.GraphPath; import org.opendaylight.transportpce.common.ResponseCodes; import org.opendaylight.transportpce.common.StringConstants; @@ -25,9 +27,9 @@ import org.opendaylight.transportpce.pce.constraints.PceConstraints; import org.opendaylight.transportpce.pce.constraints.PceConstraints.ResourcePair; import org.opendaylight.transportpce.pce.networkanalyzer.PceNode; import org.opendaylight.transportpce.pce.networkanalyzer.PceResult; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev210701.SpectrumAssignment; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev210701.SpectrumAssignmentBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220615.SpectrumAssignment; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220615.SpectrumAssignmentBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmLinkType; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.OpucnTribSlotDef; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId; import org.opendaylight.yangtools.yang.common.Uint16; @@ -44,6 +46,7 @@ public class PostAlgoPathValidator { public static final Long CONST_OSNR = 1L; public static final double SYS_MARGIN = 0; + @SuppressWarnings("fallthrough") @SuppressFBWarnings( value = "SF_SWITCH_FALLTHROUGH", justification = "intentional fallthrough") @@ -60,6 +63,8 @@ public class PostAlgoPathValidator { SpectrumAssignment spectrumAssignment = null; //variable to deal with 1GE (Nb=1) and 10GE (Nb=10) cases switch (serviceType) { + case StringConstants.SERVICE_TYPE_OTUC2: + case StringConstants.SERVICE_TYPE_OTUC3: case StringConstants.SERVICE_TYPE_OTUC4: case StringConstants.SERVICE_TYPE_400GE: spectralWidthSlotNumber = GridConstant.SPECTRAL_WIDTH_SLOT_NUMBER_MAP @@ -138,9 +143,13 @@ public class PostAlgoPathValidator { } break; case StringConstants.SERVICE_TYPE_ODU4: + case StringConstants.SERVICE_TYPE_ODUC2: + case StringConstants.SERVICE_TYPE_ODUC3: case StringConstants.SERVICE_TYPE_ODUC4: + case StringConstants.SERVICE_TYPE_100GE_S: pceResult.setRC(ResponseCodes.RESPONSE_OK); - LOG.info("In PostAlgoPathValidator: ODU4/ODUC4 path found {}", path); + pceResult.setServiceType(serviceType); + LOG.info("In PostAlgoPathValidator: ODU4/ODUCn path found {}", path); break; default: pceResult.setRC(ResponseCodes.RESPONSE_FAILED); @@ -156,13 +165,13 @@ public class PostAlgoPathValidator { double latency = 0; for (PceGraphEdge edge : path.getEdgeList()) { - try { - latency += edge.link().getLatency(); - LOG.debug("- In checkLatency: latency of {} = {} units", edge.link().getLinkId().getValue(), latency); - } catch (NullPointerException e) { + if (edge.link() == null || edge.link().getLatency() == null) { LOG.warn("- In checkLatency: the link {} does not contain latency field", edge.link().getLinkId().getValue()); + return false; } + latency += edge.link().getLatency(); + LOG.debug("- In checkLatency: latency of {} = {} units", edge.link().getLinkId().getValue(), latency); } return (latency < maxLatency); } @@ -194,42 +203,19 @@ public class PostAlgoPathValidator { pceHardConstraintsInput)); // validation: check each type for each element - for (ResourcePair next : listToInclude) { - int indx = -1; - switch (next.getType()) { - case NODE: - if (listOfElementsSubNode.contains(next.getName())) { - indx = listOfElementsSubNode.indexOf(next.getName()); - } - break; - case SRLG: - if (listOfElementsSRLG.contains(next.getName())) { - indx = listOfElementsSRLG.indexOf(next.getName()); - } - break; - case CLLI: - if (listOfElementsCLLI.contains(next.getName())) { - indx = listOfElementsCLLI.indexOf(next.getName()); - } - break; - default: - LOG.warn(" in checkInclude vertex list unsupported resource type: [{}]", next.getType()); - } - - if (indx < 0) { - LOG.debug(" in checkInclude stopped : {} ", next.getName()); - return false; - } - - LOG.debug(" in checkInclude next found {} in {}", next.getName(), path.getVertexList()); - - listOfElementsSubNode.subList(0, indx).clear(); - listOfElementsCLLI.subList(0, indx).clear(); - listOfElementsSRLG.subList(0, indx).clear(); - } - - LOG.info(" in checkInclude passed : {} ", path.getVertexList()); - return true; + List listNodeToInclude = listToInclude + .stream().filter(rp -> PceConstraints.ResourceType.NODE.equals(rp.getType())) + .map(ResourcePair::getName).collect(Collectors.toList()); + List listSrlgToInclude = listToInclude + .stream().filter(rp -> PceConstraints.ResourceType.SRLG.equals(rp.getType())) + .map(ResourcePair::getName).collect(Collectors.toList()); + List listClliToInclude = listToInclude + .stream().filter(rp -> PceConstraints.ResourceType.CLLI.equals(rp.getType())) + .map(ResourcePair::getName).collect(Collectors.toList()); + + return listOfElementsSubNode.containsAll(listNodeToInclude) + && listOfElementsSRLG.containsAll(listSrlgToInclude) + && listOfElementsCLLI.containsAll(listClliToInclude); } private List listOfElementsBuild(List pathEdges, PceConstraints.ResourceType type, @@ -294,7 +280,7 @@ public class PostAlgoPathValidator { commonEdgeTpnPool.add(srcTpn); } } - Collections.sort(commonEdgeTpnPool); + if (!commonEdgeTpnPool.isEmpty()) { Integer startTribSlot = tribSlotMap.values().stream().findFirst().get().get(0).toJava(); Integer tribPort = (int) Math.ceil((double)startTribSlot / nbSlot); @@ -440,9 +426,11 @@ public class PostAlgoPathValidator { pceNode.getNodeId(), pceNode.getVersion(), pceNode.getSlotWidthGranularity()); isFlexGrid = false; } - if ((pceNode.getSlotWidthGranularity().equals(GridConstant.SLOT_WIDTH_50)) - && (pceNode.getCentralFreqGranularity().equals(GridConstant.SLOT_WIDTH_50))) { - LOG.info("Node {}: version is {} with slot width granularity {} and central " + if ((pceNode.getSlotWidthGranularity().setScale(0, RoundingMode.CEILING) + .equals(GridConstant.SLOT_WIDTH_50)) + && (pceNode.getCentralFreqGranularity().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", pceNode.getNodeId(), pceNode.getVersion(), pceNode.getSlotWidthGranularity(), pceNode.getCentralFreqGranularity());