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;
public static final Long CONST_OSNR = 1L;
public static final double SYS_MARGIN = 0;
+ @SuppressWarnings("fallthrough")
@SuppressFBWarnings(
value = "SF_SWITCH_FALLTHROUGH",
justification = "intentional fallthrough")
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
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<String, Integer> 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<String, List<Uint16>> tribSlot = chooseTribSlot(path, allPceNodes, tribSlotNb);
}
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);
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);
}
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<Uint16> srcTpnPool = pceOtnNodeSrc.getAvailableTribPorts().get(linkSrcTp);
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<Uint16> srcTsPool = pceOtnNodeSrc.getAvailableTribSlots().get(linkSrcTp);
Collections.sort(commonEdgeTsPoolList);
List<Uint16> 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);
}
}
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;
}
}
}
}
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);
}
.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
}
return spectrumAssignmentBldr.build();
}
-}
\ No newline at end of file
+}