public static FilesystemStatisticsAggregator computeFilesystemStatisticsForHost(Map<String, FilesystemStatisticsAggregator> filesystemStatistics) { FilesystemStatisticsAggregator result = new FilesystemStatisticsAggregator(); for (Map.Entry<String, FilesystemStatisticsAggregator> entry : filesystemStatistics.entrySet()) { result.add(entry.getValue()); } return result; }
public static void setFilesystemStatistics(Host host, Map<String, FilesystemStatisticsAggregator> filesystemsStatistics) throws IOException { StringBuilder statistics = new StringBuilder(); for (Map.Entry<String, FilesystemStatisticsAggregator> entry : filesystemsStatistics.entrySet()) { statistics.append(entry.getKey()); statistics.append(' '); statistics.append(entry.getValue().toString()); statistics.append('\n'); } host.setEphemeralStatistic(FILESYSTEM_STATISTICS_KEY, statistics.toString()); }
public static String formatFilesystemStatistics(FilesystemStatisticsAggregator filesystemStatistics) { return FormatUtils.formatDouble(filesystemStatistics.getUsedPercentage()) + "% used, " + FormatUtils.formatNumBytes(filesystemStatistics.getUsedSpace()) + "/" + FormatUtils.formatNumBytes(filesystemStatistics.getTotalSpace()) ; }
public static FilesystemStatisticsAggregator computeFilesystemStatisticsForHost(Map<Host, Map<String, FilesystemStatisticsAggregator>> filesystemStatistics, Host host) { if (filesystemStatistics.containsKey(host)) { return Hosts.computeFilesystemStatisticsForHost(filesystemStatistics.get(host)); } else { return new FilesystemStatisticsAggregator(); } }
public static FilesystemStatisticsAggregator computeFilesystemStatisticsForRing( Map<Ring, Map<Host, Map<String, FilesystemStatisticsAggregator>>> filesystemStatistics, Ring ring) { if (filesystemStatistics.containsKey(ring)) { return Rings.computeFilesystemStatisticsForRing(filesystemStatistics.get(ring)); } else { return new FilesystemStatisticsAggregator(); } }
public static FilesystemStatisticsAggregator computeFilesystemStatisticsForRing(Map<Host, Map<String, FilesystemStatisticsAggregator>> filesystemStatistics) { FilesystemStatisticsAggregator result = new FilesystemStatisticsAggregator(); Set<String> hostAndFilesystemRootsAdded = new HashSet<String>(); for (Map.Entry<Host, Map<String, FilesystemStatisticsAggregator>> entry1 : filesystemStatistics.entrySet()) { for (Map.Entry<String, FilesystemStatisticsAggregator> entry2 : entry1.getValue().entrySet()) { String hostAndFilesystemRoot = entry1.getKey().getAddress().getHostName() + entry2.getKey(); if (!hostAndFilesystemRootsAdded.contains(hostAndFilesystemRoot)) { hostAndFilesystemRootsAdded.add(hostAndFilesystemRoot); result.add(entry2.getValue()); } } } return result; }
private Map<String, FilesystemStatisticsAggregator> getFilesystemStatistics() throws IOException { Map<String, FilesystemStatisticsAggregator> result = new HashMap<String, FilesystemStatisticsAggregator>(); for (String filesystemRoot : getUsedFilesystemRoots()) { File filesystemRootFile = new File(filesystemRoot); result.put(filesystemRoot, new FilesystemStatisticsAggregator(filesystemRootFile.getTotalSpace(), filesystemRootFile.getUsableSpace())); } return result; }
public static FilesystemStatisticsAggregator computeFilesystemStatisticsForRingGroup( Map<Ring, Map<Host, Map<String, FilesystemStatisticsAggregator>>> filesystemStatistics) { FilesystemStatisticsAggregator result = new FilesystemStatisticsAggregator(); for (Map.Entry<Ring, Map<Host, Map<String, FilesystemStatisticsAggregator>>> entry1 : filesystemStatistics.entrySet()) { for (Map.Entry<Host, Map<String, FilesystemStatisticsAggregator>> entry2 : entry1.getValue().entrySet()) { Set<String> hostAndFilesystemRootsAdded = new HashSet<String>(); for (Map.Entry<String, FilesystemStatisticsAggregator> entry3 : entry2.getValue().entrySet()) { String hostAndFilesystemRoot = entry2.getKey().getAddress().getHostName() + entry3.getKey(); if (!hostAndFilesystemRootsAdded.contains(hostAndFilesystemRoot)) { hostAndFilesystemRootsAdded.add(hostAndFilesystemRoot); result.add(entry3.getValue()); } } } } return result; }
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; } }