From 2bf32fea6c50b51fb04730de1dc7c5edcc5a2fd3 Mon Sep 17 00:00:00 2001 From: zhoupeng <“zhouyaobin1612@163.com”> Date: Tue, 16 Nov 2021 07:43:01 +0800 Subject: [PATCH] [INLONG-1798]RestTemplate does not read configuration from the configuration file --- .../web/config/RestTemplateConfig.java | 19 +++++++++++++------ .../resources/application-test.properties | 12 ++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/RestTemplateConfig.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/RestTemplateConfig.java index 11e35e7434a..5abc3bf7d8a 100644 --- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/RestTemplateConfig.java +++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/RestTemplateConfig.java @@ -31,6 +31,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.protocol.HttpContext; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -51,27 +52,33 @@ public class RestTemplateConfig { /** * Max total */ - private int maxTotal = 5000; + @Value("${common.http-client.maxTotal}") + private int maxTotal; /** * Concurrency */ - private int defaultMaxPerRoute = 2000; + @Value("${common.http-client.defaultMaxPerRoute}") + private int defaultMaxPerRoute; - private int validateAfterInactivity = 5000; + @Value("${common.http-client.validateAfterInactivity}") + private int validateAfterInactivity; /** * Time to connect to the server (successful handshake), timeout throws connect timeout */ - private int connectionTimeout = 3000; + @Value("${common.http-client.connectionTimeout}") + private int connectionTimeout; /** * The time for the server to return data (response), timeout throws read timeout */ - private int readTimeout = 10000; + @Value("${common.http-client.readTimeout}") + private int readTimeout; /** * Get the timeout time of the connection from the connection pool, * and throw ConnectionPoolTimeoutException when timeout */ - private int connectionRequestTimeout = 3000; + @Value("${common.http-client.connectionRequestTimeout}") + private int connectionRequestTimeout; @Bean public PoolingHttpClientConnectionManager httpClientConnectionManager() { diff --git a/inlong-manager/manager-web/src/main/resources/application-test.properties b/inlong-manager/manager-web/src/main/resources/application-test.properties index b1a61c6e255..90d1ac428cc 100644 --- a/inlong-manager/manager-web/src/main/resources/application-test.properties +++ b/inlong-manager/manager-web/src/main/resources/application-test.properties @@ -61,9 +61,9 @@ cluster.zk.root=inlong_hive sort.appName=inlong_app # Configure http client -common.http-client.maxTotal=5001 -common.http-client.defaultMaxPerRoute=2001 -common.http-client.validateAfterInactivity=5001 -common.http-client.connectionTimeout=3001 -common.http-client.readTimeout=10001 -common.http-client.connectionRequestTimeout=3001 \ No newline at end of file +#common.http-client.maxTotal=5001 +#common.http-client.defaultMaxPerRoute=2001 +#common.http-client.validateAfterInactivity=5001 +#common.http-client.connectionTimeout=3001 +#common.http-client.readTimeout=10001 +#common.http-client.connectionRequestTimeout=3001 \ No newline at end of file