use of com.bonree.brfs.resourceschedule.model.MemoryStatModel 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;
}
Aggregations