Fix Unreserved Bandwidth verification in algo 03/91203/4
authorOlivier Dugeon <olivier.dugeon@orange.com>
Fri, 10 Jul 2020 15:21:03 +0000 (17:21 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 17 Jul 2020 12:09:59 +0000 (12:09 +0000)
Path Computation Algorithms assume that Unreserved Bandwidth values are
ordered by Class-Type priority which could be wrong. This patch set correct
this issue by searching the correct Unreserved Bandwidth value that corresponds
to the Class-Type instead of directly addressing the Unreserved Bandwidth list
with the Class-Type as index.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Change-Id: I02c03c18cfe2eee2451f05739bf6df9ce6995a38
(cherry picked from commit 0d9eadca7b948a6090130de51f80eac845afbf9d)

algo/algo-impl/src/main/java/org/opendaylight/algo/impl/AbstractPathComputation.java

index cf691ccecc142b02db9e36dd1b4b89c61d1bd966..202cc8218cafba1f5359c2c4f76668b5655be614 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.graph.ConnectedEdge;
 import org.opendaylight.graph.ConnectedGraph;
 import org.opendaylight.graph.ConnectedVertex;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
@@ -235,9 +236,14 @@ public abstract class AbstractPathComputation implements PathComputationAlgorith
                 return true;
             } else {
                 Long bandwidth = constraints.getBandwidth().getValue().longValue();
-                if (attributes.getUnreservedBandwidth().get(constraints.getClassType().intValue()).getBandwidth()
-                        .getValue().longValue() < bandwidth
-                        || attributes.getMaxLinkBandwidth().getValue().longValue() < bandwidth
+                Long unrsv = 0L;
+                for (UnreservedBandwidth unResBw : attributes.getUnreservedBandwidth()) {
+                    if (unResBw.getClassType().intValue() == constraints.getClassType().intValue()) {
+                        unrsv = unResBw.getBandwidth().getValue().longValue();
+                        break;
+                    }
+                }
+                if (unrsv < bandwidth || attributes.getMaxLinkBandwidth().getValue().longValue() < bandwidth
                         || attributes.getMaxResvLinkBandwidth().getValue().longValue() < bandwidth) {
                     LOG.debug("Bandwidth constraint is not met");
                     return true;