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=61e7f145aa52e840d302b93e5cd0cae3b06e977a;hb=6b6a445c84c2eb1c85d4e48c2d10a89c3d598bc5;hp=d9b31d76b4978eaab72e443ba32c1e89f3be0ab8;hpb=6067e755ff30476a33ca409a24f148e231995c98;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 d9b31d76b..61e7f145a 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 @@ -25,9 +25,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.rev220118.SpectrumAssignment; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.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 +44,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") @@ -55,12 +56,13 @@ public class PostAlgoPathValidator { pceResult.setRC(ResponseCodes.RESPONSE_FAILED); return pceResult; } - int tribSlotNb = 1; int spectralWidthSlotNumber = GridConstant.SPECTRAL_WIDTH_SLOT_NUMBER_MAP .getOrDefault(serviceType, GridConstant.NB_SLOTS_100G); 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 @@ -120,18 +122,11 @@ public class PostAlgoPathValidator { case StringConstants.SERVICE_TYPE_100GE_M: case StringConstants.SERVICE_TYPE_10GE: case StringConstants.SERVICE_TYPE_1GE: - if (StringConstants.SERVICE_TYPE_100GE_M.equals(serviceType)) { - tribSlotNb = 20; - } else if (StringConstants.SERVICE_TYPE_10GE.equals(serviceType)) { - tribSlotNb = 8; - } else if (StringConstants.SERVICE_TYPE_1GE.equals(serviceType)) { - tribSlotNb = 1; - } else { - pceResult.setRC(ResponseCodes.RESPONSE_FAILED); - LOG.warn("In PostAlgoPathValidator checkPath: unsupported serviceType {} found {}", - serviceType, path); - break; - } + Map tribSlotNbMap = Map.of( + StringConstants.SERVICE_TYPE_100GE_M, 20, + StringConstants.SERVICE_TYPE_10GE, 8, + StringConstants.SERVICE_TYPE_1GE, 1); + int tribSlotNb = tribSlotNbMap.get(serviceType); pceResult.setRC(ResponseCodes.RESPONSE_FAILED); pceResult.setServiceType(serviceType); Map> tribSlot = chooseTribSlot(path, allPceNodes, tribSlotNb); @@ -146,9 +141,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); @@ -164,13 +163,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); } @@ -289,9 +288,9 @@ public class PostAlgoPathValidator { for (PceGraphEdge edge : path.getEdgeList()) { NodeId linkSrcNode = edge.link().getSourceId(); - String linkSrcTp = edge.link().getSourceTP().toString(); + String linkSrcTp = edge.link().getSourceTP().getValue(); NodeId linkDestNode = edge.link().getDestId(); - String linkDestTp = edge.link().getDestTP().toString(); + String linkDestTp = edge.link().getDestTP().getValue(); PceNode pceOtnNodeSrc = allPceNodes.get(linkSrcNode); PceNode pceOtnNodeDest = allPceNodes.get(linkDestNode); List srcTpnPool = pceOtnNodeSrc.getAvailableTribPorts().get(linkSrcTp); @@ -324,9 +323,9 @@ public class PostAlgoPathValidator { for (PceGraphEdge edge : path.getEdgeList()) { NodeId linkSrcNode = edge.link().getSourceId(); - String linkSrcTp = edge.link().getSourceTP().toString(); + String linkSrcTp = edge.link().getSourceTP().getValue(); NodeId linkDestNode = edge.link().getDestId(); - String linkDestTp = edge.link().getDestTP().toString(); + String linkDestTp = edge.link().getDestTP().getValue(); PceNode pceOtnNodeSrc = allPceNodes.get(linkSrcNode); PceNode pceOtnNodeDest = allPceNodes.get(linkDestNode); List srcTsPool = pceOtnNodeSrc.getAvailableTribSlots().get(linkSrcTp); @@ -341,9 +340,8 @@ public class PostAlgoPathValidator { Collections.sort(commonEdgeTsPoolList); List commonGoodStartEdgeTsPoolList = new ArrayList<>(); for (Uint16 startEdgeTsPool : commonEdgeTsPoolList) { - if (Integer.valueOf(1).equals(startEdgeTsPool.toJava() % nbSlot)) { - commonGoodStartEdgeTsPoolList.add(startEdgeTsPool); - } else if (nbSlot == 1) { + if (Integer.valueOf(1).equals(startEdgeTsPool.toJava() % nbSlot) + || nbSlot == 1) { commonGoodStartEdgeTsPoolList.add(startEdgeTsPool); } } @@ -353,15 +351,14 @@ public class PostAlgoPathValidator { int goodStartIndex = commonEdgeTsPoolList.indexOf(Uint16.valueOf(goodStartTsPool.intValue())); if (!goodTsList && commonEdgeTsPoolList.size() - goodStartIndex >= nbSlot) { for (int i = 0; i < nbSlot; i++) { - if (commonEdgeTsPoolList.get(goodStartIndex + i) + if (!commonEdgeTsPoolList.get(goodStartIndex + i) .equals(Uint16.valueOf(goodStartTsPool.toJava() + i))) { - tribSlotList.add(commonEdgeTsPoolList.get(goodStartIndex + i)); - goodTsList = true; - } else { goodTsList = false; tribSlotList.clear(); break; } + tribSlotList.add(commonEdgeTsPoolList.get(goodStartIndex + i)); + goodTsList = true; } } } @@ -412,15 +409,12 @@ public class PostAlgoPathValidator { } private double getOsnrDb(double osnrLu) { - double osnrDb; - osnrDb = 10 * Math.log10(osnrLu); - return osnrDb; + return (10 * Math.log10(osnrLu)); } private double getInverseOsnrLinkLu(double linkOsnrDb) { // 1 over the link OSNR, in linear units - double linkOsnrLu; - linkOsnrLu = Math.pow(10, (linkOsnrDb / 10.0)); + double linkOsnrLu = Math.pow(10, (linkOsnrDb / 10.0)); LOG.debug("In retrieveosnr: the inverse of link osnr is {} (Linear Unit)", linkOsnrLu); return (CONST_OSNR / linkOsnrLu); } @@ -490,10 +484,7 @@ public class PostAlgoPathValidator { .setFlexGrid(isFlexGrid); BitSet referenceBitSet = new BitSet(spectralWidthSlotNumber); referenceBitSet.set(0, spectralWidthSlotNumber); - int nbSteps = 1; - if (isFlexGrid) { - nbSteps = spectralWidthSlotNumber; - } + int nbSteps = isFlexGrid ? spectralWidthSlotNumber : 1; //higher is the frequency, smallest is the wavelength number //in operational, the allocation is done through wavelength starting from the smallest //so we have to loop from the last element of the spectrum occupation @@ -506,4 +497,4 @@ public class PostAlgoPathValidator { } return spectrumAssignmentBldr.build(); } -} \ No newline at end of file +}