Set REST API request timeout
Change-Id: I448399e75fffe050d2f638cca5f14390125c4910
diff --git a/apps/xosclient/BUCK b/apps/xosclient/BUCK
index 406b0a0..b403541 100644
--- a/apps/xosclient/BUCK
+++ b/apps/xosclient/BUCK
@@ -4,6 +4,7 @@
'//lib:openstack4j-core',
'//lib:openstack4j-http-connector',
'//lib:openstack4j-httpclient',
+ '//lib:jersey-client',
]
osgi_jar_with_tests (
diff --git a/apps/xosclient/pom.xml b/apps/xosclient/pom.xml
index 5ab5c59..acb4f72 100644
--- a/apps/xosclient/pom.xml
+++ b/apps/xosclient/pom.xml
@@ -49,6 +49,10 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.pacesys</groupId>
<artifactId>openstack4j-core</artifactId>
<version>2.11</version>
diff --git a/apps/xosclient/src/main/java/org/onosproject/xosclient/impl/XosApi.java b/apps/xosclient/src/main/java/org/onosproject/xosclient/impl/XosApi.java
index 4a9ec09..47738e7 100644
--- a/apps/xosclient/src/main/java/org/onosproject/xosclient/impl/XosApi.java
+++ b/apps/xosclient/src/main/java/org/onosproject/xosclient/impl/XosApi.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.xosclient.impl;
+import org.glassfish.jersey.client.ClientProperties;
import org.onosproject.xosclient.api.XosAccess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,6 +43,8 @@
protected final XosAccess access;
protected final Client client;
+ private static final int DEFAULT_TIMEOUT_MS = 2000;
+
/**
* Default constructor.
*
@@ -52,6 +55,9 @@
this.baseUrl = baseUrl;
this.access = xosAccess;
this.client = ClientBuilder.newClient();
+
+ client.property(ClientProperties.CONNECT_TIMEOUT, DEFAULT_TIMEOUT_MS);
+ client.property(ClientProperties.READ_TIMEOUT, DEFAULT_TIMEOUT_MS);
}
/**