From 5700bfe0a16876f505c6e967d4563206ad8291e9 Mon Sep 17 00:00:00 2001 From: jsonwan Date: Wed, 23 Aug 2023 09:47:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20file-worker=E5=BF=83=E8=B7=B3=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E5=90=8E=E6=94=AF=E6=8C=81=E8=87=AA=E5=8A=A8=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=20#2365?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 配置请求超时相关参数,防止单次请求阻塞 --- .../api/remote/RemoteFileWorkerResourceImpl.java | 2 +- .../bk/job/file_gateway/config/RestTemplateConfig.java | 9 ++++++++- .../bk/job/file/worker/config/RestTemplateConfig.java | 9 ++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/remote/RemoteFileWorkerResourceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/remote/RemoteFileWorkerResourceImpl.java index b8286e6710..3239e00f46 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/remote/RemoteFileWorkerResourceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/remote/RemoteFileWorkerResourceImpl.java @@ -65,7 +65,7 @@ public Response heartBeat(HeartBeatReq heartBeatReq) { @Override public Response updateFileSourceTask(UpdateFileSourceTaskReq updateFileSourceTaskReq) { - log.debug("Input=({})", updateFileSourceTaskReq); + log.info("updateFileSourceTaskReq=({})", updateFileSourceTaskReq); String taskId = updateFileSourceTaskReq.getFileSourceTaskId(); String filePath = updateFileSourceTaskReq.getFilePath(); String downloadPath = updateFileSourceTaskReq.getDownloadPath(); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/config/RestTemplateConfig.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/config/RestTemplateConfig.java index c7562cdd9a..fe1ed0c3c7 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/config/RestTemplateConfig.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/config/RestTemplateConfig.java @@ -26,12 +26,19 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.OkHttp3ClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @Configuration public class RestTemplateConfig { @Bean public RestTemplate restTemplate() { - return new RestTemplate(); + RestTemplate restTemplate = new RestTemplate(); + OkHttp3ClientHttpRequestFactory requestFactory = new OkHttp3ClientHttpRequestFactory(); + requestFactory.setConnectTimeout(5000); + requestFactory.setReadTimeout(15000); + requestFactory.setWriteTimeout(15000); + restTemplate.setRequestFactory(requestFactory); + return restTemplate; } } diff --git a/src/backend/job-file-worker-sdk/service-job-file-worker-sdk/src/main/java/com/tencent/bk/job/file/worker/config/RestTemplateConfig.java b/src/backend/job-file-worker-sdk/service-job-file-worker-sdk/src/main/java/com/tencent/bk/job/file/worker/config/RestTemplateConfig.java index 7e49b1a2aa..ebc0dde409 100644 --- a/src/backend/job-file-worker-sdk/service-job-file-worker-sdk/src/main/java/com/tencent/bk/job/file/worker/config/RestTemplateConfig.java +++ b/src/backend/job-file-worker-sdk/service-job-file-worker-sdk/src/main/java/com/tencent/bk/job/file/worker/config/RestTemplateConfig.java @@ -26,12 +26,19 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.OkHttp3ClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @Configuration public class RestTemplateConfig { @Bean public RestTemplate restTemplate() { - return new RestTemplate(); + RestTemplate restTemplate = new RestTemplate(); + OkHttp3ClientHttpRequestFactory requestFactory = new OkHttp3ClientHttpRequestFactory(); + requestFactory.setConnectTimeout(5000); + requestFactory.setReadTimeout(15000); + requestFactory.setWriteTimeout(15000); + restTemplate.setRequestFactory(requestFactory); + return restTemplate; } }