X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2FPceSendingPceRPCs.java;h=f819daad548d89ed89883ced69c4566dc999a3ec;hb=73d098bc499661df6ef0044b62de4d46062ecfe9;hp=9ff32153d7c849105754e04b8821e631bc2372ce;hpb=bed96a4eb1ea59f07a8d7602f792ad70854cb35c;p=transportpce.git diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java b/pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java index 9ff32153d..f819daad5 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java @@ -9,23 +9,26 @@ package org.opendaylight.transportpce.pce; import org.opendaylight.transportpce.common.ResponseCodes; +import org.opendaylight.transportpce.common.mapping.PortMapping; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.pce.constraints.PceConstraints; import org.opendaylight.transportpce.pce.constraints.PceConstraintsCalc; -import org.opendaylight.transportpce.pce.gnpy.ConnectToGnpyServer; import org.opendaylight.transportpce.pce.gnpy.GnpyException; import org.opendaylight.transportpce.pce.gnpy.GnpyResult; import org.opendaylight.transportpce.pce.gnpy.GnpyUtilitiesImpl; +import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumer; import org.opendaylight.transportpce.pce.graph.PceGraph; import org.opendaylight.transportpce.pce.networkanalyzer.PceCalculation; import org.opendaylight.transportpce.pce.networkanalyzer.PceResult; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.service.path.rpc.result.PathDescriptionBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection; -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.routing.constraints.sp.HardConstraints; +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; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirection; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.PceMetric; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +36,7 @@ import org.slf4j.LoggerFactory; * Class for Sending * PCE requests : * - path-computation-request + * - path-computation-reroute * - cancel-resource-reserve. * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange * @@ -58,20 +62,38 @@ public class PceSendingPceRPCs { private Boolean success; private String message; private String responseCode; + private final GnpyConsumer gnpyConsumer; + private PortMapping portMapping; + // Define the termination points whose reservation status is not taken into account during the pruning process + private Endpoints endpoints; - public PceSendingPceRPCs() { + public PceSendingPceRPCs(GnpyConsumer gnpyConsumer) { setPathDescription(null); this.input = null; this.networkTransaction = null; + this.gnpyConsumer = gnpyConsumer; } - public PceSendingPceRPCs(PathComputationRequestInput input, - NetworkTransactionService networkTransaction) { + public PceSendingPceRPCs(PathComputationRequestInput input, NetworkTransactionService networkTransaction, + GnpyConsumer gnpyConsumer, PortMapping portMapping) { + this.gnpyConsumer = gnpyConsumer; setPathDescription(null); - // TODO compliance check to check that input is not empty this.input = input; this.networkTransaction = networkTransaction; + this.portMapping = portMapping; + this.endpoints = null; + } + + public PceSendingPceRPCs(PathComputationRequestInput input, NetworkTransactionService networkTransaction, + GnpyConsumer gnpyConsumer, PortMapping portMapping, + Endpoints endpoints) { + this.gnpyConsumer = gnpyConsumer; + setPathDescription(null); + this.input = input; + this.networkTransaction = networkTransaction; + this.portMapping = portMapping; + this.endpoints = endpoints; } public void cancelResourceReserve() { @@ -87,10 +109,11 @@ public class PceSendingPceRPCs { 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); + PceCalculation nwAnalizer = new PceCalculation(input, networkTransaction, hardConstraints, softConstraints, rc, + portMapping, endpoints); nwAnalizer.retrievePceNetwork(); rc = nwAnalizer.getReturnStructure(); String serviceType = nwAnalizer.getServiceType(); @@ -99,9 +122,9 @@ public class PceSendingPceRPCs { return; } LOG.info("PceGraph ..."); - PceGraph graph = new PceGraph(nwAnalizer.getaendPceNode(), - nwAnalizer.getzendPceNode(), nwAnalizer.getAllPceNodes(), - hardConstraints, softConstraints, rc, serviceType); + PceGraph graph = new PceGraph(nwAnalizer.getaendPceNode(), nwAnalizer.getzendPceNode(), + nwAnalizer.getAllPceNodes(), nwAnalizer.getAllPceLinks(), hardConstraints, + rc, serviceType, networkTransaction, mode); graph.calcPath(); rc = graph.getReturnStructure(); if (!rc.getStatus()) { @@ -138,7 +161,7 @@ public class PceSendingPceRPCs { 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(); @@ -152,9 +175,9 @@ public class PceSendingPceRPCs { //Connect to Gnpy to check path feasibility and recompute another path in case of path non-feasibility try { - ConnectToGnpyServer connectToGnpy = new ConnectToGnpyServer(); - if (connectToGnpy.isGnpyURLExist()) { - GnpyUtilitiesImpl gnpy = new GnpyUtilitiesImpl(networkTransaction, input); + if (gnpyConsumer.isAvailable()) { + GnpyUtilitiesImpl gnpy = new GnpyUtilitiesImpl(networkTransaction, input, + gnpyConsumer); if (rc.getStatus() && gnpyToCheckFeasiblity(atoz,ztoa,gnpy)) { setPathDescription(new PathDescriptionBuilder().setAToZDirection(atoz).setZToADirection(ztoa)); return; @@ -171,7 +194,7 @@ public class PceSendingPceRPCs { } private boolean gnpyToCheckFeasiblity(AToZDirection atoz, ZToADirection ztoa, GnpyUtilitiesImpl gnpy) - throws GnpyException, Exception { + throws GnpyException { //Call GNPy for path verification if (gnpy.verifyComputationByGnpy(atoz, ztoa, pceHardConstraints)) { @@ -183,7 +206,7 @@ public class PceSendingPceRPCs { return false; } - private void callGnpyToComputeNewPath(GnpyUtilitiesImpl gnpy) throws GnpyException, Exception { + private void callGnpyToComputeNewPath(GnpyUtilitiesImpl gnpy) throws GnpyException { //Call GNPy in the case of non feasibility LOG.info("In pceSendingPceRPC: the path is not feasible according to Gnpy"); @@ -202,13 +225,17 @@ public class PceSendingPceRPCs { LOG.info("In pceSendingPceRPC: GNPy succeed to find another path"); // Compute the path PathComputationRequestInput inputFromGnpy = new PathComputationRequestInputBuilder() - .setServiceName(input.getServiceName()).setHardConstraints(gnpyPathAsHC) - .setSoftConstraints(input.getSoftConstraints()).setPceMetric(PceMetric.HopCount) - .setServiceAEnd(input.getServiceAEnd()).setServiceZEnd(input.getServiceZEnd()).build(); + .setServiceName(input.getServiceName()) + .setHardConstraints(gnpyPathAsHC) + .setSoftConstraints(input.getSoftConstraints()) + .setPceRoutingMetric(PceMetric.HopCount) + .setServiceAEnd(input.getServiceAEnd()) + .setServiceZEnd(input.getServiceZEnd()) + .build(); 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)) { @@ -228,7 +255,7 @@ public class PceSendingPceRPCs { private PceGraph patchRerunGraph(PceGraph graph) { LOG.info("In pathComputation patchRerunGraph : rerun Graph with metric = PROPAGATION-DELAY "); - graph.setConstrains(pceHardConstraints, pceSoftConstraints); + graph.setConstrains(pceHardConstraints); graph.calcPath(); return graph; }