use of com.bonree.brfs.resourceschedule.model.ServerStatModel in project BRFS by zhangnianli.
the class GatherResource method gatherServerStatInfo.
/**
* 概述:采集状态信息
* @param dataPath
* @return
* @user <a href=mailto:zhucg@bonree.com>朱成岗</a>
*/
public static void gatherServerStatInfo(Cache cache) {
ServerStatModel obj = new ServerStatModel();
Map<String, NetStatModel> netMap = null;
Map<String, PatitionStatModel> patitionMap = null;
Map<String, String> snToPatitionMap = new ConcurrentHashMap<String, String>();
try {
netMap = SigarUtils.instance.gatherNetStatInfos();
patitionMap = SigarUtils.instance.gatherPatitionStatInfos(cache);
obj.setCpuStatInfo(SigarUtils.instance.gatherCpuStatInfo());
obj.setMemoryStatInfo(SigarUtils.instance.gatherMemoryStatInfo());
if (netMap != null) {
obj.setNetStatInfoMap(netMap);
}
if (patitionMap != null) {
obj.setPatitionStatInfoMap(patitionMap);
if (cache.snWithDisk != null && !cache.snWithDisk.isEmpty()) {
cache.snRemainSizeMap = matchSnRemainSizeMap(cache.snWithDisk, patitionMap);
}
}
} catch (SigarException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cache.statInfoQueue.add(obj);
}
use of com.bonree.brfs.resourceschedule.model.ServerStatModel 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