From: orenais Date: Fri, 6 Jan 2023 15:12:32 +0000 (+0100) Subject: Refactor few LOG messages management X-Git-Tag: 7.0.0~55^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=refs%2Fchanges%2F42%2F103942%2F3 Refactor few LOG messages management Signed-off-by: guillaume.lambert Change-Id: I192894a27950ea3e70b5d05e91c61a7c958dd996 --- diff --git a/common/src/main/java/org/opendaylight/transportpce/common/catalog/CatalogUtils.java b/common/src/main/java/org/opendaylight/transportpce/common/catalog/CatalogUtils.java index 3737a3386..f4a807f8c 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/catalog/CatalogUtils.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/catalog/CatalogUtils.java @@ -424,12 +424,14 @@ public class CatalogUtils { .filter(val -> val.getUpToBoundary().doubleValue() >= calculatedParameter) // takes the immediate greater or equal value .findFirst().orElse(null); - return penalty == null + if (penalty == null) { //means a boundary that is greater than calculatedParameter couldn't be found // Out of specification! - ? 9999.9 - // In spec, return penalty associated with calculatedParameter - : penalty.getPenaltyValue().getValue().doubleValue(); + return 9999.9; + } + // In spec, return penalty associated with calculatedParameter + LOG.info("Penalty for {} is {} dB", impairmentType, penalty.getPenaltyValue().getValue().doubleValue()); + return penalty.getPenaltyValue().getValue().doubleValue(); } /** diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java index 5b59a4c07..583ac4572 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java @@ -101,11 +101,8 @@ public class PceGraph { if (ResponseCodes.RESPONSE_OK.equals(pceResult.getResponseCode())) { LOG.info("Path is validated"); } else { - LOG.warn("Path not validated - cause: {}", pceResult.getLocalCause()); - } - - if (!pceResult.getResponseCode().equals(ResponseCodes.RESPONSE_OK)) { - LOG.warn("In calcPath: post algo validations DROPPED the path {}", path); + LOG.warn("In calcPath: post algo validations DROPPED the path {}; for following cause: {}", + path, pceResult.getLocalCause()); continue; } diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/MapUtils.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/MapUtils.java index 1dcf97e24..fcb038686 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/MapUtils.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/MapUtils.java @@ -222,11 +222,14 @@ public final class MapUtils { } public static LinkId extractOppositeLink(Link link) { - LinkId tmpoppositeLink = null; - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1 linkOpposite + var linkOpposite = link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1.class); - tmpoppositeLink = linkOpposite.getOppositeLink(); + if (linkOpposite == null) { + LOG.error("No opposite link augmentation for network link {}", link); + return null; + } LOG.debug("PceLink: reading oppositeLink. {}", linkOpposite); + LinkId tmpoppositeLink = linkOpposite.getOppositeLink(); if (tmpoppositeLink == null) { LOG.error("PceLink: Error reading oppositeLink. Link is ignored {}", link.getLinkId().getValue()); return null; @@ -234,5 +237,4 @@ public final class MapUtils { return tmpoppositeLink; } - } diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java index 0592bbcab..e5b5b4caa 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java @@ -92,7 +92,8 @@ public class PceOpticalNode implements PceNode { this.state = node.augmentation(org.opendaylight.yang.gen.v1.http .org.openroadm.common.network.rev211210.Node1.class).getOperationalState(); } else { - LOG.error("PceNode: one of parameters is not populated : nodeId, node type, slot width granularity"); + LOG.error("PceNode {} : one of parameters is not populated : nodeId, node type, slot width granularity", + deviceNodeId); this.valid = false; } } @@ -264,8 +265,12 @@ public class PceOpticalNode implements PceNode { return; } for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network - .node.TerminationPoint tp : allTps) { + .node.TerminationPoint tp : allTps) { TerminationPoint1 cntp1 = tp.augmentation(TerminationPoint1.class); + if (cntp1 == null) { + LOG.error("initXndrTps: {} - {} has no tp type", this.nodeId, tp.getTpId().toString()); + continue; + } if (cntp1.getTpType() != OpenroadmTpType.XPONDERNETWORK) { LOG.debug("initXndrTps: {} is not an Xponder network port", cntp1.getTpType().getName()); continue; @@ -381,9 +386,9 @@ public class PceOpticalNode implements PceNode { public boolean isValid() { if (node == null || nodeId == null || nodeType == null || this.getSupNetworkNodeId() == null - || this.getSupClliNodeId() == null || adminStates == null || state == null) { - LOG.error("PceNode: one of parameters is not populated : nodeId, node type, supporting nodeId, " - + "admin state, operational state"); + || this.getSupClliNodeId() == null || adminStates == null || state == null) { + LOG.error("PceNode {}, nodeId {} NodeType {} : one of parameters is not populated : nodeId, node type," + + " supporting nodeId, admin state, operational state", deviceNodeId, nodeId, nodeType); valid = false; } return valid;