Authored by zhengyouwei

fix influx

1 package com.monitor.nginxsync.nio.service; 1 package com.monitor.nginxsync.nio.service;
2 2
3 import com.monitor.nginxsync.nio.handler.LogMsgHandler; 3 import com.monitor.nginxsync.nio.handler.LogMsgHandler;
4 -import com.squareup.okhttp.Call;  
5 import io.netty.bootstrap.ServerBootstrap; 4 import io.netty.bootstrap.ServerBootstrap;
6 import io.netty.channel.ChannelFuture; 5 import io.netty.channel.ChannelFuture;
7 import io.netty.channel.ChannelInitializer; 6 import io.netty.channel.ChannelInitializer;
1 package com.monitor.zabbix.comp; 1 package com.monitor.zabbix.comp;
2 2
3 import com.monitor.zabbix.constants.Constants; 3 import com.monitor.zabbix.constants.Constants;
4 -import com.squareup.okhttp.OkHttpClient; 4 +import okhttp3.OkHttpClient;
5 import org.influxdb.InfluxDB; 5 import org.influxdb.InfluxDB;
6 import org.influxdb.InfluxDBFactory; 6 import org.influxdb.InfluxDBFactory;
7 import org.influxdb.dto.BatchPoints; 7 import org.influxdb.dto.BatchPoints;
@@ -12,7 +12,6 @@ import org.slf4j.Logger; @@ -12,7 +12,6 @@ import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory; 12 import org.slf4j.LoggerFactory;
13 import org.springframework.beans.factory.annotation.Value; 13 import org.springframework.beans.factory.annotation.Value;
14 import org.springframework.stereotype.Component; 14 import org.springframework.stereotype.Component;
15 -import retrofit.client.OkClient;  
16 15
17 import javax.annotation.PostConstruct; 16 import javax.annotation.PostConstruct;
18 import java.util.concurrent.TimeUnit; 17 import java.util.concurrent.TimeUnit;
@@ -38,15 +37,13 @@ public class InfluxdbComp { @@ -38,15 +37,13 @@ public class InfluxdbComp {
38 37
39 @PostConstruct 38 @PostConstruct
40 public void init() { 39 public void init() {
41 - OkHttpClient okHttpClient = new OkHttpClient(); 40 + OkHttpClient.Builder builder = new OkHttpClient.Builder();
  41 + builder.connectTimeout(15, TimeUnit.SECONDS);
  42 + builder.readTimeout(40, TimeUnit.SECONDS);
  43 + builder.writeTimeout(20, TimeUnit.SECONDS);
42 44
43 - okHttpClient.setConnectTimeout(15, TimeUnit.SECONDS);  
44 45
45 - okHttpClient.setReadTimeout(40, TimeUnit.SECONDS);  
46 -  
47 - okHttpClient.setWriteTimeout(20, TimeUnit.SECONDS);  
48 -  
49 - influxDBClient = InfluxDBFactory.connect(this.influxUrl, this.influxUser, this.influxPwd, new OkClient(okHttpClient)); 46 + influxDBClient = InfluxDBFactory.connect(this.influxUrl, this.influxUser, this.influxPwd, builder);
50 } 47 }
51 48
52 49