...
|
...
|
@@ -8,7 +8,6 @@ import com.monitor.middleware.memcached.model.MemcachedVo; |
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
...
|
...
|
@@ -25,6 +24,15 @@ import java.util.*; |
|
|
public class MemcachedCtrl {
|
|
|
public static final Logger DEBUG = LoggerFactory.getLogger(MemcachedCtrl.class);
|
|
|
|
|
|
private static final String AWS_JAVA_L1 = "aws_java_l1";
|
|
|
|
|
|
private static final String AWS_JAVA_L2 = "aws_java_l2";
|
|
|
|
|
|
private static final String QCLOUD_JAVA_L1 = "qcloud_java_l1";
|
|
|
|
|
|
private static final String QCLOUD_JAVA_L2 = "qcloud_java_l2";
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
IMObjectInfoService imObjectInfoService;
|
|
|
|
...
|
...
|
@@ -46,25 +54,69 @@ public class MemcachedCtrl { |
|
|
}
|
|
|
}
|
|
|
|
|
|
//排序:先按照l1、l2拆分,再对11、l2根据ip排序,最后合并
|
|
|
List<MemcachedVo> l1List = new ArrayList<>();
|
|
|
List<MemcachedVo> l2List = new ArrayList<>();
|
|
|
List<MemcachedVo> aws1 = new ArrayList<>();
|
|
|
List<MemcachedVo> aws2 = new ArrayList<>();
|
|
|
List<MemcachedVo> qcloud1 = new ArrayList<>();
|
|
|
List<MemcachedVo> qcloud2 = new ArrayList<>();
|
|
|
for(MemcachedVo vo:memList){
|
|
|
if(vo.getName().startsWith("java_l1_memcached")){
|
|
|
l1List.add(vo);
|
|
|
if(vo.getName().startsWith(AWS_JAVA_L1)){
|
|
|
aws1.add(vo);
|
|
|
}else if(vo.getName().startsWith(AWS_JAVA_L2)){
|
|
|
aws2.add(vo);
|
|
|
}else if(vo.getName().startsWith(QCLOUD_JAVA_L1)){
|
|
|
qcloud1.add(vo);
|
|
|
}else{
|
|
|
l2List.add(vo);
|
|
|
qcloud2.add(vo);
|
|
|
}
|
|
|
}
|
|
|
Collections.sort(l1List, new URLComparator());
|
|
|
Collections.sort(l2List, new URLComparator());
|
|
|
l1List.addAll(l2List);
|
|
|
response.setData(l1List);
|
|
|
Collections.sort(aws1, new URLComparator());
|
|
|
Collections.sort(aws2, new URLComparator());
|
|
|
Collections.sort(qcloud1, new URLComparator());
|
|
|
Collections.sort(qcloud2, new URLComparator());
|
|
|
|
|
|
List<MemcachedVo> result = new ArrayList<>();
|
|
|
if(!CollectionUtils.isEmpty(aws1)){
|
|
|
result.add(mergeMemcacheVo(aws1,AWS_JAVA_L1));
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(aws2)){
|
|
|
result.add(mergeMemcacheVo(aws2,AWS_JAVA_L2));
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(qcloud1)){
|
|
|
result.add(mergeMemcacheVo(qcloud1,QCLOUD_JAVA_L1));
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(qcloud2)){
|
|
|
result.add(mergeMemcacheVo(qcloud2,QCLOUD_JAVA_L2));
|
|
|
}
|
|
|
|
|
|
response.setData(result);
|
|
|
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 合并同类的memcached
|
|
|
* @param list
|
|
|
*/
|
|
|
private MemcachedVo mergeMemcacheVo(List<MemcachedVo> list,String name) {
|
|
|
MemcachedVo temp = list.get(0);
|
|
|
temp.setName(name);
|
|
|
for(int i=1;i<list.size();i++){
|
|
|
MemcachedVo vo = list.get(i);
|
|
|
temp.setUpTime(temp.getUpTime()+"\r\n"+vo.getUpTime());
|
|
|
temp.setUrl(temp.getUrl()+"\r\n"+vo.getUrl());
|
|
|
temp.setHitRate(temp.getHitRate()+"\r\n"+vo.getHitRate());
|
|
|
temp.setUseMemory(temp.getUseMemory()+"\r\n"+vo.getUseMemory());
|
|
|
temp.setCurItems(temp.getCurItems()+"\r\n"+vo.getCurItems());
|
|
|
temp.setMaxMemory(temp.getMaxMemory()+"\r\n"+vo.getMaxMemory());
|
|
|
temp.setCmdGet(temp.getCmdGet()+"\r\n"+vo.getCmdGet());
|
|
|
temp.setCmdSet(temp.getCmdSet()+"\r\n"+vo.getCmdSet());
|
|
|
temp.setCurConnections(temp.getCurConnections()+"\r\n"+vo.getCurConnections());
|
|
|
}
|
|
|
return temp;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 组装返回对象
|
|
|
* @param info
|
|
|
* @param vo
|
...
|
...
|
|