PCE OTN layer support init
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / graph / PceGraph.java
index f4132e04cc37ba2efac2b76e09faf5a829e5d3d9..c7733ddd5726f903a79cb8d54cc2e18916d48c04 100644 (file)
@@ -35,14 +35,16 @@ public class PceGraph {
 
     ////////////////////////// for Graph ///////////////////////////
     // how many paths to bring
-    int kpathsToBring = 10;
+    private int kpathsToBring = 10;
+
     // max #hops
-    int mhopsPerPath = 50;
+    private int mhopsPerPath = 50;
 
     // input
     private Map<NodeId, PceNode> allPceNodes = new HashMap<NodeId, PceNode>();
     private PceNode apceNode = null;
     private PceNode zpceNode = null;
+    private String serviceType = "";
 
     PceConstraints pceHardConstraints;
     PceConstraints pceSoftConstraints;
@@ -57,7 +59,8 @@ public class PceGraph {
     private List<PceLink> pathAtoZ = new ArrayList<PceLink>();
 
     public PceGraph(PceNode aendNode, PceNode zendNode, Map<NodeId, PceNode> allPceNodes,
-            PceConstraints pceHardConstraints, PceConstraints pceSoftConstraints, PceResult pceResult) {
+            PceConstraints pceHardConstraints, PceConstraints pceSoftConstraints, PceResult pceResult,
+            String serviceType) {
         super();
         this.apceNode = aendNode;
         this.zpceNode = zendNode;
@@ -65,10 +68,10 @@ public class PceGraph {
         this.pceResult = pceResult;
         this.pceHardConstraints = pceHardConstraints;
         this.pceSoftConstraints = pceSoftConstraints;
+        this.serviceType = serviceType;
 
         LOG.info("In GraphCalculator: A and Z = {} / {} ", aendNode.toString(), zendNode.toString());
         LOG.debug("In GraphCalculator: allPceNodes size {}, nodes {} ", allPceNodes.size(), allPceNodes.toString());
-
     }
 
     public boolean calcPath() {
@@ -88,9 +91,8 @@ public class PceGraph {
         // validate found paths
         pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
         for (GraphPath<String, PceGraphEdge> path : allWPaths) {
-
             PostAlgoPathValidator papv = new PostAlgoPathValidator();
-            pceResult = papv.checkPath(path, allPceNodes, pceResult);
+            pceResult = papv.checkPath(path, allPceNodes, pceResult, pceHardConstraints, serviceType);
             LOG.info("In calcPath after PostAlgoPathValidator {} {}",
                     pceResult.getResponseCode(), ResponseCodes.RESPONSE_OK);
 
@@ -106,9 +108,17 @@ public class PceGraph {
             }
 
             shortestPathAtoZ = new ArrayList<>(pathAtoZ);
-            LOG.info("In calcPath Path FOUND path for wl [{}], hops {}, distance per metrics {}, path AtoZ {}",
-                    pceResult.getResultWavelength(), pathAtoZ.size(), path.getWeight(), pathAtoZ.toString());
-            break;
+            if (("100GE".equals(serviceType)) || ("OTU4".equals(serviceType))) {
+                LOG.info("In calcPath Path FOUND path for wl [{}], hops {}, distance per metrics {}, path AtoZ {}",
+                        pceResult.getResultWavelength(), pathAtoZ.size(), path.getWeight(), pathAtoZ.toString());
+                break;
+            } else {
+                // Service is at OTN layer and is relying on a supporting wavelength service
+                LOG.info("In calcPath Path FOUND path for hops {}, distance per metrics {}, path AtoZ {}",
+                        pathAtoZ.size(), path.getWeight(), pathAtoZ.toString());
+                break;
+            }
+
         }
 
         if (shortestPathAtoZ != null) {
@@ -124,16 +134,7 @@ public class PceGraph {
         if (weightedGraph.edgeSet().isEmpty() || weightedGraph.vertexSet().isEmpty()) {
             return false;
         }
-
-        PathValidator<String, PceGraphEdge> wpv = new InAlgoPathValidator(pceHardConstraints, zpceNode);
-
-        // local optimization. if 'include' constraint exists then increase amount of paths to return.
-        // it's because this constraint is checked at the last step when part of good paths
-        // are dropped by other constraints
-        if (!pceHardConstraints.getListToInclude().isEmpty()) {
-            kpathsToBring = kpathsToBring * 10;
-            LOG.info("k = {}",kpathsToBring);
-        }
+        PathValidator<String, PceGraphEdge> wpv = new InAlgoPathValidator();
 
         // KShortestPaths on weightedGraph
         KShortestSimplePaths<String, PceGraphEdge> swp =
@@ -149,7 +150,7 @@ public class PceGraph {
 
         // debug print
         for (GraphPath<String, PceGraphEdge> path : allWPaths) {
-            LOG.info("path Weight: {} : {}", path.getWeight(), path.getVertexList().toString());
+            LOG.debug("path Weight: {} : {}", path.getWeight(), path.getVertexList().toString());
         }
 
         return true;
@@ -232,6 +233,11 @@ public class PceGraph {
             case PropagationDelay :
                 weight = link.getLatency();
                 LOG.debug("In PceGraph PropagationDelay is used as a metrics. {}", link.toString());
+                if ((("1GE".equals(serviceType)) || ("10GE".equals(serviceType)) || ("ODU4".equals(serviceType)))
+                        && (weight == 0)) {
+                    LOG.warn("PropagationDelay set as metric, but latency is null: is latency set for OTN link {}?",
+                        link.toString());
+                }
                 break;
 
             default:
@@ -241,7 +247,18 @@ public class PceGraph {
         return weight;
     }
 
-    ////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    public int getKpathsToBring() {
+        return kpathsToBring;
+    }
+
+    public void setKpathsToBring(int kpathsToBring) {
+        this.kpathsToBring = kpathsToBring;
+    }
+
+    public void setMhopsPerPath(int mhopsPerPath) {
+        this.mhopsPerPath = mhopsPerPath;
+    }
+
     public List<PceLink> getPathAtoZ() {
         return shortestPathAtoZ;
     }