summaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-08-02 14:38:20 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-08-06 12:59:57 +0530
commitb761c64db074de56defbf049748d74bdeb7cff6b (patch)
treeeaecfe9f6f3d763056e08050995453b5c831d1e3 /vnfmarket-be/vnf-sdk-marketplace/src
parent04e574dc396ffa39b91ff5f92a46906a9c58f5bd (diff)
Update rpc
Issue-ID: VNFSDK-424 Change-Id: I88ed722a3b1483603b7948cbfc60f4959e497aab Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java39
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties4
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml40
4 files changed, 54 insertions, 31 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java
index 7d408e4b..1c1c6336 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java
@@ -46,6 +46,7 @@ public class VTPResource {
protected static int VTP_TEST_CENTER_PORT; // NOSONAR
protected static String VTP_ARTIFACT_STORE; // NOSONAR
protected static String VTP_EXECUTION_TEMP_STORE; // NOSONAR
+ protected static int VTP_EXECUTION_GRPC_TIMEOUT; // NOSONAR
protected static final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); // NOSONAR
@@ -59,21 +60,28 @@ public class VTPResource {
VTP_TEST_CENTER_PORT = Integer.parseInt(prp.getProperty("vtp.grpc.port"));
VTP_ARTIFACT_STORE = prp.getProperty("vtp.artifact.store");
VTP_EXECUTION_TEMP_STORE = prp.getProperty("vtp.file.store");
+ VTP_EXECUTION_GRPC_TIMEOUT = Integer.parseInt(prp.getProperty("vtp.grpc.timeout")) * 1000 ;
} catch (Exception e) { // NOSONAR
LOG.error(e.getMessage());
}
}
protected Result makeRpc(List <String> args) throws VTPException {
+ return this.makeRpc(args, VTP_EXECUTION_GRPC_TIMEOUT);
+ }
+
+ protected Result makeRpc(List <String> args, int timeout) throws VTPException {
Result result = null;
String requestId = UUID.randomUUID().toString();
try {
- result = OpenRemoteCli.run(
- VTP_TEST_CENTER_IP, VTP_TEST_CENTER_PORT, requestId,
- args);
+ result = new OpenRemoteCli(
+ VTP_TEST_CENTER_IP,
+ VTP_TEST_CENTER_PORT,
+ timeout,
+ requestId).run(args);
} catch(OpenInterfaceGrpcClient.OpenInterfaceGrpcTimeoutExecption e) {
throw new VTPException(
- new VTPError().setHttpStatus(HttpStatus.SC_GATEWAY_TIMEOUT).setMessage("Timeout.").setCode(VTPError.TIMEOUT));
+ new VTPError().setHttpStatus(HttpStatus.SC_GATEWAY_TIMEOUT).setMessage("Timed out. Please use request-id to track the progress.").setCode(VTPError.TIMEOUT));
} catch (Exception e) {
throw new VTPException(new VTPError().setMessage(e.getMessage()));
}
@@ -91,22 +99,33 @@ public class VTPResource {
}
protected JsonNode makeRpcAndGetJson(List<String> args) throws VTPException, IOException {
- Result result = this.makeRpc(args);
+ return this.makeRpcAndGetJson(args, VTP_EXECUTION_GRPC_TIMEOUT);
+ }
+
+ protected JsonNode makeRpcAndGetJson(List<String> args, int timeout) throws VTPException, IOException {
+ Result result = this.makeRpc(args, timeout);
ObjectMapper mapper = new ObjectMapper();
JsonNode resultJson = mapper.readTree(result.getOutput());
return resultJson;
}
-
protected Output makeRpc(String scenario, String requestId, String profile, String testCase, JsonNode argsJsonNode) throws VTPException {
+ return this.makeRpc(scenario, requestId, profile, testCase, argsJsonNode, VTP_EXECUTION_GRPC_TIMEOUT);
+ }
+
+ protected Output makeRpc(String scenario, String requestId, String profile, String testCase, JsonNode argsJsonNode, int timeout) throws VTPException {
Output output = null;
ObjectMapper mapper = new ObjectMapper();
Map <String, String> args = mapper.convertValue(argsJsonNode, Map.class);
try {
- output = OpenRemoteCli.invoke(VTP_TEST_CENTER_IP, VTP_TEST_CENTER_PORT, scenario, profile, testCase, requestId, args);
- } catch(OpenInterfaceGrpcClient.OpenInterfaceGrpcTimeoutExecption e) {
- throw new VTPException(
- new VTPError().setHttpStatus(HttpStatus.SC_GATEWAY_TIMEOUT).setMessage(e.getMessage()).setCode(VTPError.TIMEOUT));
+ output = new OpenRemoteCli(
+ VTP_TEST_CENTER_IP,
+ VTP_TEST_CENTER_PORT,
+ timeout,
+ requestId).invoke(scenario, profile, testCase, args);
+ } catch(OpenInterfaceGrpcClient.OpenInterfaceGrpcTimeoutExecption e) {
+ throw new VTPException(
+ new VTPError().setHttpStatus(HttpStatus.SC_GATEWAY_TIMEOUT).setMessage("Timed out. Please use request-id to track the progress.").setCode(VTPError.TIMEOUT));
} catch (Exception e) {
throw new VTPException(
new VTPError().setMessage(e.getMessage()));
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java
index 70ec6e6a..1427a578 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.UUID;
import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -51,6 +52,7 @@ import org.onap.vtp.error.VTPError.VTPException;
import org.onap.vtp.execution.model.VTPTestExecution;
import org.onap.vtp.execution.model.VTPTestExecution.VTPTestExecutionList;
import org.open.infc.grpc.Output;
+import org.open.infc.grpc.Result;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties b/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties
index e2b9f87c..d0e89d81 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties
@@ -15,4 +15,6 @@
vtp.grpc.server = localhost
vtp.grpc.port = 50051
vtp.artifact.store = /tmp/data/vtp-artifacts
-vtp.file.store = /tmp/data/vtp-tmp-files \ No newline at end of file
+vtp.file.store = /tmp/data/vtp-tmp-files
+#60 seconds
+vtp.grpc.timeout = 60 \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
index 89a84034..da5ee65f 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
@@ -1,32 +1,32 @@
-<?xml version = "1.0" encoding = "UTF-8"?>
-<web-app xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
- xmlns = "http://java.sun.com/xml/ns/javaee"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+<?xml version = "1.0" encoding = "UTF-8"?>
+<web-app xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
+ xmlns = "http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id = "WebApp_ID" version = "3.0">
- <servlet>
- <servlet-name>Jersey RESTful Application</servlet-name>
- <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>jersey.config.server.provider.packages</param-name>
+ <servlet>
+ <servlet-name>Jersey RESTful Application</servlet-name>
+ <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>jersey.config.server.provider.packages</param-name>
<param-value>io.swagger.jaxrs.listing,
org.onap.vnfsdk.marketplace.resource,
org.onap.vtp.error,
org.onap.vtp.scenario,
org.onap.vtp.execution
- </param-value>
- </init-param>
+ </param-value>
+ </init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
- <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>Jersey RESTful Application</servlet-name>
- <url-pattern>/onapapi/vnfsdk-marketplace/v1/*</url-pattern>
+ <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Jersey RESTful Application</servlet-name>
+ <url-pattern>/onapapi/vnfsdk-marketplace/v1/*</url-pattern>
</servlet-mapping>
-
+
<servlet>
<servlet-name>Jersey2Config</servlet-name>
<servlet-class>io.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>