Authored by jack

Merge branch 'dev_memcache'

@@ -46,20 +46,20 @@ public class MemcachedCtrl { @@ -46,20 +46,20 @@ public class MemcachedCtrl {
46 } 46 }
47 } 47 }
48 48
49 -  
50 - Collections.sort(memList, new Comparator<MemcachedVo>() {  
51 - @Override  
52 - public int compare(MemcachedVo o1, MemcachedVo o2) {  
53 -  
54 - if (o1.getName().compareTo(o2.getName()) > 0) {  
55 - return 1;  
56 - } else if (o1.getName().compareTo(o2.getName()) < 0) {  
57 - return -1; 49 + //排序:先按照l1、l2拆分,再对11、l2根据ip排序,最后合并
  50 + List<MemcachedVo> l1List = new ArrayList<>();
  51 + List<MemcachedVo> l2List = new ArrayList<>();
  52 + for(MemcachedVo vo:memList){
  53 + if(vo.getName().startsWith("java_l1_memcached")){
  54 + l1List.add(vo);
  55 + }else{
  56 + l2List.add(vo);
58 } 57 }
59 - return 0;  
60 } 58 }
61 - });  
62 - response.setData(memList); 59 + Collections.sort(l1List, new URLComparator());
  60 + Collections.sort(l2List, new URLComparator());
  61 + l1List.addAll(l2List);
  62 + response.setData(l1List);
63 63
64 return response; 64 return response;
65 } 65 }
@@ -88,4 +88,18 @@ public class MemcachedCtrl { @@ -88,4 +88,18 @@ public class MemcachedCtrl {
88 vo.setName(MemConstants.MEMCACHED_NAME_MAP.get(key)); 88 vo.setName(MemConstants.MEMCACHED_NAME_MAP.get(key));
89 } 89 }
90 90
  91 + private class URLComparator implements Comparator<MemcachedVo>{
  92 +
  93 + @Override
  94 + public int compare(MemcachedVo o1, MemcachedVo o2) {
  95 +
  96 + if (o1.getUrl().compareTo(o2.getUrl()) > 0) {
  97 + return 1;
  98 + } else if (o1.getUrl().compareTo(o2.getUrl()) < 0) {
  99 + return -1;
  100 + }
  101 + return 0;
  102 + }
  103 + }
  104 +
91 } 105 }
@@ -132,7 +132,6 @@ public class MemcachedMonitorImpl { @@ -132,7 +132,6 @@ public class MemcachedMonitorImpl {
132 long oldSet = MemConstants.MEMCACHED_INFO_MAP.get(url).getOldSet(); 132 long oldSet = MemConstants.MEMCACHED_INFO_MAP.get(url).getOldSet();
133 info.setCmdSet((cmdSet - oldSet) / 120.0); 133 info.setCmdSet((cmdSet - oldSet) / 120.0);
134 } 134 }
135 -  
136 info.setCurConnections(Integer.parseInt(value.get("curr_connections"))); 135 info.setCurConnections(Integer.parseInt(value.get("curr_connections")));
137 info.setCurItems(Integer.parseInt(value.get("curr_items"))); 136 info.setCurItems(Integer.parseInt(value.get("curr_items")));
138 long get_hit = Long.parseLong(value.get("get_hits")); 137 long get_hit = Long.parseLong(value.get("get_hits"));
@@ -140,7 +139,7 @@ public class MemcachedMonitorImpl { @@ -140,7 +139,7 @@ public class MemcachedMonitorImpl {
140 long limit_maxbytes = Long.parseLong(value.get("limit_maxbytes")); 139 long limit_maxbytes = Long.parseLong(value.get("limit_maxbytes"));
141 long bytes = Long.parseLong(value.get("bytes")); 140 long bytes = Long.parseLong(value.get("bytes"));
142 long uptime = Long.parseLong(value.get("uptime")); 141 long uptime = Long.parseLong(value.get("uptime"));
143 - 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); 142 + 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);
144 if ((get_hit + get_misses) == 0) { 143 if ((get_hit + get_misses) == 0) {
145 info.setHitRate("100.0%"); 144 info.setHitRate("100.0%");
146 } else { 145 } else {
@@ -150,6 +149,7 @@ public class MemcachedMonitorImpl { @@ -150,6 +149,7 @@ public class MemcachedMonitorImpl {
150 info.setUpTime(uptime / (60 * 60 * 24) + " Days"); 149 info.setUpTime(uptime / (60 * 60 * 24) + " Days");
151 info.setUseMemory(new DecimalFormat("0.00").format(bytes * 1.0 / 1024 / 1024 / 1024) + " G"); 150 info.setUseMemory(new DecimalFormat("0.00").format(bytes * 1.0 / 1024 / 1024 / 1024) + " G");
152 MemConstants.MEMCACHED_INFO_MAP.put(url, info); 151 MemConstants.MEMCACHED_INFO_MAP.put(url, info);
  152 + LOGGER.info("MemConstants.MEMCACHED_INFO_MAP all key is {}",MemConstants.MEMCACHED_INFO_MAP.keySet());
153 } 153 }
154 } 154 }
155 } 155 }