List of usage examples for org.apache.hadoop.fs FileSystem getAllStatistics
@Deprecated public static synchronized List<Statistics> getAllStatistics()
From source file:org.apache.tez.mapreduce.common.Utils.java
License:Apache License
/** * Gets a handle to the Statistics instance based on the scheme associated * with path.// www . ja v a2 s . c om * * @param path the path. * @param conf the configuration to extract the scheme from if not part of * the path. * @return a Statistics instance, or null if none is found for the scheme. */ @Private public static List<Statistics> getFsStatistics(Path path, Configuration conf) throws IOException { List<Statistics> matchedStats = new ArrayList<FileSystem.Statistics>(); path = path.getFileSystem(conf).makeQualified(path); String scheme = path.toUri().getScheme(); for (Statistics stats : FileSystem.getAllStatistics()) { if (stats.getScheme().equals(scheme)) { matchedStats.add(stats); } } return matchedStats; }
From source file:org.apache.tez.runtime.metrics.TaskCounterUpdater.java
License:Apache License
public void updateCounters() { // FileSystemStatistics are reset each time a new task is seen by the // container. // This doesn't remove the fileSystem, and does not clear all statistics - // so there is a potential of an unused FileSystem showing up for a // Container, and strange values for READ_OPS etc. Map<String, List<FileSystem.Statistics>> map = new HashMap<String, List<FileSystem.Statistics>>(); for (Statistics stat : FileSystem.getAllStatistics()) { String uriScheme = stat.getScheme(); if (map.containsKey(uriScheme)) { List<FileSystem.Statistics> list = map.get(uriScheme); list.add(stat);/* w w w.ja va 2s .c o m*/ } else { List<FileSystem.Statistics> list = new ArrayList<FileSystem.Statistics>(); list.add(stat); map.put(uriScheme, list); } } for (Map.Entry<String, List<FileSystem.Statistics>> entry : map.entrySet()) { FileSystemStatisticUpdater updater = statisticUpdaters.get(entry.getKey()); if (updater == null) {//new FileSystem has been found in the cache updater = new FileSystemStatisticUpdater(tezCounters, entry.getValue(), entry.getKey()); statisticUpdaters.put(entry.getKey(), updater); } updater.updateCounters(); } gcUpdater.incrementGcCounter(); updateResourceCounters(); }