[ARVADOS] created: 2.1.0-1491-gef950edc1
Git user
git at public.arvados.org
Thu Oct 14 19:14:23 UTC 2021
at ef950edc12c3ec560427b92537c54fb010edf970 (commit)
commit ef950edc12c3ec560427b92537c54fb010edf970
Author: Peter Amstutz <peter.amstutz at curii.com>
Date: Thu Oct 14 15:09:00 2021 -0400
18273: Increase default java sdk timeouts & make them configuable
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>
diff --git a/sdk/java-v2/src/main/java/org/arvados/client/api/client/BaseApiClient.java b/sdk/java-v2/src/main/java/org/arvados/client/api/client/BaseApiClient.java
index a8d1a08cb..51f2f4a81 100644
--- a/sdk/java-v2/src/main/java/org/arvados/client/api/client/BaseApiClient.java
+++ b/sdk/java-v2/src/main/java/org/arvados/client/api/client/BaseApiClient.java
@@ -23,6 +23,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
+import java.util.concurrent.TimeUnit;
abstract class BaseApiClient {
@@ -34,7 +35,12 @@ abstract class BaseApiClient {
BaseApiClient(ConfigProvider config) {
this.config = config;
- this.client = OkHttpClientFactory.INSTANCE.create(config.isApiHostInsecure());
+ this.client = OkHttpClientFactory.INSTANCE.create(config.isApiHostInsecure())
+ .newBuilder()
+ .connectTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS)
+ .readTimeout(config.getReadTimeout(), TimeUnit.MILLISECONDS)
+ .writeTimeout(config.getWriteTimeout(), TimeUnit.MILLISECONDS)
+ .build();
}
Request.Builder getRequestBuilder() {
diff --git a/sdk/java-v2/src/main/java/org/arvados/client/config/ConfigProvider.java b/sdk/java-v2/src/main/java/org/arvados/client/config/ConfigProvider.java
index c9a410931..116a46b3e 100644
--- a/sdk/java-v2/src/main/java/org/arvados/client/config/ConfigProvider.java
+++ b/sdk/java-v2/src/main/java/org/arvados/client/config/ConfigProvider.java
@@ -26,6 +26,11 @@ public interface ConfigProvider {
String getApiProtocol();
+ int getConnectTimeout();
+
+ int getReadTimeout();
+
+ int getWriteTimeout();
//FILE UPLOAD
int getFileSplitSize();
diff --git a/sdk/java-v2/src/main/java/org/arvados/client/config/ExternalConfigProvider.java b/sdk/java-v2/src/main/java/org/arvados/client/config/ExternalConfigProvider.java
index 17e06966f..d592b23ac 100644
--- a/sdk/java-v2/src/main/java/org/arvados/client/config/ExternalConfigProvider.java
+++ b/sdk/java-v2/src/main/java/org/arvados/client/config/ExternalConfigProvider.java
@@ -22,8 +22,35 @@ public class ExternalConfigProvider implements ConfigProvider {
private File fileSplitDirectory;
private int numberOfCopies;
private int numberOfRetries;
+ private int connectTimeout;
+ private int readTimeout;
+ private int writeTimeout;
+
+ ExternalConfigProvider(boolean apiHostInsecure, String keepWebHost, int keepWebPort, String apiHost, int apiPort,
+ String apiToken, String apiProtocol, int fileSplitSize, File fileSplitDirectory,
+ int numberOfCopies, int numberOfRetries)
+ {
+ this.apiHostInsecure = apiHostInsecure;
+ this.keepWebHost = keepWebHost;
+ this.keepWebPort = keepWebPort;
+ this.apiHost = apiHost;
+ this.apiPort = apiPort;
+ this.apiToken = apiToken;
+ this.apiProtocol = apiProtocol;
+ this.fileSplitSize = fileSplitSize;
+ this.fileSplitDirectory = fileSplitDirectory;
+ this.numberOfCopies = numberOfCopies;
+ this.numberOfRetries = numberOfRetries;
+ this.connectTimeout = 60000;
+ this.readTimeout = 60000;
+ this.writeTimeout = 60000;
+ }
- ExternalConfigProvider(boolean apiHostInsecure, String keepWebHost, int keepWebPort, String apiHost, int apiPort, String apiToken, String apiProtocol, int fileSplitSize, File fileSplitDirectory, int numberOfCopies, int numberOfRetries) {
+ ExternalConfigProvider(boolean apiHostInsecure, String keepWebHost, int keepWebPort, String apiHost, int apiPort,
+ String apiToken, String apiProtocol, int fileSplitSize, File fileSplitDirectory,
+ int numberOfCopies, int numberOfRetries,
+ int connectTimeout, int readTimeout, int writeTimeout)
+ {
this.apiHostInsecure = apiHostInsecure;
this.keepWebHost = keepWebHost;
this.keepWebPort = keepWebPort;
@@ -35,6 +62,9 @@ public class ExternalConfigProvider implements ConfigProvider {
this.fileSplitDirectory = fileSplitDirectory;
this.numberOfCopies = numberOfCopies;
this.numberOfRetries = numberOfRetries;
+ this.connectTimeout = connectTimeout;
+ this.readTimeout = readTimeout;
+ this.writeTimeout = writeTimeout;
}
public static ExternalConfigProviderBuilder builder() {
@@ -102,6 +132,18 @@ public class ExternalConfigProvider implements ConfigProvider {
return this.numberOfRetries;
}
+ public int getConnectTimeout() {
+ return this.connectTimeout;
+ }
+
+ public int getReadTimeout() {
+ return this.readTimeout;
+ }
+
+ public int getWriteTimeout() {
+ return this.writeTimeout;
+ }
+
public static class ExternalConfigProviderBuilder {
private boolean apiHostInsecure;
private String keepWebHost;
diff --git a/sdk/java-v2/src/main/java/org/arvados/client/config/FileConfigProvider.java b/sdk/java-v2/src/main/java/org/arvados/client/config/FileConfigProvider.java
index 589c3346b..99c1af810 100644
--- a/sdk/java-v2/src/main/java/org/arvados/client/config/FileConfigProvider.java
+++ b/sdk/java-v2/src/main/java/org/arvados/client/config/FileConfigProvider.java
@@ -104,4 +104,19 @@ public class FileConfigProvider implements ConfigProvider {
public String getIntegrationTestProjectUuid() {
return this.getString("integration-tests.project-uuid");
}
+
+ @Override
+ public int getConnectTimeout() {
+ return this.getInt("connectTimeout");
+ }
+
+ @Override
+ public int getReadTimeout() {
+ return this.getInt("readTimeout");
+ }
+
+ @Override
+ public int getWriteTimeout() {
+ return this.getInt("writeTimeout");
+ }
}
diff --git a/sdk/java-v2/src/main/resources/reference.conf b/sdk/java-v2/src/main/resources/reference.conf
index 3ff2bb0a9..8933e2bc6 100644
--- a/sdk/java-v2/src/main/resources/reference.conf
+++ b/sdk/java-v2/src/main/resources/reference.conf
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0 OR Apache-2.0
+#
# Arvados client default configuration
#
# Remarks:
@@ -20,4 +24,7 @@ arvados {
temp-dir = /tmp/file-split
copies = 2
retries = 0
+ connectTimeout = 60000
+ readTimeout = 60000
+ writeTimeout = 60000
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list