Refactor code after Chlorine Bump
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / networkanalyzer / PceCalculation.java
index a817bec4aaed44050e6d259f0b4288c60f09a309..c419727d212e99d9ca8817a05ef86742c8927fc4 100644 (file)
@@ -33,14 +33,10 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev22
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mc.capabilities.McCapabilities;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1;
-//import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
-//import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmLinkType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
-//import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType;
-//import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
@@ -58,7 +54,7 @@ import org.slf4j.LoggerFactory;
 public class PceCalculation {
     /* Logging. */
     private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class);
-    private NetworkTransactionService networkTransactionService = null;
+    private NetworkTransactionService networkTransactionService;
 
     ///////////// data parsed from Input/////////////////
     private PathComputationRequestInput input;
@@ -112,7 +108,7 @@ public class PceCalculation {
 
     public void retrievePceNetwork() {
 
-        LOG.info("In PceCalculation retrieveNetwork: ");
+        LOG.debug("In PceCalculation retrieveNetwork");
 
         if (!readMdSal()) {
             returnStructure.setRC(ResponseCodes.RESPONSE_FAILED);
@@ -127,7 +123,6 @@ public class PceCalculation {
         printNodesInfo(allPceNodes);
 
         returnStructure.setRC(ResponseCodes.RESPONSE_OK);
-        return;
     }
 
     private boolean parseInput() {
@@ -150,7 +145,7 @@ public class PceCalculation {
                     input.getServiceAEnd().getTxDirection().getPort().getPortName())
                 : null);
 
-        LOG.info("parseInput: A and Z :[{}] and [{}]", anodeId, znodeId);
+        LOG.debug("parseInput: A and Z :[{}] and [{}]", anodeId, znodeId);
 
         getAZnodeId();
 
@@ -202,7 +197,7 @@ public class PceCalculation {
             case StringConstants.SERVICE_TYPE_OTUC2:
             case StringConstants.SERVICE_TYPE_OTUC3:
             case StringConstants.SERVICE_TYPE_OTUC4:
-                LOG.info("readMdSal: network {}", NetworkUtils.OVERLAY_NETWORK_ID);
+                LOG.debug("readMdSal: network {}", NetworkUtils.OVERLAY_NETWORK_ID);
                 nwInstanceIdentifier = InstanceIdentifier.builder(Networks.class)
                     .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
                 break;
@@ -214,7 +209,7 @@ public class PceCalculation {
             case StringConstants.SERVICE_TYPE_ODUC4:
             case StringConstants.SERVICE_TYPE_10GE:
             case StringConstants.SERVICE_TYPE_1GE:
-                LOG.info("readMdSal: network {}", NetworkUtils.OTN_NETWORK_ID);
+                LOG.debug("readMdSal: network {}", NetworkUtils.OTN_NETWORK_ID);
                 nwInstanceIdentifier = InstanceIdentifier.builder(Networks.class)
                     .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID))).build();
                 break;
@@ -270,8 +265,6 @@ public class PceCalculation {
             LOG.error("readMdSal: Error reading topology {}", nwInstanceIdentifier);
             networkTransactionService.close();
             returnStructure.setRC(ResponseCodes.RESPONSE_FAILED);
-            throw new RuntimeException(
-                "readMdSal: Error reading from operational store, topology : " + nwInstanceIdentifier + " :" + e);
         }
         return nw;
     }
@@ -384,7 +377,7 @@ public class PceCalculation {
     }
 
     private boolean validateLink(Link link) {
-        LOG.info("validateLink: link {} ", link);
+        LOG.debug("validateLink: link {} ", link);
 
         NodeId sourceId = link.getSource().getSourceNode();
         NodeId destId = link.getDestination().getDestNode();
@@ -433,7 +426,7 @@ public class PceCalculation {
     }
 
     private void validateNode(Node node) {
-        LOG.info("validateNode: node {} ", node);
+        LOG.debug("validateNode: node {} ", node);
         // PceNode will be used in Graph algorithm
         Node1 node1 = node.augmentation(Node1.class);
         if (node1 == null) {
@@ -453,7 +446,7 @@ public class PceCalculation {
             deviceNodeId = node.getNodeId().getValue();
         }
 
-        LOG.info("Device node id {} for {}", deviceNodeId, node);
+        LOG.debug("Device node id {} for {}", deviceNodeId, node);
         PceOpticalNode pceNode = new PceOpticalNode(deviceNodeId, this.serviceType, portMapping, node, nodeType,
             mappingUtils.getOpenRoadmVersion(deviceNodeId), getSlotWidthGranularity(deviceNodeId, node.getNodeId()),
             getCentralFreqGranularity(deviceNodeId, node.getNodeId()));
@@ -461,7 +454,7 @@ public class PceCalculation {
         pceNode.initFrequenciesBitSet();
 
         if (!pceNode.isValid()) {
-            LOG.warn(" validateNode: Node is ignored");
+            LOG.debug(" validateNode: Node {} is ignored", node.getNodeId().getValue());
             return;
         }
         if (validateNodeConstraints(pceNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
@@ -474,7 +467,7 @@ public class PceCalculation {
                 List<Link> links = this.allLinks.stream()
                     .filter(x -> x.getSource().getSourceNode().getValue().contains(pceNode.getNodeId().getValue()))
                     .collect(Collectors.toList());
-                if (links.size() > 0) {
+                if (!links.isEmpty()) {
                     this.aendPceNode = pceNode;
                 }
             }
@@ -483,7 +476,7 @@ public class PceCalculation {
                 List<Link> links = this.allLinks.stream()
                     .filter(x -> x.getDestination().getDestNode().getValue().contains(pceNode.getNodeId().getValue()))
                     .collect(Collectors.toList());
-                if (links.size() > 0) {
+                if (!links.isEmpty()) {
                     this.zendPceNode = pceNode;
                 }
             }
@@ -491,7 +484,6 @@ public class PceCalculation {
 
         allPceNodes.put(pceNode.getNodeId(), pceNode);
         LOG.debug("validateNode: node is saved {}", pceNode.getNodeId().getValue());
-        return;
     }
 
     @SuppressWarnings("fallthrough")
@@ -569,7 +561,6 @@ public class PceCalculation {
         }
         allPceNodes.put(pceOtnNode.getNodeId(), pceOtnNode);
         LOG.info("validateOtnNode: node {} is saved", node.getNodeId().getValue());
-        return;
     }
 
     private ConstraintTypes validateNodeConstraints(PceNode pcenode) {
@@ -577,11 +568,11 @@ public class PceCalculation {
             return ConstraintTypes.NONE;
         }
         if (pceHardConstraints.getExcludeSupNodes().contains(pcenode.getSupNetworkNodeId())) {
-            LOG.info("validateNodeConstraints: {}", pcenode.getNodeId().getValue());
+            LOG.debug("validateNodeConstraints: {}", pcenode.getNodeId().getValue());
             return ConstraintTypes.HARD_EXCLUDE;
         }
         if (pceHardConstraints.getExcludeCLLI().contains(pcenode.getSupClliNodeId())) {
-            LOG.info("validateNodeConstraints: {}", pcenode.getNodeId().getValue());
+            LOG.debug("validateNodeConstraints: {}", pcenode.getNodeId().getValue());
             return ConstraintTypes.HARD_EXCLUDE;
         }
         return ConstraintTypes.NONE;
@@ -600,7 +591,7 @@ public class PceCalculation {
         List<Long> constraints = new ArrayList<>(pceHardConstraints.getExcludeSRLG());
         constraints.retainAll(link.getsrlgList());
         if (!constraints.isEmpty()) {
-            LOG.info("validateLinkConstraints: {}", link.getLinkId().getValue());
+            LOG.debug("validateLinkConstraints: {}", link.getLinkId().getValue());
             return ConstraintTypes.HARD_EXCLUDE;
         }
 
@@ -627,7 +618,7 @@ public class PceCalculation {
                 pceNode.initXndrTps(input.getServiceAEnd().getServiceFormat());
                 break;
             default:
-                LOG.warn("endPceNode: Node {} is not SRG or XPONDER !", nodeId);
+                LOG.debug("endPceNode: Node {} is not SRG or XPONDER !", nodeId);
                 return false;
         }
 
@@ -736,7 +727,7 @@ public class PceCalculation {
                 }
                 allPceLinks.put(linkId, pceOtnLink);
                 source.addOutgoingLink(pceOtnLink);
-                LOG.info("validateLink: OTN-LINK added to allPceLinks {}", pceOtnLink);
+                LOG.debug("validateLink: OTN-LINK added to allPceLinks {}", pceOtnLink);
                 break;
             default:
                 LOG.warn("validateLink: link type is not supported {}", pceOtnLink);
@@ -770,7 +761,7 @@ public class PceCalculation {
 
     private static void printNodesInfo(Map<NodeId, PceNode> allPceNodes) {
         allPceNodes.forEach(((nodeId, pceNode) -> {
-            LOG.info("In printNodes in node {} : outgoing links {} ", pceNode.getNodeId().getValue(),
+            LOG.debug("In printNodes in node {} : outgoing links {} ", pceNode.getNodeId().getValue(),
                     pceNode.getOutgoingLinks());
         }));
     }