+ LOG.error("In pathComputationWithConstraints, description: result = {}", rc);
+ }
+ }
+
+ public void pathComputation() throws Exception {
+
+ PceConstraintsCalc constraints = new PceConstraintsCalc(input, networkTransaction);
+ pceHardConstraints = constraints.getPceHardConstraints();
+ pceSoftConstraints = constraints.getPceSoftConstraints();
+ pathComputationWithConstraints(pceHardConstraints, pceSoftConstraints, PceConstraintMode.Loose);
+ this.success = rc.getStatus();
+ this.message = rc.getMessage();
+ this.responseCode = rc.getResponseCode();
+
+ AToZDirection atoz = null;
+ ZToADirection ztoa = null;
+ if (rc.getStatus()) {
+ atoz = rc.getAtoZDirection();
+ ztoa = rc.getZtoADirection();
+ }
+
+ //Connect to Gnpy to check path feasibility and recompute another path in case of path non-feasibility
+ try {
+ 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;
+ }
+ callGnpyToComputeNewPath(gnpy);
+ } else {
+ setPathDescription(new PathDescriptionBuilder().setAToZDirection(atoz).setZToADirection(ztoa));
+ }
+ }
+ catch (GnpyException e) {
+ LOG.error("Exception raised by GNPy {}",e.getMessage());
+ setPathDescription(new PathDescriptionBuilder().setAToZDirection(atoz).setZToADirection(ztoa));
+ }
+ }
+
+ private boolean gnpyToCheckFeasiblity(AToZDirection atoz, ZToADirection ztoa, GnpyUtilitiesImpl gnpy)
+ throws GnpyException {
+
+ //Call GNPy for path verification
+ if (gnpy.verifyComputationByGnpy(atoz, ztoa, pceHardConstraints)) {
+ LOG.info("In pceSendingPceRPC: the path is feasible according to Gnpy");
+ gnpyAtoZ = gnpy.getGnpyAtoZ();
+ gnpyZtoA = gnpy.getGnpyZtoA();
+ return true;
+ }
+ return false;
+ }
+
+ 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");
+ HardConstraints gnpyPathAsHC = null;
+ gnpyPathAsHC = gnpy.askNewPathFromGnpy(pceHardConstraints);
+ if (gnpyPathAsHC == null) {
+ LOG.info("In pceSendingPceRPC: GNPy failed to find another path");
+ this.success = false;
+ this.message = "No path available by PCE and GNPy ";
+ this.responseCode = ResponseCodes.RESPONSE_FAILED;
+ gnpyAtoZ = gnpy.getGnpyAtoZ();
+ gnpyZtoA = gnpy.getGnpyZtoA();
+ return;
+ }
+
+ 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())
+ .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, PceConstraintMode.Strict);
+ AToZDirection atoz = rc.getAtoZDirection();
+ ZToADirection ztoa = rc.getZtoADirection();
+ if (gnpyToCheckFeasiblity(atoz, ztoa,gnpy)) {
+ LOG.info("In pceSendingPceRPC: the new path computed by GNPy is valid");
+ this.success = true;
+ this.message = "Path is calculated by GNPy";
+ this.responseCode = ResponseCodes.RESPONSE_OK;
+ setPathDescription(new PathDescriptionBuilder().setAToZDirection(atoz).setZToADirection(ztoa));
+ } else {
+ LOG.info("In pceSendingPceRPC: the new path computed by GNPy is not valid");
+ this.success = false;
+ this.message = "No path available";
+ this.responseCode = ResponseCodes.RESPONSE_FAILED;
+ setPathDescription(new PathDescriptionBuilder().setAToZDirection(null).setZToADirection(null));