Hyunsun Moon

Set REST API request timeout

Change-Id: I448399e75fffe050d2f638cca5f14390125c4910
...@@ -4,6 +4,7 @@ COMPILE_DEPS = [ ...@@ -4,6 +4,7 @@ COMPILE_DEPS = [
4 '//lib:openstack4j-core', 4 '//lib:openstack4j-core',
5 '//lib:openstack4j-http-connector', 5 '//lib:openstack4j-http-connector',
6 '//lib:openstack4j-httpclient', 6 '//lib:openstack4j-httpclient',
7 + '//lib:jersey-client',
7 ] 8 ]
8 9
9 osgi_jar_with_tests ( 10 osgi_jar_with_tests (
......
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
49 <version>${project.version}</version> 49 <version>${project.version}</version>
50 </dependency> 50 </dependency>
51 <dependency> 51 <dependency>
52 + <groupId>org.glassfish.jersey.core</groupId>
53 + <artifactId>jersey-client</artifactId>
54 + </dependency>
55 + <dependency>
52 <groupId>org.pacesys</groupId> 56 <groupId>org.pacesys</groupId>
53 <artifactId>openstack4j-core</artifactId> 57 <artifactId>openstack4j-core</artifactId>
54 <version>2.11</version> 58 <version>2.11</version>
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.xosclient.impl; 16 package org.onosproject.xosclient.impl;
17 17
18 +import org.glassfish.jersey.client.ClientProperties;
18 import org.onosproject.xosclient.api.XosAccess; 19 import org.onosproject.xosclient.api.XosAccess;
19 import org.slf4j.Logger; 20 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory; 21 import org.slf4j.LoggerFactory;
...@@ -42,6 +43,8 @@ public class XosApi { ...@@ -42,6 +43,8 @@ public class XosApi {
42 protected final XosAccess access; 43 protected final XosAccess access;
43 protected final Client client; 44 protected final Client client;
44 45
46 + private static final int DEFAULT_TIMEOUT_MS = 2000;
47 +
45 /** 48 /**
46 * Default constructor. 49 * Default constructor.
47 * 50 *
...@@ -52,6 +55,9 @@ public class XosApi { ...@@ -52,6 +55,9 @@ public class XosApi {
52 this.baseUrl = baseUrl; 55 this.baseUrl = baseUrl;
53 this.access = xosAccess; 56 this.access = xosAccess;
54 this.client = ClientBuilder.newClient(); 57 this.client = ClientBuilder.newClient();
58 +
59 + client.property(ClientProperties.CONNECT_TIMEOUT, DEFAULT_TIMEOUT_MS);
60 + client.property(ClientProperties.READ_TIMEOUT, DEFAULT_TIMEOUT_MS);
55 } 61 }
56 62
57 /** 63 /**
......