소스 검색

1、优化data-tsdb服务模块中连接influxdb数据库OkHttpClient.Builder client模块,设置连接influxdb时序数据库超时时间为24小时;
2、优化data-tranfer服务模块中连接influxdb数据库逻辑,增加OkHttpClient.Builder client模块,同时设置连接超时时间和读数据超时时间;

james 1 개월 전
부모
커밋
a4756e125e

+ 7 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/config/TsdbConfig.java

@@ -1,12 +1,15 @@
 package com.usky.transfer.service.config;
 
 import com.usky.common.core.util.StringUtils;
+import okhttp3.OkHttpClient;
 import org.influxdb.InfluxDB;
 import org.influxdb.InfluxDBFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+import java.util.concurrent.TimeUnit;
+
 @Configuration
 public class TsdbConfig {
 
@@ -30,7 +33,10 @@ public class TsdbConfig {
         if (StringUtils.isEmpty(userName)) {
             influxDB = InfluxDBFactory.connect(influxDBUrl);
         } else {
-            influxDB = InfluxDBFactory.connect(influxDBUrl, userName, password);
+            OkHttpClient.Builder client = new OkHttpClient.Builder();
+            client.readTimeout(300, TimeUnit.SECONDS);
+            client.connectTimeout(365, TimeUnit.DAYS);
+            influxDB = InfluxDBFactory.connect(influxDBUrl, userName, password, client);
         }
         try {
 

+ 4 - 1
data-tsdb-proxy/data-tsdb-proxy-biz/src/main/java/com/usky/demo/service/config/TsdbConfig.java

@@ -33,7 +33,10 @@ public class TsdbConfig {
         if (StringUtils.isEmpty(userName)) {
             influxDB = InfluxDBFactory.connect(influxDBUrl);
         } else {
-            influxDB = InfluxDBFactory.connect(influxDBUrl, userName, password);
+            OkHttpClient.Builder client = new OkHttpClient.Builder();
+            client.readTimeout(300, TimeUnit.SECONDS);
+            client.connectTimeout(365, TimeUnit.DAYS);
+            influxDB = InfluxDBFactory.connect(influxDBUrl, userName, password, client);
         }
         try {