Refactor few LOG messages management 42/103942/3
authororenais <olivier.renais@orange.com>
Fri, 6 Jan 2023 15:12:32 +0000 (16:12 +0100)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Wed, 18 Jan 2023 08:53:46 +0000 (08:53 +0000)
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I192894a27950ea3e70b5d05e91c61a7c958dd996

common/src/main/java/org/opendaylight/transportpce/common/catalog/CatalogUtils.java
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/MapUtils.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java

index 3737a33867c0bf8359096772aa49f7a378cf8e17..f4a807f8c7edd5c25e5d276494e0464ccde6f7cf 100644 (file)
@@ -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();
     }
 
     /**
index 5b59a4c07d19667d9ec000ccfd7aa6c9eca6744b..583ac4572580c905ac9d3d918efa6417602fba83 100644 (file)
@@ -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;
             }
 
index 1dcf97e24b5308f3785a1687150f2e1e15a889f3..fcb038686d240226f322dae9808ef6c1e2f95c36 100644 (file)
@@ -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;
     }
 
-
 }
index 0592bbcab8f5888a8a3b09d6b0dd0efc42243244..e5b5b4caab7ad3d0ca8ae15cae1306b7ee3134f9 100644 (file)
@@ -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;