...
|
...
|
@@ -39,7 +39,8 @@ public class MemcachedMonitService { |
|
|
updateTime=System.currentTimeMillis();
|
|
|
|
|
|
//查询逻辑分组 memcached
|
|
|
Map<String, List<MObjectInfo>> memcachedMap = queryAllMoListByLogic("memcached");
|
|
|
TypeInfo parentTypeInfo = typeInfoService.getTypeByMobjectPathArray("YOHO,middleware,memcached".split(","));
|
|
|
Map<String, List<MObjectInfo>> memcachedMap = queryAllMoListByLogic(parentTypeInfo);
|
|
|
|
|
|
if (memcachedMap.isEmpty()) {
|
|
|
//要监控内容为空,则清空map
|
...
|
...
|
@@ -47,6 +48,16 @@ public class MemcachedMonitService { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
if(MemConstants.MEMCACHED_RELATE_MAP.size()>0){
|
|
|
for(String key:MemConstants.MEMCACHED_RELATE_MAP.keySet()){
|
|
|
//把被移除的对象从缓存中清除 ,map里面的内容会重新的put ,所有不用关心
|
|
|
if(!memcachedMap.keySet().contains(key)){
|
|
|
MemConstants.MEMCACHED_RELATE_MAP.remove(key);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(memcachedMap.size());
|
|
|
|
|
|
for (Map.Entry<String, List<MObjectInfo>> entry : memcachedMap.entrySet()) {
|
...
|
...
|
@@ -55,12 +66,7 @@ public class MemcachedMonitService { |
|
|
}
|
|
|
|
|
|
|
|
|
for(String key:MemConstants.MEMCACHED_RELATE_MAP.keySet()){
|
|
|
//把被移除的对象从缓存中清除
|
|
|
if(!memcachedMap.keySet().contains(key)){
|
|
|
MemConstants.MEMCACHED_RELATE_MAP.remove(key);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
executorService.shutdown();
|
|
|
}
|
...
|
...
|
@@ -71,25 +77,20 @@ public class MemcachedMonitService { |
|
|
*
|
|
|
* @return not null
|
|
|
*/
|
|
|
public Map<String, List<MObjectInfo>> queryAllMoListByLogic(String parentName) {
|
|
|
public Map<String, List<MObjectInfo>> queryAllMoListByLogic(TypeInfo parentTypeInfo) {
|
|
|
|
|
|
Map<String, List<MObjectInfo>> serversMap = new HashMap<>();
|
|
|
|
|
|
RedisMonitService redisMonitService = SpringContextUtils.getBeanByClass(RedisMonitService.class);
|
|
|
|
|
|
TypeInfo parentTypeInfo = redisMonitService.queryParentType(parentName);
|
|
|
|
|
|
//未找到 父类型 memcached
|
|
|
if (null == parentTypeInfo) {
|
|
|
|
|
|
DEBUG.warn("Not found parent type in memcached...");
|
|
|
|
|
|
return serversMap;
|
|
|
}
|
|
|
|
|
|
RedisMonitService redisMonitService = SpringContextUtils.getBeanByClass(RedisMonitService.class);
|
|
|
|
|
|
//查询 memcached下的子类型(逻辑分组)
|
|
|
List<TypeInfo> childTypeList = redisMonitService.queryChildType(parentTypeInfo);
|
|
|
Set<String> currentKeys=new HashSet<>();
|
|
|
//Set<String> currentKeys=new HashSet<>();
|
|
|
for (TypeInfo typeInfo : childTypeList) {
|
|
|
|
|
|
List<MObjectInfo> memcacheList = redisMonitService.queryMoByType(typeInfo);
|
...
|
...
|
@@ -98,35 +99,18 @@ public class MemcachedMonitService { |
|
|
if(!memcacheList.isEmpty())
|
|
|
{
|
|
|
String logicName = typeInfo.getTypeName();
|
|
|
|
|
|
currentKeys.add(logicName);
|
|
|
|
|
|
//currentKeys.add(logicName);
|
|
|
serversMap.put(logicName, memcacheList);
|
|
|
|
|
|
/*List<MObjectInfo> sMemcacheList = serversMap.get(logicName);
|
|
|
|
|
|
//该类型下没有查询过,则新插入
|
|
|
if (null == sMemcacheList) {
|
|
|
|
|
|
serversMap.put(logicName, memcacheList);
|
|
|
|
|
|
}
|
|
|
//否则,更新已有的列表
|
|
|
else {
|
|
|
|
|
|
sMemcacheList.addAll(memcacheList);
|
|
|
|
|
|
}*/
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//把已经被去掉的不再监控对象的,从缓存中移除
|
|
|
/*//把已经被去掉的不再监控对象的,从缓存中移除
|
|
|
for(String key:serversMap.keySet()){
|
|
|
if(!currentKeys.contains(key)){
|
|
|
serversMap.remove(key);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
return serversMap;
|
|
|
}
|
|
|
|
...
|
...
|
|