public static long computeUpdateETA(Host host) { try { if (host.getState() != HostState.UPDATING) { return -1; } String etaString = host.getStatistic(UPDATE_ETA_STATISTIC_KEY); if (etaString != null) { return Long.parseLong(etaString); } else { return -1; } } catch (IOException e) { return -1; } }
public static Map<String, FilesystemStatisticsAggregator> computeFilesystemStatistics(Host host) throws IOException { String filesystemsStatistics = host.getStatistic(FILESYSTEM_STATISTICS_KEY); if (filesystemsStatistics == null) { return Collections.emptyMap(); } else { TreeMap<String, FilesystemStatisticsAggregator> result = new TreeMap<String, FilesystemStatisticsAggregator>(); String[] filesystemStatistics = filesystemsStatistics.split("\n"); for (String statistics : filesystemStatistics) { if (statistics.length() == 0) { continue; } String[] tokens = statistics.split(" "); String filesystemRoot = tokens[0]; long totalSpace = Long.parseLong(tokens[1]); long usableSpace = Long.parseLong(tokens[2]); result.put(filesystemRoot, new FilesystemStatisticsAggregator(totalSpace, usableSpace)); } return result; } }
public static Map<Domain, RuntimeStatisticsAggregator> computeRuntimeStatistics(Coordinator coordinator, Host host) throws IOException { String runtimeStatistics = host.getStatistic(RUNTIME_STATISTICS_KEY); if (runtimeStatistics == null) { return Collections.emptyMap(); } else { Map<Domain, RuntimeStatisticsAggregator> result = new HashMap<Domain, RuntimeStatisticsAggregator>(); String[] domainStatistics = runtimeStatistics.split("\n"); for (String statistics : domainStatistics) { if (statistics.length() == 0) { continue; } String[] tokens = statistics.split("\t"); int domainId = Integer.parseInt(tokens[0]); result.put(coordinator.getDomainById(domainId), RuntimeStatisticsAggregator.parse(tokens[1])); } return result; } }
protected HostData getHostData(Host host) throws IOException { HostData data = new HostData(); data.address = host.getAddress(); data.isOnline = Hosts.isOnline(host); data.state = host.getState(); data.statisticsString = host.getStatistic(Hosts.RUNTIME_STATISTICS_KEY); data.statisticsJson = getRuntimeStatsString(host); return data; }