java.lang.Object
org.apache.hadoop.hdfs.server.federation.router.Quota
Direct Known Subclasses:
AsyncQuota

public class Quota extends Object
Module that implements the quota relevant RPC calls ClientProtocol.setQuota(String, long, long, StorageType) and ClientProtocol.getQuotaUsage(String) in the RouterRpcServer.
  • Constructor Details

  • Method Details

    • setQuota

      public void setQuota(String path, long namespaceQuota, long storagespaceQuota, org.apache.hadoop.fs.StorageType type, boolean checkMountEntry) throws IOException
      Set quota for the federation path.
      Parameters:
      path - Federation path.
      namespaceQuota - Name space quota.
      storagespaceQuota - Storage space quota.
      type - StorageType that the space quota is intended to be set on.
      checkMountEntry - whether to check the path is a mount entry.
      Throws:
      IOException - If the quota system is disabled or if checkMountEntry is true and the path is a mount entry.
    • getQuotaUsage

      public org.apache.hadoop.fs.QuotaUsage getQuotaUsage(String path) throws IOException
      Get aggregated quota usage for the federation path.
      Parameters:
      path - Federation path.
      Returns:
      Aggregated quota.
      Throws:
      IOException - If the quota system is disabled.
    • getEachQuotaUsage

      protected Map<RemoteLocation,org.apache.hadoop.fs.QuotaUsage> getEachQuotaUsage(String path) throws IOException
      Get quota usage for the federation path.
      Parameters:
      path - Federation path.
      Returns:
      quota usage for each remote location.
      Throws:
      IOException - If the quota system is disabled.
    • getValidQuotaLocations

      protected List<RemoteLocation> getValidQuotaLocations(String path) throws IOException
      Get valid quota remote locations used in getQuotaUsage(String). Differentiate the method getQuotaRemoteLocations(String), this method will do some additional filtering.
      Parameters:
      path - Federation path.
      Returns:
      List of valid quota remote locations.
      Throws:
      IOException - If the location for this path cannot be determined.
    • aggregateQuota

      protected org.apache.hadoop.fs.QuotaUsage aggregateQuota(String path, Map<RemoteLocation,org.apache.hadoop.fs.QuotaUsage> results) throws IOException
      Aggregate quota that queried from sub-clusters.
      Parameters:
      path - Federation path of the results.
      results - Quota query result.
      Returns:
      Aggregated Quota.
      Throws:
      IOException - If the quota system is disabled.
    • eachByStorageType

      public static void eachByStorageType(Consumer<org.apache.hadoop.fs.StorageType> consumer)
      Invoke consumer by each storage type.
      Parameters:
      consumer - the function consuming the storage type.
    • orByStorageType

      public static boolean orByStorageType(Predicate<org.apache.hadoop.fs.StorageType> predicate)
      Invoke predicate by each storage type and bitwise inclusive OR the results.
      Parameters:
      predicate - the function test the storage type.
      Returns:
      true if bitwise OR by all storage type returns true, false otherwise.
    • andByStorageType

      public static boolean andByStorageType(Predicate<org.apache.hadoop.fs.StorageType> predicate)
      Invoke predicate by each storage type and bitwise AND the results.
      Parameters:
      predicate - the function test the storage type.
      Returns:
      true if bitwise AND by all storage type returns true, false otherwise.