Commit 950510ff by 郑冰晶

优化graceful-shutdown;add matrix-datasource log

parent 7d00ea38
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -17,9 +17,31 @@ public class BizResponse<T> extends Response<T> {
super(code, msg);
}
public BizResponse(Integer code, String msg, T data) {
super(code, msg, data);
}
public boolean isSuccess() {
return getCode() != null && getCode() == CommonConstant.Success.CODE;
return getCode() != null && getCode().equals(CommonConstant.Success.CODE);
}
public static <T> BizResponse<T> success(T data) {
return new BizResponse<>(CommonConstant.Success.CODE, CommonConstant.Success.MSG, data);
}
public static <T> BizResponse<T> success(Integer code, String msg) {
return new BizResponse<>(code, msg);
}
public static <T> BizResponse<T> success(Integer code, String msg,T data) {
return new BizResponse<>(code, msg, data);
}
public static <T> BizResponse<T> fail(Integer code, String msg) {
return new BizResponse<>(code, msg);
}
public static <T> BizResponse<T> fail(Integer code, String msg, T data) {
return new BizResponse<>(code, msg, data);
}
}
......@@ -21,6 +21,12 @@ public class Response<T> implements Serializable {
this.msg = msg;
}
public Response(Integer code, String msg, T data) {
this.code = code;
this.msg = msg;
this.data = data;
}
public Integer getCode() {
return code;
}
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -2,17 +2,15 @@ package com.secoo.mall.common.util.http;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.secoo.mall.common.util.date.DateUtil;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.*;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.entity.StringEntity;
......@@ -21,8 +19,12 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.message.BasicHeaderElementIterator;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.Args;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -36,7 +38,7 @@ import java.nio.charset.Charset;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
/**
......@@ -48,13 +50,16 @@ public class HttpClientUtils {
private static Logger LOG = LoggerFactory.getLogger(HttpClientUtils.class);
private static PoolingHttpClientConnectionManager connMgr;
private static RequestConfig requestConfig;
private static final int CONNECT_TIMEOUT = 100000;
private static final int SOCKET_TIMEOUT = 100000;
private static final int REQUEST_TIMEOUT = 2000;
private static final int CONNECT_TIMEOUT = 10000;
private static final int SOCKET_TIMEOUT = 60000;
private static final int REQUEST_TIMEOUT = 10000;
private static final int KEEPALIVE_TIMEOUT = 50000;
private static final String CHARSET = "UTF-8";
private static final ConnectionKeepAliveStrategy connectionKeepAliveStrategy;
private static final PoolingHttpClientConnectionManager connMgr;
private static RequestConfig requestConfig;
static {
// 设置连接池
connMgr = new PoolingHttpClientConnectionManager();
......@@ -69,8 +74,25 @@ public class HttpClientUtils {
configBuilder.setConnectionRequestTimeout(REQUEST_TIMEOUT);
// 等待数据超时时间
configBuilder.setSocketTimeout(SOCKET_TIMEOUT);
LOG.debug("Http参数设置,连接超时时间[{}],Socket超时时间[{}],请求超时时间[{}]", CONNECT_TIMEOUT, SOCKET_TIMEOUT);
LOG.debug("Http参数设置,连接超时时间[{}],Socket超时时间[{}],请求超时时间[{}]", CONNECT_TIMEOUT, SOCKET_TIMEOUT,REQUEST_TIMEOUT);
requestConfig = configBuilder.build();
connectionKeepAliveStrategy = new ConnectionKeepAliveStrategy() {
@Override
public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {
Args.notNull(httpResponse, "HTTP response");
final HeaderElementIterator it = new BasicHeaderElementIterator(httpResponse.headerIterator(HTTP.CONN_KEEP_ALIVE));
while (it.hasNext()) {
final HeaderElement he = it.nextElement();
final String param = he.getName();
final String value = he.getValue();
if (value != null && param.equalsIgnoreCase("timeout")) {
return Long.parseLong(value) * 1000;
}
}
return KEEPALIVE_TIMEOUT;
}
};
}
/**
......@@ -103,7 +125,7 @@ public class HttpClientUtils {
String result = doGet(url, new HashMap<>(10));
return result;
} catch (Exception e) {
LOG.error("发送 GET 请求ERROR :{}", e);
LOG.error("发送 GET 请求ERROR:", e);
}
return "";
}
......@@ -125,7 +147,7 @@ public class HttpClientUtils {
String result = null;
if (StringUtils.isEmpty(url)) {
LOG.debug("warn:doGet url is null or '' ");
LOG.warn("doGet url is null or '' ");
return result;
}
......@@ -133,8 +155,11 @@ public class HttpClientUtils {
for (Map.Entry<String, Object> entry : params.entrySet()) {
pairList.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
}
CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr).build();
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr)
.setKeepAliveStrategy(connectionKeepAliveStrategy)
.build();
CloseableHttpResponse response = null;
InputStream instream = null;
try {
......@@ -169,15 +194,16 @@ public class HttpClientUtils {
}
public static HttpEntity doGetByDefault(String url) throws Exception {
CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr).build();
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr)
.setKeepAliveStrategy(connectionKeepAliveStrategy)
.build();
HttpGet httpGet = new HttpGet(url);
CloseableHttpResponse response = httpclient.execute(httpGet);
LOG.info("doGet statusCode:{}", response.getStatusLine().getStatusCode());
LOG.debug("doGet statusCode:{}", response.getStatusLine().getStatusCode());
return response.getEntity();
......@@ -186,8 +212,11 @@ public class HttpClientUtils {
public static String doDelete(String url, Map<String, String> headers, Map<String, String> params) throws Exception {
CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr).build();
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr)
.setKeepAliveStrategy(connectionKeepAliveStrategy)
.build();
CloseableHttpResponse response = null;
InputStream instream = null;
List<NameValuePair> pairList = new ArrayList<>(params.size());
......@@ -209,7 +238,7 @@ public class HttpClientUtils {
response = httpclient.execute(httpDelete);
LOG.info("httpDelete statusCode:{}", response.getStatusLine().getStatusCode());
LOG.debug("httpDelete statusCode:{}", response.getStatusLine().getStatusCode());
HttpEntity entity = response.getEntity();
if (entity != null) {
......@@ -251,8 +280,11 @@ public class HttpClientUtils {
});
CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr).build();
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr)
.setKeepAliveStrategy(connectionKeepAliveStrategy)
.build();
CloseableHttpResponse response = null;
InputStream instream = null;
try {
......@@ -272,7 +304,7 @@ public class HttpClientUtils {
}
response = httpclient.execute(httpPut);
LOG.info("doGet statusCode:{}", response.getStatusLine().getStatusCode());
LOG.debug("doGet statusCode:{}", response.getStatusLine().getStatusCode());
HttpEntity entity = response.getEntity();
if (entity != null) {
......@@ -315,7 +347,7 @@ public class HttpClientUtils {
public static String doPost(String url, Map<String, Object> params) throws Exception {
if (StringUtils.isEmpty(url)) {
LOG.info("warn:doPost url is null or '' ");
LOG.warn("doPost url is null or '' ");
return null;
}
List<NameValuePair> pairList = new ArrayList<>(params.size());
......@@ -339,7 +371,7 @@ public class HttpClientUtils {
public static String doPost(String url, String xml) throws Exception {
if (StringUtils.isEmpty(url)) {
LOG.info("warn:doPost url is null or '' ");
LOG.warn("doPost url is null or '' ");
return null;
}
......@@ -359,7 +391,7 @@ public class HttpClientUtils {
public static String doPost(String url, Object json) throws Exception {
if (StringUtils.isEmpty(url)) {
LOG.error("warn:doPostByJson url is null or '' ");
LOG.warn("doPostByJson url is null or '' ");
return null;
}
HttpPost httpPost = new HttpPost(url);
......@@ -373,7 +405,7 @@ public class HttpClientUtils {
public static String doPost(String url, HttpEntity entity, Map<String, String> headers) throws Exception {
if (StringUtils.isEmpty(url)) {
LOG.error("warn:doPostByJson url is null or '' ");
LOG.warn("doPostByJson url is null or '' ");
return null;
}
HttpPost httpPost = new HttpPost(url);
......@@ -396,7 +428,7 @@ public class HttpClientUtils {
public static String doPostSsl(String apiUrl, Map<String, Object> params) throws Exception {
if (StringUtils.isEmpty(apiUrl)) {
LOG.info("warn:doPostSSL url is null or '' ");
LOG.warn("doPostSSL url is null or '' ");
return null;
}
......@@ -421,7 +453,7 @@ public class HttpClientUtils {
public static String doPostSsl(String apiUrl, Object json) throws Exception {
if (StringUtils.isEmpty(apiUrl)) {
LOG.info("warn:doPostSSL By Json url is null or '' ");
LOG.warn("doPostSSL By Json url is null or '' ");
return null;
}
......@@ -456,10 +488,17 @@ public class HttpClientUtils {
SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy())
.build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext);
httpClient = HttpClients.custom().setConnectionManager(connMgr).setSSLSocketFactory(sslsf)
.setDefaultRequestConfig(requestConfig).build();
httpClient = HttpClients.custom()
.setConnectionManager(connMgr)
.setSSLSocketFactory(sslsf)
.setDefaultRequestConfig(requestConfig)
.setKeepAliveStrategy(connectionKeepAliveStrategy)
.build();
} else {
httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).setConnectionManager(connMgr)
httpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(connMgr)
.setKeepAliveStrategy(connectionKeepAliveStrategy)
.build();
}
response = httpClient.execute(httpPost);
......@@ -497,33 +536,36 @@ public class HttpClientUtils {
final String[] content = new String[1];
content[0]="";
// 传入HttpPost request
CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom().setDefaultRequestConfig(requestConfig).build();
LOG.info("httpclient test begin time:{}", DateUtil.getDateTime());
CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
.setDefaultRequestConfig(requestConfig)
.setKeepAliveStrategy(connectionKeepAliveStrategy)
.build();
LOG.debug("httpclient test begin time:{}", LocalDateTime.now());
httpclient.start();
httpclient.execute(request, new FutureCallback<HttpResponse>() {
@Override
public void completed(final HttpResponse response) {
LOG.info(request.getRequestLine() + "->" + response.getStatusLine());
LOG.info("httpclient test received content time:{}",DateUtil.getDateTime());
LOG.debug(request.getRequestLine() + "->" + response.getStatusLine());
LOG.debug("httpclient test received content time:{}",LocalDateTime.now());
try {
content[0] = EntityUtils.toString(response.getEntity(), "UTF-8");
content[0] = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (IOException e) {
LOG.error("matrix HttpClientUtils asynchronousPost error",e);
}
}
@Override
public void failed(final Exception ex) {
LOG.info("httpclient test received failed time:{}",DateUtil.getDateTime());
LOG.error(request.getRequestLine() + "->" + ex);
LOG.debug("httpclient test received failed time:{}", LocalDateTime.now());
LOG.error(request.getRequestLine() + "->", ex);
}
@Override
public void cancelled() {
LOG.info("httpclient test received cancelled time:{}",DateUtil.getDateTime());
LOG.error(request.getRequestLine() + " cancelled");
LOG.debug("httpclient test received cancelled time:{}",LocalDateTime.now());
LOG.warn(request.getRequestLine() + " cancelled");
}
});
LOG.info("httpclient test end time:{}",DateUtil.getDateTime());
LOG.debug("httpclient test end time:{}",LocalDateTime.now());
return content[0];
}
......
......@@ -78,7 +78,7 @@ public class StringUtil extends StringUtils {
}
public static String line(){
String lineSeparator = System.getProperty("line.separator", "\n");
String lineSeparator = System.getProperty("line.separator", String.valueOf(CharConstant.LF));
return lineSeparator;
}
......@@ -95,5 +95,9 @@ public class StringUtil extends StringUtils {
System.out.println("toHyphen=="+toHyphen(str3,'-'));
System.out.println(toSnakeCase("test-jdate", '-'));
System.out.println(line());
System.out.println("========");
}
}
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-bigdata</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-bigdata</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-bus</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-client</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-datahelper</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-datahelper</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -21,7 +21,7 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-datahelper-redis-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-datasource</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -13,6 +13,7 @@ import com.secoo.mall.datasource.constant.DataSourceConstant;
import com.secoo.mall.datasource.errorcode.DataSourceError;
import com.secoo.mall.datasource.util.SysUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.StopWatch;
import java.io.InputStream;
import java.net.HttpURLConnection;
......@@ -60,6 +61,9 @@ public class EncryptorFactory<T> {
* @return
*/
private String initPrivateKey() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
String appId = configUtil.getAppId();
if (StringUtil.isEmpty(appId)) {
throw new BusinessException(DataSourceError.APP_ID_NOT_EXIST);
......@@ -84,11 +88,14 @@ public class EncryptorFactory<T> {
return String.join("", strings);
}
} catch (Exception e) {
log.error("connetion server error", e);
log.error("", e);
} finally {
if (connection != null) {
connection.disconnect();
}
stopWatch.stop();
log.info("init PrivateKey elapsed {}ms",stopWatch.getTime());
}
return null;
......@@ -96,15 +103,21 @@ public class EncryptorFactory<T> {
private void createEncryptor() {
if (StringUtil.isNotEmpty(this.privateKey)) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
MatrixUrlClassLoader.getInstance().loadByUrl(DataSourceConstant.SECURITY_FILE_JAR_PATH);
String[] args = this.privateKey.split(DataSourceConstant.ENCRY_FLAG);
encryptor = MatrixUrlClassLoader.getInstance().loadClassByFullName("com.secoo.mall.app.security.encryptor.StringEncryptor", Encryptor.class, new Class[]{String.class, String.class}, args);
stopWatch.stop();
log.info("create Encryptor elapsed {}ms",stopWatch.getTime());
}
/**
* 如果无法从远程创建解密对象,则进行降级处理
*/
if (Objects.isNull(encryptor)) {
log.warn("load remote encryptor fail.use default encryptor");
log.warn("load remote encryptor fail, use default encryptor");
encryptor = new Encryptor<T>() {
@Override
public T encrypt(T value) {
......
......@@ -14,6 +14,7 @@ import com.secoo.mall.datasource.properties.MatrixDataSourceProperties;
import com.secoo.mall.datasource.util.SysUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.commons.lang3.time.StopWatch;
import javax.sql.DataSource;
import java.lang.reflect.Field;
......@@ -34,9 +35,14 @@ public class ApolloDataSourceProvider<T extends MatrixDataSourceConfig> extends
@Override
protected List<T> getDataSourceProperties() {
log.info("load config from apollo...");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Config appConfig = ConfigService.getConfig(DataSourceConstant.DB_NAMESPACE);
Set<String> propertyNames = appConfig.getPropertyNames();
List<T> list = Lists.newArrayList();
stopWatch.stop();
log.info("load config from apollo elapsed {}ms",stopWatch.getTime());
Map<String, DataSource> dataSourceMap = new HashMap<>();
......@@ -50,6 +56,7 @@ public class ApolloDataSourceProvider<T extends MatrixDataSourceConfig> extends
Map<String, Class> fieldMap = FieldUtil.getAllFieldsList(getEntryClass()).stream().collect(Collectors.toMap(Field::getName, Field::getType, (key1, key2) -> key1));
Set<String> notSupportPropertySet = new HashSet<>();
List<T> list = Lists.newArrayList();
try {
for (Map.Entry<String, List<String>> entry : dsPpropertyMap.entrySet()) {
String dsName = entry.getKey();
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-datasource</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -21,7 +21,7 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-datasource-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
package com.secoo.mall.gracefulshutdown.autoconfigure;
import com.secoo.mall.common.core.service.UpDatas;
import com.secoo.mall.common.util.string.StringUtil;
import com.secoo.mall.gracefulshutdown.component.UpDatas;
import com.secoo.mall.gracefulshutdown.component.ShutDownDataReportAsyncHttp;
import com.secoo.mall.gracefulshutdown.monitor.config.ConfigCenter;
import com.secoo.mall.gracefulshutdown.monitor.dubbo.exception.ConfigurationException;
import com.secoo.mall.gracefulshutdown.monitor.dubbo.service.ProviderService;
import com.secoo.mall.gracefulshutdown.monitor.dubbo.service.RegistryServerSync;
import com.secoo.mall.gracefulshutdown.monitor.dubbo.service.impl.ProviderServiceImpl;
import com.secoo.mall.gracefulshutdown.monitor.utils.Tool;
import com.secoo.mall.gracefulshutdown.component.GracefulShutDown;
import com.secoo.mall.gracefulshutdown.component.ShutDownDataReport;
import com.secoo.mall.gracefulshutdown.component.TomcatGracefulShutDown;
import com.secoo.mall.gracefulshutdown.component.hook.DubboCustomerShutDownHook;
import com.secoo.mall.gracefulshutdown.component.hook.TomcatShutDownHook;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.registry.Registry;
......
package com.secoo.mall.gracefulshutdown.component;
import com.secoo.mall.common.core.service.StopService;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetail;
import com.secoo.mall.gracefulshutdown.component.model.ExecutorDetail;
public abstract class AbstractShutDown implements StopService<ExecutorDetail>,Comparable {
//定义执行顺序
......
......@@ -2,9 +2,7 @@ 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://test-exwarn.secoo.com/gracefulshutdown/gracefulSave";
public static String EXWARN="http://exwarn.secoo.com/gracefulshutdown/gracefulSave";
public static String EXWARN_URL ="http://exwarn.secoo.com/gracefulshutdown/gracefulSave";
public static final int CONNECT_TIMEOUT = 1000;//连接超时时间
public static final int SOCKET_TIMEOUT = 5000;//等待数据超时时间
......
package com.secoo.mall.gracefulshutdown.component;
import com.alibaba.fastjson.JSON;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetail;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetails;
import com.secoo.mall.common.core.service.StopService;
import com.secoo.mall.common.core.service.UpDatas;
import com.secoo.mall.gracefulshutdown.component.model.ExecutorDetail;
import com.secoo.mall.gracefulshutdown.component.model.ExecutorDetails;
import com.secoo.mall.common.util.date.DateUtil;
import com.secoo.mall.common.util.log.LoggerUtil;
import com.secoo.mall.gracefulshutdown.monitor.utils.Tool;
import com.secoo.mall.gracefulshutdown.component.hook.TomcatShutDownHook;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.DubboShutdownHook;
import org.apache.dubbo.config.spring.extension.SpringExtensionFactory;
......
package com.secoo.mall.gracefulshutdown.component;
import com.alibaba.fastjson.JSON;
import com.secoo.mall.common.core.service.UpDatas;
import com.secoo.mall.common.util.log.LoggerUtil;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetails;
import com.secoo.mall.gracefulshutdown.component.model.ExecutorDetails;
import com.secoo.mall.common.util.string.StringUtil;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
......
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.gracefulshutdown.component.model.ExecutorDetails;
import com.secoo.mall.common.util.http.HttpClientUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
......@@ -22,7 +21,7 @@ public class ShutDownDataReportAsyncHttp implements UpDatas<ExecutorDetails> {
try {
String result=JSON.toJSONString(obj);
HttpPost httpPost = new HttpPost(ConfigConstant.EXWARN);
HttpPost httpPost = new HttpPost(ConfigConstant.EXWARN_URL);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("gracefulresult", result));
HttpClientUtils.setHttpParam(ConfigConstant.CONNECT_TIMEOUT,ConfigConstant.SOCKET_TIMEOUT,ConfigConstant.REQUEST_TIMEOUT);
......
package com.secoo.mall.common.core.service;
package com.secoo.mall.gracefulshutdown.component;
public interface StopService <T>{
......
package com.secoo.mall.common.core.service;
package com.secoo.mall.gracefulshutdown.component;
public interface UpDatas<T> {
public boolean upData(T t) throws Exception;
......
package com.secoo.mall.gracefulshutdown.component.hook;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetail;
import com.secoo.mall.gracefulshutdown.component.model.ExecutorDetail;
import com.secoo.mall.common.util.date.DateUtil;
import com.secoo.mall.common.util.log.LoggerUtil;
import com.secoo.mall.common.util.string.StringUtil;
import com.secoo.mall.gracefulshutdown.monitor.dubbo.Constants.Constants;
import com.secoo.mall.gracefulshutdown.monitor.dubbo.service.ProviderService;
import com.secoo.mall.gracefulshutdown.monitor.dubbo.service.RegistryServerSync;
import com.secoo.mall.gracefulshutdown.monitor.utils.Stack;
......
......@@ -2,7 +2,7 @@ package com.secoo.mall.gracefulshutdown.component.hook;
import com.secoo.mall.common.util.date.DateUtil;
import com.secoo.mall.common.util.string.StringUtil;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetail;
import com.secoo.mall.gracefulshutdown.component.model.ExecutorDetail;
import com.secoo.mall.gracefulshutdown.component.AbstractShutDown;
import org.apache.catalina.connector.Connector;
import java.util.ArrayList;
......
package com.secoo.mall.common.core.bean.gracefulshowtdownBean;
package com.secoo.mall.gracefulshutdown.component.model;
public class AbstractTransportData<T> {
T t;
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-job</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-job</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-job</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -21,12 +21,12 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-job-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-job-xxl-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-mq</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-mq</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-mq</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -27,7 +27,7 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mq-rocketmq-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-mybatis</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-mybatis</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -25,17 +25,17 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mybatis-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-datasource-druid</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mybatis-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-protocol</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-protocol</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-protocol</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-protocol</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-protocol</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -29,27 +29,27 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-web-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-dubbo-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-web-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-dubbo-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<!-- Aapche Dubbo -->
......
......@@ -6,7 +6,7 @@
<groupId>com.secoo.mall</groupId>
<artifactId>matrix</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
<packaging>pom</packaging>
......@@ -54,119 +54,119 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>logger-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>common-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>config-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>common-util</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-datasource-druid</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mybatis-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mybatis-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mq-rocketmq-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mq-rocketmq-client</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<!--rocketmq-starter废弃,启用matrix-mq-rocketmq-starter-->
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mq-rocketmq-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-dubbo-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-dubbo-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-web-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-protocol-web-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-job-xxl-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-job-xxl-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-bigdata-hbase-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<!--redis-->
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-datahelper-redis-core</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-datahelper-redis-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-client-openfeign-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<!-- bus -->
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-bus-canal-starter</artifactId>
<version>2.0.17.RELEASE</version>
<version>2.0.18.RELEASE</version>
</dependency>
<!--普通jar-->
......@@ -196,11 +196,6 @@
<version>1.2.58</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.2</version>
......
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