use of com.sohu.cache.entity.MachineMemInfo in project cachecloud by sohutv.
the class MachineCenterImpl method getMachineMemoryDetail.
@Override
public MachineStats getMachineMemoryDetail(String ip) {
long applyMem = 0;
long usedMem = 0;
List<InstanceStats> instanceStats = instanceStatsDao.getInstanceStatsByIp(ip);
for (InstanceStats instance : instanceStats) {
applyMem += instance.getMaxMemory();
usedMem += instance.getUsedMemory();
}
MachineStats machineStats = machineStatsDao.getMachineStatsByIp(ip);
machineStats.setInfo(machineDao.getMachineInfoByIp(ip));
MachineMemInfo machineMemInfo = new MachineMemInfo();
machineMemInfo.setIp(ip);
machineMemInfo.setApplyMem(applyMem);
machineMemInfo.setUsedMem(usedMem);
machineStats.setMachineMemInfo(machineMemInfo);
int memoryHost = instanceDao.getMemoryByHost(ip);
machineStats.setMemoryAllocated(memoryHost);
return machineStats;
}
use of com.sohu.cache.entity.MachineMemInfo in project cachecloud by sohutv.
the class MachineCenterImpl method getAllMachineStats.
@Override
public List<MachineStats> getAllMachineStats() {
List<MachineStats> list = machineStatsDao.getAllMachineStats();
for (MachineStats ms : list) {
String ip = ms.getIp();
MachineInfo machineInfo = machineDao.getMachineInfoByIp(ip);
if (machineInfo == null || machineInfo.isOffline()) {
continue;
}
int memoryHost = instanceDao.getMemoryByHost(ip);
getMachineMemoryDetail(ms.getIp());
//获取机器申请和使用内存
long applyMem = 0;
long usedMem = 0;
List<InstanceStats> instanceStats = instanceStatsDao.getInstanceStatsByIp(ip);
for (InstanceStats instance : instanceStats) {
applyMem += instance.getMaxMemory();
usedMem += instance.getUsedMemory();
}
MachineMemInfo machineMemInfo = new MachineMemInfo();
machineMemInfo.setIp(ip);
machineMemInfo.setApplyMem(applyMem);
machineMemInfo.setUsedMem(usedMem);
ms.setMachineMemInfo(machineMemInfo);
ms.setMemoryAllocated(memoryHost);
ms.setInfo(machineInfo);
}
return list;
}
Aggregations