Authored by qinchao

修改java服务信息:刷新时偶尔数据为空问题

... ... @@ -208,6 +208,9 @@ public class JavaApiClient {
//close 线程池
executorService.shutdownNow();
long endTime = System.currentTimeMillis();
//任务执行完毕
javaApiStatus.cacheStatus();
log.info("task stop cost {} ms ...", endTime - startTime);
}
... ...
... ... @@ -24,9 +24,9 @@ public class JavaApiStatus {
*/
private ConcurrentHashMap<String, AtomicInteger> mapStaticsErr = new ConcurrentHashMap<String, AtomicInteger>();
private ConcurrentHashMap<String, AtomicInteger> mapStaticsOk = new ConcurrentHashMap<String, AtomicInteger>();
private ConcurrentHashMap<String, Long> mapUpdateTime = new ConcurrentHashMap<String, Long>();
//private ConcurrentHashMap<String, Integer> cloudDetailMap = new ConcurrentHashMap<String, Integer>();
private List<JavaApiStaticsRep> statusList=new ArrayList<>();
public void addError(JavaApiStatics javaApiStatics) {
String key=getKey(javaApiStatics);
... ... @@ -53,6 +53,9 @@ public class JavaApiStatus {
public void clear() {
//把最近一次的数据缓存起来
cacheStatus();
mapStaticsErr.clear();
mapStaticsOk.clear();
mapUpdateTime.clear();
... ... @@ -66,12 +69,14 @@ public class JavaApiStatus {
* @return
*/
public List<JavaApiStaticsRep> getStatusList() {
return statusList;
}
List<JavaApiStaticsRep> rel = new ArrayList<JavaApiStaticsRep>();
public void cacheStatus(){
List<JavaApiStaticsRep> rel = new ArrayList<JavaApiStaticsRep>();
MultiKeyMap multiKeyMap = new MultiKeyMap();
Enumeration<String> errkeys = mapStaticsErr.keys();
while (errkeys.hasMoreElements()) {
String key = errkeys.nextElement();
... ... @@ -113,7 +118,7 @@ public class JavaApiStatus {
javaApiStaticsRep.setUpdateTime(DateFormatUtil.parseLongToTimeStr(time));
}
return rel;
statusList =rel;
}
... ...