Merge changes I1ed16552,Ia080da84
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / gnpy / GnpyUtilitiesImpl.java
index 6ef4a1b668f6bcd36261efd53489380491224908..fcd1cbc0cdfb3b4197a5c805465e07347b213fd3 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.transportpce.pce.gnpy;
 
 import java.util.List;
-
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
 import org.opendaylight.yang.gen.v1.gnpy.gnpy.api.rev190103.GnpyApi;
@@ -18,15 +17,16 @@ import org.opendaylight.yang.gen.v1.gnpy.gnpy.api.rev190103.gnpy.api.ServiceFile
 import org.opendaylight.yang.gen.v1.gnpy.gnpy.api.rev190103.gnpy.api.TopologyFileBuilder;
 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Connections;
 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Elements;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.generic.path.properties.path.properties.PathRouteObjects;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.service.PathRequest;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.Synchronization;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestInput;
-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.AToZDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.generic.path.properties.path.properties.PathRouteObjects;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.service.PathRequest;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.synchronization.info.Synchronization;
+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.rev200629.path.description.AToZDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.AToZDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.ZToADirection;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.HardConstraints;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,14 +39,13 @@ import org.slf4j.LoggerFactory;
 
 public class GnpyUtilitiesImpl {
 
-    private static final Logger LOG = LoggerFactory.getLogger(GnpyResult.class);
+    private static final Logger LOG = LoggerFactory.getLogger(GnpyUtilitiesImpl.class);
     private NetworkTransactionService networkTransaction;
     private PathComputationRequestInput input;
     private GnpyTopoImpl gnpyTopo = null;
     private GnpyResult gnpyAtoZ;
     private GnpyResult gnpyZtoA;
-    private Long requestId;
-    //private boolean status;
+    private Uint32 requestId;
 
     public GnpyUtilitiesImpl(NetworkTransactionService networkTransaction, PathComputationRequestInput input)
         throws GnpyException {
@@ -56,7 +55,7 @@ public class GnpyUtilitiesImpl {
         this.input = input;
         this.gnpyAtoZ = null;
         this.gnpyZtoA = null;
-        this.requestId = (long) 0;
+        this.requestId = Uint32.valueOf(0);
     }
 
     public boolean verifyComputationByGnpy(AToZDirection atoz, ZToADirection ztoa, PceConstraints pceHardConstraints)
@@ -77,7 +76,7 @@ public class GnpyUtilitiesImpl {
     }
 
     public GnpyResult gnpyResponseOneDirection(GnpyServiceImpl gnpySvc) throws GnpyException, Exception {
-        requestId++;
+        requestId = Uint32.valueOf((requestId.toJava()) + 1);
         List<PathRequest> pathRequestList = gnpySvc.getPathRequest();
         List<Synchronization> synchronizationList = gnpySvc.getSynchronization();
         // Send the computed path to GNPY tool
@@ -87,14 +86,14 @@ public class GnpyUtilitiesImpl {
             synchronizationList);
         // Analyze the response
         if (gnpyResponse == null) {
-            throw new GnpyException("In GnpyUtilities: no respnse from GNPy server");
+            throw new GnpyException("In GnpyUtilities: no response from GNPy server");
         }
         GnpyResult result = new GnpyResult(gnpyResponse, gnpyTopo);
         result.analyzeResult();
         return result;
     }
 
-    public HardConstraints askNewPathFromGnpy(HardConstraints gnpyPathAsHC, PceConstraints pceHardConstraints)
+    public HardConstraints askNewPathFromGnpy(PceConstraints pceHardConstraints)
             throws GnpyException, Exception {
 
         AToZDirection atoztmp = new AToZDirectionBuilder()
@@ -105,16 +104,14 @@ public class GnpyUtilitiesImpl {
         GnpyResult result = gnpyResponseOneDirection(gnpySvc);
 
         if (result == null) {
-            throw new GnpyException("In GnpyUtilities: no response from the GNPy server");
+            throw new GnpyException("In GnpyUtilities: no result from the GNPy server");
         }
 
         if (!result.getPathFeasibility()) {
             return null;
         }
         List<PathRouteObjects> pathRouteObjectList = result.analyzeResult();
-        gnpyPathAsHC = result.computeHardConstraintsFromGnpyPath(pathRouteObjectList);
-
-        return gnpyPathAsHC;
+        return result.computeHardConstraintsFromGnpyPath(pathRouteObjectList);
     }
 
     public String getGnpyResponse(List<Elements> elementsList, List<Connections> connectionsList,
@@ -136,8 +133,7 @@ public class GnpyUtilitiesImpl {
             .replace("gnpy-path-computation-simplified:", "")
             .replace("gnpy-network-topology:", "");
 
-        String gnpyResponse = connect.gnpyCnx(gnpyJsonModified);
-        return gnpyResponse;
+        return connect.returnGnpyResponse(gnpyJsonModified);
     }
 
     public GnpyResult getGnpyAtoZ() {