import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PceConstraintMode;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.reroute.request.input.Endpoints;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescriptionBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.HardConstraints;
LOG.info("cancelResourceReserve ...");
}
- public void pathComputationWithConstraints(PceConstraints hardConstraints, PceConstraints softConstraints) {
+ private void pathComputationWithConstraints(PceConstraints hardConstraints, PceConstraints softConstraints,
+ PceConstraintMode mode) {
PceCalculation nwAnalizer = new PceCalculation(input, networkTransaction, hardConstraints, softConstraints, rc,
portMapping, endpoints);
LOG.info("PceGraph ...");
PceGraph graph = new PceGraph(nwAnalizer.getaendPceNode(), nwAnalizer.getzendPceNode(),
nwAnalizer.getAllPceNodes(), nwAnalizer.getAllPceLinks(), hardConstraints, softConstraints,
- rc, serviceType, networkTransaction);
+ rc, serviceType, networkTransaction, mode);
graph.calcPath();
rc = graph.getReturnStructure();
if (!rc.getStatus()) {
PceConstraintsCalc constraints = new PceConstraintsCalc(input, networkTransaction);
pceHardConstraints = constraints.getPceHardConstraints();
pceSoftConstraints = constraints.getPceSoftConstraints();
- pathComputationWithConstraints(pceHardConstraints, pceSoftConstraints);
+ pathComputationWithConstraints(pceHardConstraints, pceSoftConstraints, PceConstraintMode.Loose);
this.success = rc.getStatus();
this.message = rc.getMessage();
this.responseCode = rc.getResponseCode();
PceConstraintsCalc constraintsGnpy = new PceConstraintsCalc(inputFromGnpy, networkTransaction);
PceConstraints gnpyHardConstraints = constraintsGnpy.getPceHardConstraints();
PceConstraints gnpySoftConstraints = constraintsGnpy.getPceSoftConstraints();
- pathComputationWithConstraints(gnpyHardConstraints, gnpySoftConstraints);
+ pathComputationWithConstraints(gnpyHardConstraints, gnpySoftConstraints, PceConstraintMode.Strict);
AToZDirection atoz = rc.getAtoZDirection();
ZToADirection ztoa = rc.getZtoADirection();
if (gnpyToCheckFeasiblity(atoz, ztoa,gnpy)) {
import org.opendaylight.transportpce.pce.networkanalyzer.PceNode;
import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
import org.opendaylight.transportpce.pce.networkanalyzer.PceResult.LocalCause;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PceConstraintMode;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
private Double margin = null;
PceConstraints pceHardConstraints;
PceConstraints pceSoftConstraints;
+ private PceConstraintMode pceConstraintMode;
// results
private PceResult pceResult = null;
public PceGraph(PceNode aendNode, PceNode zendNode, Map<NodeId, PceNode> allPceNodes,
Map<LinkId, PceLink> allPceLinks, PceConstraints pceHardConstraints, PceConstraints pceSoftConstraints,
- PceResult pceResult, String serviceType, NetworkTransactionService networkTransactionService) {
+ PceResult pceResult, String serviceType, NetworkTransactionService networkTransactionService,
+ PceConstraintMode mode) {
super();
this.apceNode = aendNode;
this.zpceNode = zendNode;
this.pceSoftConstraints = pceSoftConstraints;
this.serviceType = serviceType;
this.networkTransactionService = networkTransactionService;
+ this.pceConstraintMode = mode;
LOG.info("In GraphCalculator: A and Z = {} / {} ", aendNode, zendNode);
LOG.debug("In GraphCalculator: allPceNodes size {}, nodes {} ", allPceNodes.size(), allPceNodes);
GraphPath<String, PceGraphEdge> path = entry.getValue();
LOG.info("validating path n° {} - {}", entry.getKey(), path.getVertexList());
PostAlgoPathValidator papv = new PostAlgoPathValidator(networkTransactionService);
- pceResult = papv.checkPath(path, allPceNodes, allPceLinks, pceResult, pceHardConstraints, serviceType);
+ pceResult = papv.checkPath(
+ path, allPceNodes, allPceLinks, pceResult, pceHardConstraints, serviceType, pceConstraintMode);
this.margin = papv.getTpceCalculatedMargin();
if (ResponseCodes.RESPONSE_OK.equals(pceResult.getResponseCode())) {
LOG.info("Path is validated");
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import org.jgrapht.GraphPath;
import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
import org.opendaylight.transportpce.pce.networkanalyzer.PceNode;
import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PceConstraintMode;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.SpectrumAssignment;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.SpectrumAssignmentBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1;
public static final Long CONST_OSNR = 1L;
public static final double SYS_MARGIN = 0;
+
private Double tpceCalculatedMargin = 0.0;
private final NetworkTransactionService networkTransactionService;
justification = "intentional fallthrough")
public PceResult checkPath(GraphPath<String, PceGraphEdge> path, Map<NodeId, PceNode> allPceNodes,
Map<LinkId, PceLink> allPceLinks, PceResult pceResult, PceConstraints pceHardConstraints,
- String serviceType) {
+ String serviceType, PceConstraintMode mode) {
LOG.info("path = {}", path);
// check if the path is empty
if (path.getEdgeList().isEmpty()) {
return pceResult;
}
// Check if nodes are included in the hard constraints
- if (!checkInclude(path, pceHardConstraints)) {
+ if (!checkInclude(path, pceHardConstraints, mode)) {
pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
pceResult.setLocalCause(PceResult.LocalCause.HD_NODE_INCLUDE);
return pceResult;
}
// Check the inclusion if it is defined in the hard constraints
- private boolean checkInclude(GraphPath<String, PceGraphEdge> path, PceConstraints pceHardConstraintsInput) {
- List<ResourcePair> listToInclude = pceHardConstraintsInput.getListToInclude()
- .stream().sorted((rp1, rp2) -> rp1.getName().compareTo(rp2.getName()))
- .collect(Collectors.toList());
+ //TODO: remove this checkstyle false positive warning when the checkstyle bug will be fixed
+ @SuppressWarnings("MissingSwitchDefault")
+ private boolean checkInclude(GraphPath<String, PceGraphEdge> path, PceConstraints pceHardConstraintsInput,
+ PceConstraintMode mode) {
+ List<ResourcePair> listToInclude = pceHardConstraintsInput.getListToInclude();
if (listToInclude.isEmpty()) {
return true;
}
List<PceGraphEdge> pathEdges = path.getEdgeList();
LOG.debug(" in checkInclude vertex list: [{}]", path.getVertexList());
+ LOG.debug("listToInclude = {}", listToInclude);
List<String> listOfElementsSubNode = new ArrayList<>();
listOfElementsSubNode.add(pathEdges.get(0).link().getsourceNetworkSupNodeId());
listOfElementsSubNode.addAll(
listOfElementsSRLG.addAll(
listOfElementsBuild(pathEdges, PceConstraints.ResourceType.SRLG, pceHardConstraintsInput));
// validation: check each type for each element
- return listOfElementsSubNode.containsAll(
- listToInclude
- .stream().filter(rp -> PceConstraints.ResourceType.NODE.equals(rp.getType()))
- .map(ResourcePair::getName).collect(Collectors.toList()))
+ LOG.debug("listOfElementsSubNode = {}", listOfElementsSubNode);
+ return switch (mode) {
+ case Loose -> listOfElementsSubNode
+ .containsAll(listToInclude.stream()
+ .filter(rp -> PceConstraints.ResourceType.NODE.equals(rp.getType()))
+ .map(ResourcePair::getName).collect(Collectors.toList()));
+ case Strict -> listOfElementsSubNode
+ .equals(listToInclude.stream()
+ .filter(rp -> PceConstraints.ResourceType.NODE.equals(rp.getType()))
+ .map(ResourcePair::getName).collect(Collectors.toList()));
+ }
&& listOfElementsSRLG.containsAll(
listToInclude
.stream().filter(rp -> PceConstraints.ResourceType.SRLG.equals(rp.getType()))
private List<String> listOfElementsBuild(List<PceGraphEdge> pathEdges, PceConstraints.ResourceType type,
PceConstraints pceHardConstraints) {
- List<String> listOfElements = new ArrayList<>();
+ Set<String> listOfElements = new LinkedHashSet<>();
for (PceGraphEdge link : pathEdges) {
switch (type) {
case NODE:
LOG.debug("listOfElementsBuild unsupported resource type");
}
}
- return listOfElements;
+ return new ArrayList<>(listOfElements);
}
private Map<String, Uint16> chooseTribPort(GraphPath<String,
import org.opendaylight.transportpce.test.stub.MountPointStub;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PceConstraintMode;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEndBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEndBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder;
pceCalc.retrievePceNetwork();
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
assertEquals(pceGraph.calcPath(), true);
assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(3.0919881995992924));
}
pceCalc.retrievePceNetwork();
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_OTUC2, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_OTUC2, netTransServ, PceConstraintMode.Loose);
assertEquals(pceGraph.calcPath(), true);
assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.1559963686478447));
}
pceCalc.retrievePceNetwork();
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_OTUC3, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_OTUC3, netTransServ, PceConstraintMode.Loose);
assertEquals(pceGraph.calcPath(), true);
assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.3351048800367167));
}
pceCalc.retrievePceNetwork();
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_400GE, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose);
assertEquals(pceGraph.calcPath(), false);
assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.0));
}
pceCalc.retrievePceNetwork();
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_400GE, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose);
assertEquals(pceGraph.calcPath(), true);
assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.4432381874659086));
}
pceCalc.retrievePceNetwork();
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose);
assertEquals(pceGraph.calcPath(), true);
assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.4432381874659086));
}
pceCalc.retrievePceNetwork();
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose);
assertEquals(pceGraph.calcPath(), true);
assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.0));
}
pceCalc.retrievePceNetwork();
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
assertEquals(pceGraph.calcPath(), true);
assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(3.0919881995992924));
}
pceHardConstraints.setPceMetrics(PceMetric.PropagationDelay);
pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
- null, rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ);
+ null, rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
pceGraph.setConstrains(pceHardConstraints, null);
assertEquals(pceGraph.calcPath(), true);
new NodeId("optical"), pceOtnNode,
new NodeId("optical2"), pceOtnNode2);
return new PceGraph(pceOtnNode, pceOtnNode2, allPceNodes, allPceLinks, pceHardConstraints, null,
- new PceResult(), type, null);
+ new PceResult(), type, null, PceConstraintMode.Loose);
}
private void saveOpenRoadmNetwork(Network network, String networkId)