Search in sources :

Example 1 with MachineMemInfo

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;
}
Also used : InstanceStats(com.sohu.cache.entity.InstanceStats) MachineStats(com.sohu.cache.entity.MachineStats) MachineMemInfo(com.sohu.cache.entity.MachineMemInfo)

Example 2 with MachineMemInfo

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;
}
Also used : MachineInfo(com.sohu.cache.entity.MachineInfo) InstanceStats(com.sohu.cache.entity.InstanceStats) MachineStats(com.sohu.cache.entity.MachineStats) MachineMemInfo(com.sohu.cache.entity.MachineMemInfo)

Aggregations

InstanceStats (com.sohu.cache.entity.InstanceStats)2 MachineMemInfo (com.sohu.cache.entity.MachineMemInfo)2 MachineStats (com.sohu.cache.entity.MachineStats)2 MachineInfo (com.sohu.cache.entity.MachineInfo)1