use of com.sohu.cache.entity.InstanceInfo in project cachecloud by sohutv.
the class BaseController method fillAppInstanceStats.
/**
* 实例统计信息
*
* @param appId
* @param model
*/
protected void fillAppInstanceStats(Long appId, Model model) {
List<InstanceInfo> instanceList = appService.getAppInstanceInfo(appId);
List<InstanceStats> appInstanceStats = appService.getAppInstanceStats(appId);
Map<String, InstanceStats> instanceStatsMap = new HashMap<String, InstanceStats>();
for (InstanceStats instanceStats : appInstanceStats) {
instanceStatsMap.put(instanceStats.getIp() + ":" + instanceStats.getPort(), instanceStats);
}
model.addAttribute("instanceList", instanceList);
model.addAttribute("instanceStatsMap", instanceStatsMap);
//slot分布
Map<String, InstanceSlotModel> clusterSlotsMap = redisCenter.getClusterSlotsMap(appId);
model.addAttribute("clusterSlotsMap", clusterSlotsMap);
}
use of com.sohu.cache.entity.InstanceInfo in project cachecloud by sohutv.
the class MachineManageController method fillInstanceModel.
/**
* 实例统计信息
* @param appAudit
* @param model
*/
protected void fillInstanceModel(List<InstanceInfo> instanceList, List<InstanceStats> appInstanceStats, Model model) {
Map<String, MachineStats> machineStatsMap = new HashMap<String, MachineStats>();
Map<String, Long> machineCanUseMem = new HashMap<String, Long>();
Map<String, InstanceStats> instanceStatsMap = new HashMap<String, InstanceStats>();
Map<Long, AppDesc> appInfoMap = new HashMap<Long, AppDesc>();
for (InstanceStats instanceStats : appInstanceStats) {
instanceStatsMap.put(instanceStats.getIp() + ":" + instanceStats.getPort(), instanceStats);
appInfoMap.put(instanceStats.getAppId(), appService.getByAppId(instanceStats.getAppId()));
}
for (InstanceInfo instanceInfo : instanceList) {
if (TypeUtil.isRedisSentinel(instanceInfo.getType())) {
continue;
}
String ip = instanceInfo.getIp();
if (machineStatsMap.containsKey(ip)) {
continue;
}
List<MachineStats> machineStatsList = machineCenter.getMachineStats(ip);
MachineStats machineStats = null;
for (MachineStats stats : machineStatsList) {
if (stats.getIp().equals(ip)) {
machineStats = stats;
machineStatsMap.put(ip, machineStats);
break;
}
}
MachineStats ms = machineCenter.getMachineMemoryDetail(ip);
machineCanUseMem.put(ip, ms.getMachineMemInfo().getLockedMem());
}
model.addAttribute("appInfoMap", appInfoMap);
model.addAttribute("machineCanUseMem", machineCanUseMem);
model.addAttribute("machineStatsMap", machineStatsMap);
model.addAttribute("instanceList", instanceList);
model.addAttribute("instanceStatsMap", instanceStatsMap);
}
use of com.sohu.cache.entity.InstanceInfo in project cachecloud by sohutv.
the class MachineManageController method doMachineInstances.
/**
* 机器实例展示
* @param ip
* @return
*/
@RequestMapping(value = "/machineInstances")
public ModelAndView doMachineInstances(HttpServletRequest request, HttpServletResponse response, Model model, String ip) {
//机器以及机器下面的实例信息
MachineInfo machineInfo = machineCenter.getMachineInfoByIp(ip);
List<InstanceInfo> instanceList = machineCenter.getMachineInstanceInfo(ip);
List<InstanceStats> instanceStatList = machineCenter.getMachineInstanceStatsByIp(ip);
//统计信息
fillInstanceModel(instanceList, instanceStatList, model);
model.addAttribute("machineInfo", machineInfo);
model.addAttribute("machineActive", SuccessEnum.SUCCESS.value());
return new ModelAndView("manage/machine/machineInstances");
}
use of com.sohu.cache.entity.InstanceInfo in project cachecloud by sohutv.
the class InstanceStatsCenterImpl method getInstanceStats.
@Override
public InstanceStats getInstanceStats(long instanceId) {
InstanceStats instanceStats = instanceStatsDao.getInstanceStatsByInsId(instanceId);
if (instanceStats == null) {
logger.error("instanceStats id={} is null", instanceId);
return null;
}
InstanceInfo instanceInfo = instanceDao.getInstanceInfoById(instanceId);
int type = instanceInfo.getType();
boolean isRun = isRun(type, instanceInfo.getIp(), instanceInfo.getPort());
instanceStats.setRun(isRun);
if (isRun) {
Map<String, Object> infoMap = getInfoMap(type, instanceInfo.getIp(), instanceInfo.getPort());
instanceStats.setInfoMap(infoMap);
if (infoMap == null || infoMap.isEmpty()) {
instanceStats.setRun(false);
}
}
return instanceStats;
}
use of com.sohu.cache.entity.InstanceInfo in project cachecloud by sohutv.
the class InstanceStatsCenterImpl method getStandardStatsList.
@Override
public Map<Integer, Map<String, List<InstanceCommandStats>>> getStandardStatsList(Long appId, long beginTime, long endTime, List<String> commands) {
if (appId == null) {
return Collections.emptyMap();
}
List<InstanceInfo> list = instanceDao.getInstListByAppId(appId);
if (list == null || list.isEmpty()) {
return Collections.emptyMap();
}
Map<Integer, Map<String, List<InstanceCommandStats>>> resultMap = new LinkedHashMap<Integer, Map<String, List<InstanceCommandStats>>>();
for (InstanceInfo instance : list) {
if (instance.isOffline()) {
continue;
}
int instanceId = instance.getId();
String ip = instance.getIp();
int port = instance.getPort();
int type = instance.getType();
Boolean isMaster = redisCenter.isMaster(ip, port);
if (BooleanUtils.isNotTrue(isMaster)) {
continue;
}
List<Map<String, Object>> objectList = this.queryDiffMapList(beginTime, endTime, ip, port, ConstUtils.REDIS);
;
if (objectList != null) {
Map<String, List<InstanceCommandStats>> commandMap = new LinkedHashMap<String, List<InstanceCommandStats>>();
for (String commandName : commands) {
List<InstanceCommandStats> resultList = new ArrayList<InstanceCommandStats>(objectList.size());
for (Map<String, Object> map : objectList) {
InstanceCommandStats stats = parseCommand(instanceId, commandName, map, false, type);
if (stats != null) {
resultList.add(stats);
}
}
commandMap.put(commandName, resultList);
}
resultMap.put(instanceId, commandMap);
}
}
return resultMap;
}
Aggregations