...
|
...
|
@@ -29,7 +29,7 @@ import java.text.DecimalFormat; |
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeoutException;
|
|
|
|
|
|
import static com.monitor.middleware.memcached.constant.MemConstants.MEMCACHED_UPDATE_TIME;
|
|
|
import static com.monitor.middleware.memcached.constant.MemConstants.MEMCACHED_INFO_MAP;
|
|
|
|
|
|
/**
|
|
|
* Created by yoho on 2016/10/11.
|
...
|
...
|
@@ -76,10 +76,29 @@ public class MemcachedMonitorImpl { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
removeInfoMap(MemConstants.MEMCACHED_NAME_MAP,MEMCACHED_INFO_MAP);
|
|
|
doMonitor(monitorUrl);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*校验是不是删除了url监控,是则从缓存中删除该url
|
|
|
* @param memcachedNameMap 现在监控的url
|
|
|
* @param memcachedInfoMap 缓存监控的url
|
|
|
*/
|
|
|
private void removeInfoMap(Map<String, String> memcachedNameMap, Map<String, MemcachedInfo> memcachedInfoMap) {
|
|
|
Set<String> exist = memcachedNameMap.keySet();
|
|
|
Set<String> cache = memcachedInfoMap.keySet();
|
|
|
Set<String> temp = new HashSet<>();
|
|
|
for(String s:cache){
|
|
|
temp.add(s);
|
|
|
}
|
|
|
temp.removeAll(exist);
|
|
|
for(String key:temp){
|
|
|
memcachedInfoMap.remove(key);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 执行监控任务
|
|
|
* @param monitorUrl 监控url
|
|
|
*/
|
...
|
...
|
@@ -155,9 +174,9 @@ public class MemcachedMonitorImpl { |
|
|
info.setUpTime(uptime / (60 * 60 * 24) + " Days");
|
|
|
info.setUseMemory(new DecimalFormat("0.00").format(bytes * 1.0 / 1024 / 1024 / 1024) + " G");
|
|
|
MemConstants.MEMCACHED_INFO_MAP.put(url, info);
|
|
|
MemConstants.MEMCACHED_UPDATE_TIME.put("memcachedUpdateTime",DateTimeUtil.unix2time(System.currentTimeMillis()));
|
|
|
LOGGER.info("MemConstants.MEMCACHED_INFO_MAP all key is {}",MemConstants.MEMCACHED_INFO_MAP.keySet());
|
|
|
}
|
|
|
MemConstants.MEMCACHED_UPDATE_TIME.put("memcachedUpdateTime",DateTimeUtil.unix2time(System.currentTimeMillis()));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|