Authored by jack

Merge branch 'dev_memcache'

... ... @@ -46,20 +46,20 @@ public class MemcachedCtrl {
}
}
Collections.sort(memList, new Comparator<MemcachedVo>() {
@Override
public int compare(MemcachedVo o1, MemcachedVo o2) {
if (o1.getName().compareTo(o2.getName()) > 0) {
return 1;
} else if (o1.getName().compareTo(o2.getName()) < 0) {
return -1;
}
return 0;
//排序:先按照l1、l2拆分,再对11、l2根据ip排序,最后合并
List<MemcachedVo> l1List = new ArrayList<>();
List<MemcachedVo> l2List = new ArrayList<>();
for(MemcachedVo vo:memList){
if(vo.getName().startsWith("java_l1_memcached")){
l1List.add(vo);
}else{
l2List.add(vo);
}
});
response.setData(memList);
}
Collections.sort(l1List, new URLComparator());
Collections.sort(l2List, new URLComparator());
l1List.addAll(l2List);
response.setData(l1List);
return response;
}
... ... @@ -88,4 +88,18 @@ public class MemcachedCtrl {
vo.setName(MemConstants.MEMCACHED_NAME_MAP.get(key));
}
private class URLComparator implements Comparator<MemcachedVo>{
@Override
public int compare(MemcachedVo o1, MemcachedVo o2) {
if (o1.getUrl().compareTo(o2.getUrl()) > 0) {
return 1;
} else if (o1.getUrl().compareTo(o2.getUrl()) < 0) {
return -1;
}
return 0;
}
}
}
\ No newline at end of file
... ...
... ... @@ -132,7 +132,6 @@ public class MemcachedMonitorImpl {
long oldSet = MemConstants.MEMCACHED_INFO_MAP.get(url).getOldSet();
info.setCmdSet((cmdSet - oldSet) / 120.0);
}
info.setCurConnections(Integer.parseInt(value.get("curr_connections")));
info.setCurItems(Integer.parseInt(value.get("curr_items")));
long get_hit = Long.parseLong(value.get("get_hits"));
... ... @@ -140,7 +139,7 @@ public class MemcachedMonitorImpl {
long limit_maxbytes = Long.parseLong(value.get("limit_maxbytes"));
long bytes = Long.parseLong(value.get("bytes"));
long uptime = Long.parseLong(value.get("uptime"));
LOGGER.debug(url + " monitor info: com_get is {},cmd_set is {},get_hit is {},get_misses is {},limit_maxbytes is {},bytes is {},uptime is {}", cmdGet, cmdSet, get_hit, get_misses, limit_maxbytes, bytes, uptime);
LOGGER.info(url + " monitor info: com_get is {},cmd_set is {},get_hit is {},get_misses is {},limit_maxbytes is {},bytes is {},uptime is {}", cmdGet, cmdSet, get_hit, get_misses, limit_maxbytes, bytes, uptime);
if ((get_hit + get_misses) == 0) {
info.setHitRate("100.0%");
} else {
... ... @@ -150,6 +149,7 @@ 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);
LOGGER.info("MemConstants.MEMCACHED_INFO_MAP all key is {}",MemConstants.MEMCACHED_INFO_MAP.keySet());
}
}
}
... ...