Commit 9b985c0b authored by 江洋洋's avatar 江洋洋

warmup bug修复

parent a15e1afb
......@@ -38,7 +38,7 @@ allprojects {
}
group = "cn.com.duiba.boot"
version = "0.0.32"
version = "0.0.34"
}
subprojects {
......
......@@ -143,14 +143,15 @@ public class CacheConfig {
return;
}
logger.info("container of all registered AppInfo size: {}", instances.size());
List<InstanceInfo> list = instances.stream().sorted(Comparator.comparing(InstanceInfo::getLastUpdatedTimestamp).reversed()).collect(Collectors.toList());
List<InstanceInfo> list = instances.stream().sorted((o1, o2) -> (int) (o2.getLeaseInfo().getServiceUpTimestamp()-o1.getLeaseInfo().getServiceUpTimestamp())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(list)) {
logger.warn("Cache preheating failed,because 服务启动获取【" + appName + "】列表信息为空");
return;
}
logger.info("打印warmup获取备份数据实例信息:{}", JSONObject.toJSONString(list.get(0)));
String result = HttpRequestUtils.sendHttp(list.get(0).getHomePageUrl() + "/local/getCacheMap", null, appName);
if (StringUtils.isBlank(result)) {
logger.warn("Cache preheating failed,because request {} ,response {}, instance status{}", list.get(0).getHomePageUrl() + "/local/getCacheMap", result, list.get(0).getStatus());
logger.warn("Cache preheating failed,because request {} ,response {}", list.get(0).getHomePageUrl() + "/local/getCacheMap", result);
return;
}
......
......@@ -29,7 +29,7 @@ public class HttpRequestUtils {
*/
public static String sendHttp(String url , Map<String, String> param, String appName){
CloseableHttpClient httpClient = HttpClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom().setConnectTimeout(150).setSocketTimeout(150).setConnectionRequestTimeout(100).build())
.setDefaultRequestConfig(RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(10000).setConnectionRequestTimeout(10000).build())
.setMaxConnPerRoute(1)
.setMaxConnTotal(1000)
.evictExpiredConnections()//开启后台线程定时清理失效的连接,每隔10秒主动扫描并逐出超时的连接(超过keepAliveTimeout)
......
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