Constants for service type
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / graph / PostAlgoPathValidator.java
index 2aa455cb73951528cee6ee3c2e24d8e15a4c2d5c..047d248a99022ee2d8facd93c388a0ae5f3be9a2 100644 (file)
@@ -8,19 +8,20 @@
 
 package org.opendaylight.transportpce.pce.graph;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import org.jgrapht.GraphPath;
 import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.common.StringConstants;
 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.openroadm.network.types.rev181130.OpenroadmLinkType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
 import org.opendaylight.yangtools.yang.common.Uint16;
 import org.slf4j.Logger;
@@ -37,6 +38,9 @@ public class PostAlgoPathValidator {
     public static final Long CONST_OSNR = 1L;
     public static final double SYS_MARGIN = 0;
 
+    @SuppressFBWarnings(
+        value = "SF_SWITCH_FALLTHROUGH",
+        justification = "intentional fallthrough")
     public PceResult checkPath(GraphPath<String, PceGraphEdge> path, Map<NodeId, PceNode> allPceNodes,
         PceResult pceResult, PceConstraints pceHardConstraints, String serviceType) {
 
@@ -50,8 +54,8 @@ public class PostAlgoPathValidator {
         //variable to deal with 1GE (Nb=1) and 10GE (Nb=10) cases
         switch (serviceType) {
 
-            case "100GE":
-            case "OTU4":
+            case StringConstants.SERVICE_TYPE_100GE:
+            case StringConstants.SERVICE_TYPE_OTU4:
                 // choose wavelength available in all nodes of the path
                 Long waveL = chooseWavelength(path, allPceNodes);
                 pceResult.setServiceType(serviceType);
@@ -93,10 +97,10 @@ public class PostAlgoPathValidator {
 
                 break;
 
-            case "10GE":
-                tribSlotNb = 10;
+            case StringConstants.SERVICE_TYPE_10GE:
+                tribSlotNb = 8;
             //fallthrough
-            case "1GE":
+            case StringConstants.SERVICE_TYPE_1GE:
                 pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
                 pceResult.setServiceType(serviceType);
                 Map<String, Uint16> tribPort = chooseTribPort(path, allPceNodes);
@@ -112,7 +116,7 @@ public class PostAlgoPathValidator {
                 }
                 break;
 
-            case "ODU4":
+            case StringConstants.SERVICE_TYPE_ODU4:
                 pceResult.setRC(ResponseCodes.RESPONSE_OK);
                 LOG.info("In PostAlgoPathValidator: ODU4 path found {}", path);
                 break;
@@ -303,7 +307,7 @@ public class PostAlgoPathValidator {
 
     private Map<String, List<Uint16>> chooseTribSlot(GraphPath<String,
         PceGraphEdge> path, Map<NodeId, PceNode> allPceNodes, int nbSlot) {
-        LOG.info("In choosetribSlot2: edgeList = {} ", path.getEdgeList());
+        LOG.info("In choosetribSlot: edgeList = {} ", path.getEdgeList());
         Map<String, List<Uint16>> tribSlotMap = new HashMap<>();
 
         for (PceGraphEdge edge : path.getEdgeList()) {
@@ -345,61 +349,6 @@ public class PostAlgoPathValidator {
         return tribSlotMap;
     }
 
-    private List<List<Uint16>> chooseTribSlot3(GraphPath<String, PceGraphEdge> path,
-        Map<NodeId, PceNode> allPceNodes) {
-        List<List<Uint16>> tribSlot = new ArrayList<>();
-        boolean statusOK = true;
-        boolean check = false;
-        Object nodeClass = allPceNodes.getClass();
-        if (nodeClass.getClass().isInstance(PceNode.class)) {
-            LOG.debug("In choosetribSlot: AllPceNodes contains PceNode instance, no trib port search");
-            return tribSlot;
-        } else if (nodeClass.getClass().isInstance(PceNode.class)) {
-            LOG.debug("In choosetribPort: {} {}", path.getLength(), path);
-        }
-        for (PceGraphEdge edge : path.getEdgeList()) {
-            LOG.debug("In chooseTribSlot: source {} ", edge.link().getSourceId());
-            PceNode pceNode = allPceNodes.get(edge.link().getSourceId());
-            Object tps = allPceNodes.get(edge.link().getSourceTP());
-            Object tpd = allPceNodes.get(edge.link().getDestTP());
-            if ((pceNode.getAvailableTribSlots().containsKey(tps.toString()))
-                && (pceNode.getAvailableTribSlots().containsKey(tpd.toString()))) {
-                List<Uint16> tribSlotEdgeSourceN = pceNode.getAvailableTribSlots().get(tps.toString());
-                List<Uint16> tribSlotEdgeDestN = pceNode.getAvailableTribSlots().get(tps.toString());
-                check = false;
-                for (int i = 0; i <= 79; i++) {
-                    if (tribSlotEdgeSourceN.get(i) == null) {
-                        break;
-                    }
-                    // TODO This will need to be modified as soon as the trib-slots allocation per
-                    // trib-port
-                    // policy applied by the different manufacturer is known
-                    if (tribSlotEdgeSourceN.get(i).equals(tribSlotEdgeDestN.get(i))) {
-                        check = true;
-                    } else {
-                        check = false;
-                        LOG.debug("In chooseTribSlot: Misalignement of trib slots between source {} and dest {}",
-                            edge.link().getSourceId(), edge.link().getDestId());
-                        break;
-                    }
-                }
-                if (check) {
-                    tribSlot.add(tribSlotEdgeSourceN);
-                }
-            } else {
-                LOG.debug("In chooseTribSlot: source {} does not have provisonned hosting HO interface ",
-                    edge.link().getSourceId());
-                statusOK = false;
-            }
-        }
-        if (statusOK && check) {
-            return tribSlot;
-        } else {
-            tribSlot.clear();
-            return tribSlot;
-        }
-    }
-
     // Check the path OSNR
     private boolean checkOSNR(GraphPath<String, PceGraphEdge> path) {
         double linkOsnrDb;