aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main/java
diff options
context:
space:
mode:
authorBenjamin, Max <max.benjamin@att.com>2020-11-06 18:04:49 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-11-11 23:13:49 -0500
commitc183d2d73b46a51a028bd65c742ee46df5e7d547 (patch)
tree35f47caddf6107f7a4ee343503973d05be8dd361 /common/src/main/java
parentea82d794ac51faa699b9b84ea003a9242b8d4ccc (diff)
added configurable read timeout value for A&AI
added configurable read timeout value for A&AI Issue-ID: SO-3370 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I1216608a09f6a8649a57aa4b320fbea4982a7efe
Diffstat (limited to 'common/src/main/java')
-rw-r--r--common/src/main/java/org/onap/so/client/RestClient.java8
-rw-r--r--common/src/main/java/org/onap/so/client/RestClientSSL.java4
-rw-r--r--common/src/main/java/org/onap/so/client/RestProperties.java9
3 files changed, 18 insertions, 3 deletions
diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java
index ece1333f83..9fce328b1d 100644
--- a/common/src/main/java/org/onap/so/client/RestClient.java
+++ b/common/src/main/java/org/onap/so/client/RestClient.java
@@ -34,10 +34,12 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
+import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.ResponseProcessingException;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
@@ -187,7 +189,7 @@ public abstract class RestClient {
}
protected Client getClient() {
- return ClientBuilder.newBuilder().build();
+ return ClientBuilder.newBuilder().readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS).build();
}
protected abstract ONAPComponentsList getTargetEntity();
@@ -201,7 +203,6 @@ public abstract class RestClient {
metricLogClientFilter = new SOMetricLogClientFilter();
mdcSetup.setTargetEntity(getTargetEntity());
client.register(metricLogClientFilter);
-
if (!path.isPresent()) {
webTarget = client.target(host.toString());
} else {
@@ -225,6 +226,9 @@ public abstract class RestClient {
result.add(e -> {
return e.getCause() instanceof ConnectException;
});
+ result.add(e -> {
+ return e.getCause() instanceof ResponseProcessingException;
+ });
return result;
}
diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java
index 1e8953892e..8956e20a5a 100644
--- a/common/src/main/java/org/onap/so/client/RestClientSSL.java
+++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java
@@ -24,6 +24,7 @@ import java.net.URI;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;
+import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -56,7 +57,8 @@ public abstract class RestClientSSL extends RestClient {
}
}
// Use default SSL context
- client = ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()).build();
+ client = ClientBuilder.newBuilder().sslContext(SSLContext.getDefault())
+ .readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS).build();
logger.info("RestClientSSL using default SSL context!");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
diff --git a/common/src/main/java/org/onap/so/client/RestProperties.java b/common/src/main/java/org/onap/so/client/RestProperties.java
index 9e4e99cb4e..36da424f93 100644
--- a/common/src/main/java/org/onap/so/client/RestProperties.java
+++ b/common/src/main/java/org/onap/so/client/RestProperties.java
@@ -40,4 +40,13 @@ public interface RestProperties {
public default boolean mapNotFoundToEmpty() {
return false;
}
+
+ /**
+ * Time in milliseconds
+ *
+ * @return
+ */
+ public default Long getReadTimeout() {
+ return Long.valueOf(60000);
+ }
}