src/main/java/org/apache/hadoop/hdfs/server/namenode/cache/CachedDirectories.java
public void analyze(
      QueryEngine queryEngine,
      Collection<INode> inodeSet,
      Map<String, Long> countMap,
      Map<String, Long> diskspaceMap) {
    long start = System.currentTimeMillis();

    VirtualINodeTree tree = new VirtualINodeTree();
    cachedDirs.forEach(tree::addElement);
    List<String> commonRoots = tree.getCommonAncestorsAsStrings();

    for (String commonRoot : commonRoots) {
      Collection<INode> commonINodes =
          queryEngine.combinedFilter(
              inodeSet, new String[] {"path"}, new String[] {"startsWith:" + commonRoot});

      for (String cachedDir : cachedDirs) {
        if (!cachedDir.startsWith(commonRoot)) {
          continue;
        }
        Collection<INode> inodes;
        if (cachedDir.equals(commonRoot)) {
          inodes = commonINodes;
        } else {
          inodes =
              queryEngine.combinedFilter(
                  commonINodes, new String[] {"path"}, new String[] {"startsWith:" + cachedDir});
        }
        long count = inodes.size();
        long diskspaceConsumed = queryEngine.sum(inodes, "diskspaceConsumed");
        countMap.put(cachedDir, count);
        diskspaceMap.put(cachedDir, diskspaceConsumed);
      }
    }

    long end = System.currentTimeMillis();
    LOG.info(
        "Performed cached directory analysis using VirtualINodeTree in: " + (end - start) + "ms.");
  }
/**
   * Call to perform analysis across set of cached dirs.
   *
   * @param queryEngine queryEngine to use
   * @param inodeSet the inode set
   * @param countMap map of dir -> file count to add to
   * @param diskspaceMap map of dir -> diskspace to add to
   */
Call to perform analysis across set of cached dirs.
@param queryEngine queryEngine to use
@param inodeSet the inode set
@param countMap map of dir -> file count to add to
@param diskspaceMap map of dir -> diskspace to add to
Call to perform analysis across set of cached dirs . @param queryEngine queryEngine to use @param inodeSet the inode set @param countMap map of dir - > file count to add to @param diskspaceMap map of dir - > diskspace to add to
public void analyze(
      QueryEngine queryEngine,
      Collection<INode> inodeSet,
      Map<String, Long> countMap,
      Map<String, Long> diskspaceMap) {
    long start = System.currentTimeMillis();
    VirtualINodeTree tree = new VirtualINodeTree();
    cachedDirs.forEach(tree::addElement);
    List<String> commonRoots = tree.getCommonAncestorsAsStrings();
    for (String commonRoot : commonRoots) {
      Collection<INode> commonINodes =
          queryEngine.combinedFilter(
              inodeSet, new String[] {"path"}, new String[] {"startsWith:" + commonRoot});
      for (String cachedDir : cachedDirs) {
        if (!cachedDir.startsWith(commonRoot)) {
          continue;
        }
        Collection<INode> inodes;
        if (cachedDir.equals(commonRoot)) {
          inodes = commonINodes;
        } else {
          inodes =
              queryEngine.combinedFilter(
                  commonINodes, new String[] {"path"}, new String[] {"startsWith:" + cachedDir});
        }
        long count = inodes.size();
        long diskspaceConsumed = queryEngine.sum(inodes, "diskspaceConsumed");
        countMap.put(cachedDir, count);
        diskspaceMap.put(cachedDir, diskspaceConsumed);
      }
    }
    long end = System.currentTimeMillis();
    LOG.info(
        "Performed cached directory analysis using VirtualINodeTree in: " + (end - start) + "ms.");
  }
public void analyze ( QueryEngine queryEngine , Collection < INode > inodeSet , Map < String , Long > countMap , Map < String , Long > diskspaceMap ) { long start = System . currentTimeMillis ( ) ; VirtualINodeTree tree = new VirtualINodeTree ( ) ; cachedDirs . forEach ( tree :: addElement ) ; List < String > commonRoots = tree . getCommonAncestorsAsStrings ( ) ; for ( String commonRoot : commonRoots ) { Collection < INode > commonINodes = queryEngine . combinedFilter ( inodeSet , new String [ ] { "path" } , new String [ ] { "startsWith:" + commonRoot } ) ; for ( String cachedDir : cachedDirs ) { if ( ! cachedDir . startsWith ( commonRoot ) ) { continue ; } Collection < INode > inodes ; if ( cachedDir . equals ( commonRoot ) ) { inodes = commonINodes ; } else { inodes = queryEngine . combinedFilter ( commonINodes , new String [ ] { "path" } , new String [ ] { "startsWith:" + cachedDir } ) ; } long count = inodes . size ( ) ; long diskspaceConsumed = queryEngine . sum ( inodes , "diskspaceConsumed" ) ; countMap . put ( cachedDir , count ) ; diskspaceMap . put ( cachedDir , diskspaceConsumed ) ; } } long end = System . currentTimeMillis ( ) ; LOG . info ( "Performed cached directory analysis using VirtualINodeTree in: " + ( end - start ) + "ms." ) ; }
Call to perform analysis across set of cached dirs.
Call to perform analysis across set of cached dirs .