X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fconstraints%2FPceConstraintsCalc.java;h=dda3ea280407a93ee6c4d41d5206b9cc56dee8ac;hb=2a29f9ab006d8806f77b1a1e073b478e5351cc5f;hp=0c3cc109220160edfd56c2dd5b744c6438259674;hpb=a0c703ac04217369edcc80c55d2fafd1a0efefe4;p=transportpce.git diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/PceConstraintsCalc.java b/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/PceConstraintsCalc.java index 0c3cc1092..dda3ea280 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/PceConstraintsCalc.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/PceConstraintsCalc.java @@ -8,21 +8,22 @@ package org.opendaylight.transportpce.pce.constraints; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; - import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.Timeouts; import org.opendaylight.transportpce.common.network.NetworkTransactionService; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.PathDescription; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZ; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.Link; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.Node; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev210701.PathComputationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.PathDescription; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZ; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.Link; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.Node; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp.PceMetric; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.constraints.sp.CoRoutingOrGeneral; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.constraints.sp.co.routing.or.general.CoRouting; @@ -46,6 +47,8 @@ import org.slf4j.LoggerFactory; public class PceConstraintsCalc { /* Logging. */ private static final Logger LOG = LoggerFactory.getLogger(PceConstraintsCalc.class); + private static final Comparator ORDERED_HOP_COMPARATOR = + Comparator.comparing(OrderedHops::getHopNumber); private PceConstraints pceHardConstraints = new PceConstraints(); private PceConstraints pceSoftConstraints = new PceConstraints(); @@ -155,7 +158,7 @@ public class PceConstraintsCalc { Include include = tmpGeneral.getInclude(); if (include != null) { - List listHops = include.getOrderedHops(); + List listHops = new ArrayList<>(include.nonnullOrderedHops().values()); if (listHops != null) { readIncludeNodes(listHops, constraints); } @@ -169,13 +172,13 @@ public class PceConstraintsCalc { if (temp == null) { return; } - if (Boolean.TRUE.equals(temp.isNode())) { + if (Boolean.TRUE.equals(temp.getNode())) { rt = PceConstraints.ResourceType.NODE; } - if (Boolean.TRUE.equals(temp.isSrlg())) { + if (Boolean.TRUE.equals(temp.getSrlg())) { rt = PceConstraints.ResourceType.SRLG; } - if (Boolean.TRUE.equals(temp.isClli())) { + if (Boolean.TRUE.equals(temp.getClli())) { rt = PceConstraints.ResourceType.CLLI; } LOG.info("in readGeneralContrains {} list is :{}", rt, diversity); @@ -185,6 +188,7 @@ public class PceConstraintsCalc { } private void readIncludeNodes(List listHops, PceConstraints constraints) { + Collections.sort(listHops, ORDERED_HOP_COMPARATOR); for (int i = 0; i < listHops.size(); i++) { HopType hoptype = listHops.get(i).getHopType().getHopType(); @@ -266,7 +270,7 @@ public class PceConstraintsCalc { } private List getAToZNodeList(PathDescription pathDescription) { - List aendToZList = pathDescription.getAToZDirection().getAToZ(); + List aendToZList = new ArrayList<>(pathDescription.getAToZDirection().nonnullAToZ().values()); return aendToZList.stream().filter(aToZ -> { if (aToZ.getResource() == null || aToZ.getResource().getResource() == null) { LOG.warn("Diversity constraint: Resource of AToZ node {} is null! Skipping this node!", aToZ.getId()); @@ -287,7 +291,7 @@ public class PceConstraintsCalc { } private List getSRLGList(PathDescription pathDescription) { - List aendToZList = pathDescription.getAToZDirection().getAToZ(); + List aendToZList = new ArrayList<>(pathDescription.getAToZDirection().nonnullAToZ().values()); return aendToZList.stream().filter(aToZ -> { if (aToZ.getResource() == null || aToZ.getResource().getResource() == null) {