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=754d51eeba610568a887e6929c92430831311227;hb=1e2f9a502de80450411761fd2f636e2b7ee32301;hp=8a7a8c6ec430bbda7eeff96066f7aabeb3f7da5c;hpb=98dda60c2cd59d7c7dd8dba35d7d80473862646d;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 8a7a8c6ec..754d51eeb 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,8 +8,6 @@ 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; @@ -19,38 +17,35 @@ 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.transportpce.pce.constraints.PceConstraints.ResourcePair; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.CoRoutingOrGeneral; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.CoRouting; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.General; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.general.Diversity; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.general.Exclude; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.general.Include; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.general.Latency; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.diversity.existing.service.constraints.ExistingServiceApplicability; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.HardConstraints; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.SoftConstraints; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.PathDescription; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.Link; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.Node; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.constraints.sp.CoRoutingOrGeneral; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.constraints.sp.co.routing.or.general.CoRouting; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.constraints.sp.co.routing.or.general.General; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.constraints.sp.co.routing.or.general.general.Diversity; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.constraints.sp.co.routing.or.general.general.Exclude; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.constraints.sp.co.routing.or.general.general.Include; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.constraints.sp.co.routing.or.general.general.Latency; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.constraints.sp.co.routing.or.general.general.include_.OrderedHops; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.diversity.existing.service.contraints.sp.ExistingServiceApplicability; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.ordered.constraints.sp.hop.type.HopType; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.ordered.constraints.sp.hop.type.hop.type.Clli; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.ordered.constraints.sp.hop.type.hop.type.SRLG; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.routing.constraints.sp.HardConstraints; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.routing.constraints.sp.SoftConstraints; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.PceMetric; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.ServicePathList; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; 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(); @@ -136,35 +131,13 @@ public class PceConstraintsCalc { } Exclude exclude = tmpGeneral.getExclude(); - List elementsToExclude = null; if (exclude != null) { - elementsToExclude = exclude.getNodeId(); - if (elementsToExclude != null) { - constraints.setExcludeSupNodes(elementsToExclude); - } - - elementsToExclude = exclude.getSRLG(); - if (elementsToExclude != null) { - List srlgToExclude = new ArrayList<>(); - for (String str : elementsToExclude) { - srlgToExclude.add(Long.parseLong(str)); - } - constraints.setExcludeSRLG(srlgToExclude); - } - - elementsToExclude = exclude.getClli(); - if (elementsToExclude != null) { - constraints.setExcludeCLLI(elementsToExclude); - } + readExclude(exclude, constraints); } Include include = tmpGeneral.getInclude(); if (include != null) { - List listHops = new ArrayList<>(include.nonnullOrderedHops().values()); - if (listHops != null) { - readIncludeNodes(listHops, constraints); - } - LOG.debug("in readGeneralContrains INCLUDE {} ", include); + readInclude(include, constraints); } Diversity diversity = tmpGeneral.getDiversity(); @@ -180,43 +153,54 @@ public class PceConstraintsCalc { if (Boolean.TRUE.equals(temp.getSrlg())) { rt = PceConstraints.ResourceType.SRLG; } - if (Boolean.TRUE.equals(temp.getClli())) { + if (Boolean.TRUE.equals(temp.getSite())) { rt = PceConstraints.ResourceType.CLLI; } LOG.info("in readGeneralContrains {} list is :{}", rt, diversity); readDiversity(diversity.getExistingService(), constraints, rt); } + } + private void readExclude(Exclude exclude, PceConstraints constraints) { + List nodes = exclude.getNodeId(); + if (nodes != null) { + List elementsToExclude = new ArrayList<>(); + for (NodeIdType node : nodes) { + elementsToExclude.add(node.getValue()); + } + constraints.setExcludeSupNodes(elementsToExclude); + } + List srlgs = exclude.getSrlgId(); + if (srlgs != null) { + List elementsToExclude = new ArrayList<>(); + for (Uint32 srlg : srlgs) { + elementsToExclude.add(srlg.longValue()); + } + constraints.setExcludeSRLG(elementsToExclude); + } + List sites = exclude.getSite(); + if (sites != null) { + constraints.setExcludeCLLI(exclude.getSite()); + } } - 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(); - - String hopt = hoptype.implementedInterface().getSimpleName(); - LOG.info("in readIncludeNodes next hop to include {}", hopt); - switch (hopt) { - case "Node": - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118 - .ordered.constraints.sp.hop.type.hop.type.Node node = - (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118 - .ordered.constraints.sp.hop.type.hop.type.Node) hoptype; - constraints.setListToInclude( - new PceConstraints.ResourcePair(PceConstraints.ResourceType.NODE, node.getNodeId())); - break; - case "SRLG": - SRLG srlg = (SRLG) hoptype; - constraints.setListToInclude( - new PceConstraints.ResourcePair(PceConstraints.ResourceType.SRLG, srlg.getSRLG())); - break; - case "Clli": - Clli clli = (Clli) hoptype; - constraints.setListToInclude( - new PceConstraints.ResourcePair(PceConstraints.ResourceType.CLLI, clli.getClli())); - break; - default: - LOG.error("in readIncludeNodes unsupported include type {}", hopt); + private void readInclude(Include include, PceConstraints constraints) { + List nodes = include.getNodeId(); + if (nodes != null) { + for (NodeIdType node : nodes) { + constraints.setListToInclude(new ResourcePair(PceConstraints.ResourceType.NODE, node.getValue())); + } + } + List srlgs = include.getSrlgId(); + if (srlgs != null) { + for (Uint32 srlg : srlgs) { + constraints.setListToInclude(new ResourcePair(PceConstraints.ResourceType.SRLG, srlg.toString())); + } + } + List sites = include.getSite(); + if (sites != null) { + for (String site : sites) { + constraints.setListToInclude(new ResourcePair(PceConstraints.ResourceType.CLLI, site)); } } } @@ -262,7 +246,6 @@ public class PceConstraintsCalc { LOG.info("in readDiversity srv={} is not present", srv); } } - } private List getAToZNodeList(PathDescription pathDescription) {