src/main/java/org/apache/hadoop/hdfs/server/namenode/cache/CachedQuotas.java
public void analyze(
      NameNodeLoader loader,
      Collection<INode> dirs,
      Map<String, Long> dsQuotaCountsUsers,
      Map<String, Long> nsQuotaCountsUsers,
      Map<String, Long> dsQuotaThreshCountsUsers,
      Map<String, Long> nsQuotaThreshCountsUsers) {
    /* If there is no namesystem (static testing), then exit. */
    if (loader.getCurrentTxId() == -1L) {
      return;
    }

    final QueryEngine queryEngine = loader.getQueryEngine();
    final Map<String, Map<String, Set<INode>>> ownerDirContentSummary =
        queryEngine
            .combinedFilterToStream(dirs, new String[] {"hasQuota"}, new String[] {"eq:true"})
            .collect(
                Collectors.groupingBy(
                    INode::getUserName,
                    Collectors.groupingBy(
                        INode::getFullPathName,
                        Collectors.mapping(Function.identity(), Collectors.toSet()))));
    cachedUserNsQuotaAssigned.clear();
    cachedUserNsQuotaUsed.clear();
    cachedUserNsQuotaRatios.clear();
    cachedUserDsQuotaAssigned.clear();
    cachedUserDsQuotaUsed.clear();
    cachedUserDsQuotaRatios.clear();
    for (Entry<String, Map<String, Set<INode>>> entry : ownerDirContentSummary.entrySet()) {
      long nsQuotaRatio85 = 0;
      long dsQuotaRatio85 = 0;
      long nsQuotaCount = 0;
      long dsQuotaCount = 0;
      Map<String, Long> nsQuotaAssigned = new HashMap<>();
      Map<String, Long> nsQuotaUsed = new HashMap<>();
      Map<String, Long> nsQuotaRatio = new HashMap<>();
      Map<String, Long> dsQuotaAssigned = new HashMap<>();
      Map<String, Long> dsQuotaUsed = new HashMap<>();
      Map<String, Long> dsQuotaRatio = new HashMap<>();
      String user = entry.getKey();
      for (Entry<String, Set<INode>> innerEntry : entry.getValue().entrySet()) {
        INode value = innerEntry.getValue().iterator().next();
        Long nsQuotaRatioLong =
            queryEngine.getSumFunctionForINode("nsQuotaRatioUsed", null).apply(value);
        if (nsQuotaRatioLong >= 0) {
          nsQuotaCount++;
          if (nsQuotaRatioLong >= 85) {
            nsQuotaRatio85++;
          }
        } else {
          nsQuotaRatioLong = -1L;
        }
        Long nsQuotaAssignedLong = queryEngine.getSumFunctionForINode("nsQuota", null).apply(value);
        if (nsQuotaAssignedLong <= -1L) {
          nsQuotaAssignedLong = -1L;
        }
        Long nsQuotaUsedLong = queryEngine.getSumFunctionForINode("nsQuotaUsed", null).apply(value);
        if (nsQuotaUsedLong <= -1L) {
          nsQuotaUsedLong = -1L;
        }
        Long dsQuotaRatioLong =
            queryEngine.getSumFunctionForINode("dsQuotaRatioUsed", null).apply(value);
        if (dsQuotaRatioLong >= 0) {
          dsQuotaCount++;
          if (dsQuotaRatioLong >= 85) {
            dsQuotaRatio85++;
          }
        } else {
          dsQuotaRatioLong = -1L;
        }
        Long dsQuotaAssignedLong = queryEngine.getSumFunctionForINode("dsQuota", null).apply(value);
        if (dsQuotaAssignedLong <= -1L) {
          dsQuotaAssignedLong = -1L;
        }
        Long dsQuotaUsedLong = queryEngine.getSumFunctionForINode("dsQuotaUsed", null).apply(value);
        if (dsQuotaUsedLong <= -1L) {
          dsQuotaUsedLong = -1L;
        }
        String path = innerEntry.getKey();
        nsQuotaAssigned.put(path, nsQuotaAssignedLong);
        dsQuotaAssigned.put(path, dsQuotaAssignedLong);
        nsQuotaUsed.put(path, nsQuotaUsedLong);
        dsQuotaUsed.put(path, dsQuotaUsedLong);
        nsQuotaRatio.put(path, nsQuotaRatioLong);
        dsQuotaRatio.put(path, dsQuotaRatioLong);
      }
      cachedUserNsQuotaAssigned.put(user, nsQuotaAssigned);
      cachedUserNsQuotaUsed.put(user, nsQuotaUsed);
      cachedUserNsQuotaRatios.put(user, nsQuotaRatio);
      cachedUserDsQuotaAssigned.put(user, dsQuotaAssigned);
      cachedUserDsQuotaUsed.put(user, dsQuotaUsed);
      cachedUserDsQuotaRatios.put(user, dsQuotaRatio);
      nsQuotaThreshCountsUsers.put(user, nsQuotaRatio85);
      dsQuotaThreshCountsUsers.put(user, dsQuotaRatio85);
      nsQuotaCountsUsers.put(user, nsQuotaCount);
      dsQuotaCountsUsers.put(user, dsQuotaCount);
    }
  }
/**
   * Main analysis call for compute all quotas and quota usage information.
   *
   * @param loader the nn loader
   * @param dirs set of inode directories
   * @param dsQuotaCountsUsers map of user -> # of ds quotas they have
   * @param nsQuotaCountsUsers map of user -> # of ns quotas they have
   * @param dsQuotaThreshCountsUsers map of user -> # of high ds usage dirs they have
   * @param nsQuotaThreshCountsUsers map of user -> # of high ns usage dirs they have
   */
Main analysis call for compute all quotas and quota usage information.
Main analysis call for compute all quotas and quota usage information .
public void analyze(
      NameNodeLoader loader,
      Collection<INode> dirs,
      Map<String, Long> dsQuotaCountsUsers,
      Map<String, Long> nsQuotaCountsUsers,
      Map<String, Long> dsQuotaThreshCountsUsers,
      Map<String, Long> nsQuotaThreshCountsUsers) {
    /* If there is no namesystem (static testing), then exit. */
    if (loader.getCurrentTxId() == -1L) {
      return;
    }
    final QueryEngine queryEngine = loader.getQueryEngine();
    final Map<String, Map<String, Set<INode>>> ownerDirContentSummary =
        queryEngine
            .combinedFilterToStream(dirs, new String[] {"hasQuota"}, new String[] {"eq:true"})
            .collect(
                Collectors.groupingBy(
                    INode::getUserName,
                    Collectors.groupingBy(
                        INode::getFullPathName,
                        Collectors.mapping(Function.identity(), Collectors.toSet()))));
    cachedUserNsQuotaAssigned.clear();
    cachedUserNsQuotaUsed.clear();
    cachedUserNsQuotaRatios.clear();
    cachedUserDsQuotaAssigned.clear();
    cachedUserDsQuotaUsed.clear();
    cachedUserDsQuotaRatios.clear();
    for (Entry<String, Map<String, Set<INode>>> entry : ownerDirContentSummary.entrySet()) {
      long nsQuotaRatio85 = 0;
      long dsQuotaRatio85 = 0;
      long nsQuotaCount = 0;
      long dsQuotaCount = 0;
      Map<String, Long> nsQuotaAssigned = new HashMap<>();
      Map<String, Long> nsQuotaUsed = new HashMap<>();
      Map<String, Long> nsQuotaRatio = new HashMap<>();
      Map<String, Long> dsQuotaAssigned = new HashMap<>();
      Map<String, Long> dsQuotaUsed = new HashMap<>();
      Map<String, Long> dsQuotaRatio = new HashMap<>();
      String user = entry.getKey();
      for (Entry<String, Set<INode>> innerEntry : entry.getValue().entrySet()) {
        INode value = innerEntry.getValue().iterator().next();
        Long nsQuotaRatioLong =
            queryEngine.getSumFunctionForINode("nsQuotaRatioUsed", null).apply(value);
        if (nsQuotaRatioLong >= 0) {
          nsQuotaCount++;
          if (nsQuotaRatioLong >= 85) {
            nsQuotaRatio85++;
          }
        } else {
          nsQuotaRatioLong = -1L;
        }
        Long nsQuotaAssignedLong = queryEngine.getSumFunctionForINode("nsQuota", null).apply(value);
        if (nsQuotaAssignedLong <= -1L) {
          nsQuotaAssignedLong = -1L;
        }
        Long nsQuotaUsedLong = queryEngine.getSumFunctionForINode("nsQuotaUsed", null).apply(value);
        if (nsQuotaUsedLong <= -1L) {
          nsQuotaUsedLong = -1L;
        }
        Long dsQuotaRatioLong =
            queryEngine.getSumFunctionForINode("dsQuotaRatioUsed", null).apply(value);
        if (dsQuotaRatioLong >= 0) {
          dsQuotaCount++;
          if (dsQuotaRatioLong >= 85) {
            dsQuotaRatio85++;
          }
        } else {
          dsQuotaRatioLong = -1L;
        }
        Long dsQuotaAssignedLong = queryEngine.getSumFunctionForINode("dsQuota", null).apply(value);
        if (dsQuotaAssignedLong <= -1L) {
          dsQuotaAssignedLong = -1L;
        }
        Long dsQuotaUsedLong = queryEngine.getSumFunctionForINode("dsQuotaUsed", null).apply(value);
        if (dsQuotaUsedLong <= -1L) {
          dsQuotaUsedLong = -1L;
        }
        String path = innerEntry.getKey();
        nsQuotaAssigned.put(path, nsQuotaAssignedLong);
        dsQuotaAssigned.put(path, dsQuotaAssignedLong);
        nsQuotaUsed.put(path, nsQuotaUsedLong);
        dsQuotaUsed.put(path, dsQuotaUsedLong);
        nsQuotaRatio.put(path, nsQuotaRatioLong);
        dsQuotaRatio.put(path, dsQuotaRatioLong);
      }
      cachedUserNsQuotaAssigned.put(user, nsQuotaAssigned);
      cachedUserNsQuotaUsed.put(user, nsQuotaUsed);
      cachedUserNsQuotaRatios.put(user, nsQuotaRatio);
      cachedUserDsQuotaAssigned.put(user, dsQuotaAssigned);
      cachedUserDsQuotaUsed.put(user, dsQuotaUsed);
      cachedUserDsQuotaRatios.put(user, dsQuotaRatio);
      nsQuotaThreshCountsUsers.put(user, nsQuotaRatio85);
      dsQuotaThreshCountsUsers.put(user, dsQuotaRatio85);
      nsQuotaCountsUsers.put(user, nsQuotaCount);
      dsQuotaCountsUsers.put(user, dsQuotaCount);
    }
  }
public void analyze ( NameNodeLoader loader , Collection < INode > dirs , Map < String , Long > dsQuotaCountsUsers , Map < String , Long > nsQuotaCountsUsers , Map < String , Long > dsQuotaThreshCountsUsers , Map < String , Long > nsQuotaThreshCountsUsers ) { /* If there is no namesystem (static testing), then exit. */ if ( loader . getCurrentTxId ( ) == - 1L ) { return ; } final QueryEngine queryEngine = loader . getQueryEngine ( ) ; final Map < String , Map < String , Set < INode > > > ownerDirContentSummary = queryEngine . combinedFilterToStream ( dirs , new String [ ] { "hasQuota" } , new String [ ] { "eq:true" } ) . collect ( Collectors . groupingBy ( INode :: getUserName , Collectors . groupingBy ( INode :: getFullPathName , Collectors . mapping ( Function . identity ( ) , Collectors . toSet ( ) ) ) ) ) ; cachedUserNsQuotaAssigned . clear ( ) ; cachedUserNsQuotaUsed . clear ( ) ; cachedUserNsQuotaRatios . clear ( ) ; cachedUserDsQuotaAssigned . clear ( ) ; cachedUserDsQuotaUsed . clear ( ) ; cachedUserDsQuotaRatios . clear ( ) ; for ( Entry < String , Map < String , Set < INode > > > entry : ownerDirContentSummary . entrySet ( ) ) { long nsQuotaRatio85 = 0 ; long dsQuotaRatio85 = 0 ; long nsQuotaCount = 0 ; long dsQuotaCount = 0 ; Map < String , Long > nsQuotaAssigned = new HashMap < > ( ) ; Map < String , Long > nsQuotaUsed = new HashMap < > ( ) ; Map < String , Long > nsQuotaRatio = new HashMap < > ( ) ; Map < String , Long > dsQuotaAssigned = new HashMap < > ( ) ; Map < String , Long > dsQuotaUsed = new HashMap < > ( ) ; Map < String , Long > dsQuotaRatio = new HashMap < > ( ) ; String user = entry . getKey ( ) ; for ( Entry < String , Set < INode > > innerEntry : entry . getValue ( ) . entrySet ( ) ) { INode value = innerEntry . getValue ( ) . iterator ( ) . next ( ) ; Long nsQuotaRatioLong = queryEngine . getSumFunctionForINode ( "nsQuotaRatioUsed" , null ) . apply ( value ) ; if ( nsQuotaRatioLong >= 0 ) { nsQuotaCount ++ ; if ( nsQuotaRatioLong >= 85 ) { nsQuotaRatio85 ++ ; } } else { nsQuotaRatioLong = - 1L ; } Long nsQuotaAssignedLong = queryEngine . getSumFunctionForINode ( "nsQuota" , null ) . apply ( value ) ; if ( nsQuotaAssignedLong <= - 1L ) { nsQuotaAssignedLong = - 1L ; } Long nsQuotaUsedLong = queryEngine . getSumFunctionForINode ( "nsQuotaUsed" , null ) . apply ( value ) ; if ( nsQuotaUsedLong <= - 1L ) { nsQuotaUsedLong = - 1L ; } Long dsQuotaRatioLong = queryEngine . getSumFunctionForINode ( "dsQuotaRatioUsed" , null ) . apply ( value ) ; if ( dsQuotaRatioLong >= 0 ) { dsQuotaCount ++ ; if ( dsQuotaRatioLong >= 85 ) { dsQuotaRatio85 ++ ; } } else { dsQuotaRatioLong = - 1L ; } Long dsQuotaAssignedLong = queryEngine . getSumFunctionForINode ( "dsQuota" , null ) . apply ( value ) ; if ( dsQuotaAssignedLong <= - 1L ) { dsQuotaAssignedLong = - 1L ; } Long dsQuotaUsedLong = queryEngine . getSumFunctionForINode ( "dsQuotaUsed" , null ) . apply ( value ) ; if ( dsQuotaUsedLong <= - 1L ) { dsQuotaUsedLong = - 1L ; } String path = innerEntry . getKey ( ) ; nsQuotaAssigned . put ( path , nsQuotaAssignedLong ) ; dsQuotaAssigned . put ( path , dsQuotaAssignedLong ) ; nsQuotaUsed . put ( path , nsQuotaUsedLong ) ; dsQuotaUsed . put ( path , dsQuotaUsedLong ) ; nsQuotaRatio . put ( path , nsQuotaRatioLong ) ; dsQuotaRatio . put ( path , dsQuotaRatioLong ) ; } cachedUserNsQuotaAssigned . put ( user , nsQuotaAssigned ) ; cachedUserNsQuotaUsed . put ( user , nsQuotaUsed ) ; cachedUserNsQuotaRatios . put ( user , nsQuotaRatio ) ; cachedUserDsQuotaAssigned . put ( user , dsQuotaAssigned ) ; cachedUserDsQuotaUsed . put ( user , dsQuotaUsed ) ; cachedUserDsQuotaRatios . put ( user , dsQuotaRatio ) ; nsQuotaThreshCountsUsers . put ( user , nsQuotaRatio85 ) ; dsQuotaThreshCountsUsers . put ( user , dsQuotaRatio85 ) ; nsQuotaCountsUsers . put ( user , nsQuotaCount ) ; dsQuotaCountsUsers . put ( user , dsQuotaCount ) ; } }
Main analysis call for compute all quotas and quota usage information.
Main analysis call for compute all quotas and quota usage information .