Commit fddc2858 by 房斌

http传递

parent 3ed15d4d
package com.secoo.mall.gracefulshutdown.component;
public class ConfigConstant {
// public static String EXWARN="http://172.17.76.196:6080/gracefulshutdown/gracefulSave";
public static String EXWARN="http://exwarn.secoo.com/gracefulshutdown/gracefulSave";
public static final int CONNECT_TIMEOUT = 1000;//连接超时时间
public static final int SOCKET_TIMEOUT = 5000;//等待数据超时时间
public static final int REQUEST_TIMEOUT = 1000;//连接不够时等待超时时间,不设置将阻塞线程
}
package com.secoo.mall.gracefulshutdown.component;
import com.alibaba.fastjson.JSON;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetails;
import com.secoo.mall.common.core.service.UpDatas;
import com.secoo.mall.common.util.http.HttpClientUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class ShutDownDataReportAsyncHttp implements UpDatas<ExecutorDetails> {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public boolean upData(ExecutorDetails obj) {
try {
String result=JSON.toJSONString(obj);
HttpPost httpPost = new HttpPost(ConfigConstant.EXWARN);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("gracefulresult", result));
HttpClientUtils.setHttpParam(ConfigConstant.CONNECT_TIMEOUT,ConfigConstant.SOCKET_TIMEOUT,ConfigConstant.REQUEST_TIMEOUT);
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
String back= HttpClientUtils.asynchronousPost(httpPost);
return true;
}catch (Exception e){
logger.error("matrix ShutDownDataReportAsyncHttp upData error",e);
}
return false;
}
}
...@@ -57,6 +57,10 @@ ...@@ -57,6 +57,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies> </dependencies>
......
...@@ -2,8 +2,8 @@ package com.secoo.mall.dubbo.monitor.utils; ...@@ -2,8 +2,8 @@ package com.secoo.mall.dubbo.monitor.utils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.secoo.mall.common.util.http.HttpClientUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.MultipartEntityBuilder;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment