Esempio n. 1
0
 private synchronized void updateCounters() {
   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);
     } 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(entry.getValue(), entry.getKey());
       statisticUpdaters.put(entry.getKey(), updater);
     }
     updater.updateCounters();
   }
   gcUpdater.incrementGcCounter();
   updateResourceCounters();
 }
Esempio n. 2
0
 /**
  * Gets a handle to the Statistics instance based on the scheme associated with path.
  *
  * @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.
  */
 protected 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;
 }