Search in sources :

Example 1 with CpuStatModel

use of com.bonree.brfs.resourceschedule.model.CpuStatModel in project BRFS by zhangnianli.

the class GatherResource method sumServerStatus.

/**
 * 概述:汇总状态信息
 * @param cache
 * @return
 * @user <a href=mailto:zhucg@bonree.com>朱成岗</a>
 */
public static ServerStatModel sumServerStatus(Cache cache) {
    Queue<ServerStatModel> tmpqueue = cache.statInfoQueue;
    if (tmpqueue.size() < 2) {
        return null;
    }
    // 汇总状态信息
    int size = tmpqueue.size();
    ServerStatModel prex = null;
    ServerStatModel current = null;
    CpuStatModel cpuObj = new CpuStatModel();
    MemoryStatModel memObj = new MemoryStatModel();
    // 磁盘IO率集合
    Map<String, List<PatitionStatModel>> patMap = null;
    // 网卡IO率集合
    Map<String, List<NetStatModel>> netMap = null;
    CommonMapCalcInterface<String, NetStatModel> netInstance = new MapModelCalc<String, NetStatModel>();
    CommonMapCalcInterface<String, PatitionStatModel> patInstance = new MapModelCalc<String, PatitionStatModel>();
    for (int i = 0; i < size; i++) {
        current = tmpqueue.poll();
        // 1.统计cpu状态
        cpuObj = cpuObj.calc(current.getCpuStatInfo());
        // 2.统计内存状态
        memObj = memObj.calc(current.getMemoryStatInfo());
        if (i == 0) {
            prex = current;
            continue;
        }
        // 3.统计网卡IO
        netMap = netInstance.collectModels(netMap, netInstance.calcMapData(current.getNetStatInfoMap(), prex.getNetStatInfoMap()));
        // 4.统计磁盘IO
        patMap = patInstance.collectModels(patMap, patInstance.calcMapData(current.getPatitionStatInfoMap(), prex.getPatitionStatInfoMap()));
    }
    Map<String, NetStatModel> netResult = netInstance.sumMapData(netMap);
    Map<String, PatitionStatModel> patResult = patInstance.sumMapData(patMap);
    ServerStatModel obj = new ServerStatModel();
    obj.setCpuStatInfo(cpuObj);
    obj.setMemoryStatInfo(memObj);
    obj.setNetStatInfoMap(netResult);
    obj.setPatitionStatInfoMap(patResult);
    obj.setSnRemainSizeMap(cache.snRemainSizeMap);
    return obj;
}
Also used : MemoryStatModel(com.bonree.brfs.resourceschedule.model.MemoryStatModel) NetStatModel(com.bonree.brfs.resourceschedule.model.NetStatModel) PatitionStatModel(com.bonree.brfs.resourceschedule.model.PatitionStatModel) ServerStatModel(com.bonree.brfs.resourceschedule.model.ServerStatModel) CpuStatModel(com.bonree.brfs.resourceschedule.model.CpuStatModel) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

CpuStatModel (com.bonree.brfs.resourceschedule.model.CpuStatModel)1 MemoryStatModel (com.bonree.brfs.resourceschedule.model.MemoryStatModel)1 NetStatModel (com.bonree.brfs.resourceschedule.model.NetStatModel)1 PatitionStatModel (com.bonree.brfs.resourceschedule.model.PatitionStatModel)1 ServerStatModel (com.bonree.brfs.resourceschedule.model.ServerStatModel)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1