FileSystemStorageStatistics(String name, FileSystem.Statistics stats) { super(name); Preconditions.checkArgument(stats != null, "FileSystem.Statistics can not be null"); Preconditions.checkArgument(stats.getData() != null, "FileSystem.Statistics can not have null data"); this.stats = stats; }
/** * In the common network topology setup, distance value should be an even * number such as 0, 2, 4, 6. To make it more general, we group distance * by {1, 2}, {3, 4} and {5 and beyond} for accounting. So if the caller * ask for bytes read for distance 2, the function will return the value * for group {1, 2}. * @param distance the network distance * @return the total number of bytes read by the network distance */ public long getBytesReadByDistance(int distance) { long bytesRead; switch (distance) { case 0: bytesRead = getData().getBytesReadLocalHost(); break; case 1: case 2: bytesRead = getData().getBytesReadDistanceOfOneOrTwo(); break; case 3: case 4: bytesRead = getData().getBytesReadDistanceOfThreeOrFour(); break; default: bytesRead = getData().getBytesReadDistanceOfFiveOrLarger(); break; } return bytesRead; }
@Override public Iterator<LongStatistic> getLongStatistics() { return new LongStatisticIterator(stats.getData()); }
@Override public Long getLong(String key) { return fetch(stats.getData(), key); }