X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fgraph%2FPceGraph.java;h=279d23ef7be7748b18ad3a1b918a644db99364b3;hb=62fc6625966276207a38955eaf07988f77f6984f;hp=711cbcebe2d165e0d468a7b20fb1a4b3f7bd494c;hpb=b115d446ae97ff4e7def0ad5c96beaa13191e5b0;p=transportpce.git 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 711cbcebe..279d23ef7 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 @@ -15,7 +15,7 @@ import java.util.List; import java.util.Map; import org.jgrapht.GraphPath; -import org.jgrapht.alg.shortestpath.KShortestPaths; +import org.jgrapht.alg.shortestpath.KShortestSimplePaths; import org.jgrapht.alg.shortestpath.PathValidator; import org.jgrapht.graph.DefaultDirectedWeightedGraph; import org.opendaylight.transportpce.common.ResponseCodes; @@ -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 allPceNodes = new HashMap(); private PceNode apceNode = null; private PceNode zpceNode = null; + private String serviceType = ""; PceConstraints pceHardConstraints; PceConstraints pceSoftConstraints; @@ -57,7 +59,8 @@ public class PceGraph { private List pathAtoZ = new ArrayList(); public PceGraph(PceNode aendNode, PceNode zendNode, Map 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 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,22 +134,12 @@ public class PceGraph { if (weightedGraph.edgeSet().isEmpty() || weightedGraph.vertexSet().isEmpty()) { return false; } - - PathValidator 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 wpv = new InAlgoPathValidator(); // KShortestPaths on weightedGraph - KShortestPaths swp = - new KShortestPaths(weightedGraph, kpathsToBring, mhopsPerPath, wpv); - - allWPaths = swp.getPaths(apceNode.getNodeId().getValue(), zpceNode.getNodeId().getValue()); + KShortestSimplePaths swp = + new KShortestSimplePaths(weightedGraph, mhopsPerPath, wpv); + allWPaths = swp.getPaths(apceNode.getNodeId().getValue(), zpceNode.getNodeId().getValue(), kpathsToBring); if (allWPaths.isEmpty()) { LOG.info(" In runKgraphs : algorithm didn't find any path"); @@ -150,9 +150,8 @@ public class PceGraph { // debug print for (GraphPath path : allWPaths) { - LOG.info("path Weight: {} : {}", path.getWeight(), path.getVertexList().toString()); + LOG.debug("path Weight: {} : {}", path.getWeight(), path.getVertexList().toString()); } - // debug print return true; } @@ -170,10 +169,8 @@ public class PceGraph { LOG.error("In addLinkToGraph link dest node is null : {}", pcelink.toString()); return false; } - LOG.debug("In addLinkToGraph link to nodes : {}{} {}", pcelink.toString(), source.toString(), dest.toString()); return true; - } private void populateWithNodes(DefaultDirectedWeightedGraph weightedGraph) { @@ -214,38 +211,45 @@ public class PceGraph { } private double chooseWeight(PceLink link) { - // HopCount is default double weight = 1; switch (pceHardConstraints.getPceMetrics()) { - case IGPMetric : - // TODO implement IGPMetric - low priority. - LOG.warn("In PceGraph not implemented IGPMetric. HopCount works as a default"); - break; - - case TEMetric : - // TODO implement TEMetric - low priority - LOG.warn("In PceGraph not implemented TEMetric. HopCount works as a default"); - break; - case HopCount : weight = 1; LOG.debug("In PceGraph HopCount is used as a metrics. {}", link.toString()); break; - 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; - + // TODO implement IGPMetric and TEMetric - low priority. + case IGPMetric : + case TEMetric : default: + LOG.warn("In PceGraph {} not implemented. HopCount works as a default", + pceHardConstraints.getPceMetrics()); break; } - 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 getPathAtoZ() { return shortestPathAtoZ; } @@ -258,5 +262,4 @@ public class PceGraph { this.pceHardConstraints = pceHardConstraintsInput; this.pceSoftConstraints = pceSoftConstraintsInput; } - }