/** * Add MBean monitors on the given monitorTargets. * * @param monitorTargets a set of monitor targets * @param reportPath report path */ public void add(Set<AgentInfo> monitorTargets, File reportPath) { for (AgentInfo target : monitorTargets) { String targetKey = createTargetKey(target); if (!monitorClientsMap.containsKey(targetKey)) { MonitorClientSerivce bean = applicationContext.getBean(MonitorClientSerivce.class); bean.init( target.getIp(), target.getPort(), reportPath, cacheManager.getCache("monitor_data")); monitorClientsMap.put(targetKey, bean); } } }
@Override public void run() { Map<String, SystemDataModel> systemInfoMap = Maps.newHashMap(); for (Entry<String, MonitorClientSerivce> target : monitorClientsMap.entrySet()) { MonitorClientSerivce monitorClientSerivce = target.getValue(); SystemInfo saveDataCache = monitorClientSerivce.saveDataCache(); if (saveDataCache != null) { systemInfoMap.put(target.getKey(), new SystemDataModel(saveDataCache, "UNKNOWN")); } } perfTestService.updateMonitorStat(perfTestId, systemInfoMap); }
/** * Save the {@link org.ngrinder.monitor.share.domain.SystemInfo} into the report path. * * @param empty true if empty data should be saved. */ public void saveData(boolean empty) { for (Entry<String, MonitorClientSerivce> target : monitorClientsMap.entrySet()) { MonitorClientSerivce monitorClientSerivce = target.getValue(); monitorClientSerivce.record(empty); } }