java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.UsersManager
All Implemented Interfaces:
AbstractUsersManager

@Private public class UsersManager extends Object implements AbstractUsersManager
UsersManager tracks users in the system and its respective data structures.
  • Constructor Details

    • UsersManager

      public UsersManager(QueueMetrics metrics, AbstractLeafQueue lQueue, RMNodeLabelsManager labelManager, org.apache.hadoop.yarn.util.resource.ResourceCalculator resourceCalculator)
      UsersManager Constructor.
      Parameters:
      metrics - Queue Metrics
      lQueue - Leaf Queue Object
      labelManager - Label Manager instance
      resourceCalculator - rc
  • Method Details

    • getUserLimit

      public float getUserLimit()
      Get configured user-limit.
      Returns:
      user limit
    • setUserLimit

      public void setUserLimit(float userLimit)
      Set configured user-limit.
      Parameters:
      userLimit - user limit
    • getUserLimitFactor

      public float getUserLimitFactor()
      Get configured user-limit factor.
      Returns:
      user-limit factor
    • setUserLimitFactor

      public void setUserLimitFactor(float userLimitFactor)
      Set configured user-limit factor.
      Parameters:
      userLimitFactor - User Limit factor.
    • getUsageRatio

      @VisibleForTesting public float getUsageRatio(String label)
    • userLimitNeedsRecompute

      public void userLimitNeedsRecompute()
      Force UsersManager to recompute userlimit.
    • getUsers

      public Map<String,UsersManager.User> getUsers()
    • getUser

      public UsersManager.User getUser(String userName)
      Get user object for given user name.
      Parameters:
      userName - User Name
      Returns:
      User object
    • removeUser

      public void removeUser(String userName)
      Remove user.
      Parameters:
      userName - User Name
    • getUserAndAddIfAbsent

      public UsersManager.User getUserAndAddIfAbsent(String userName)
      Get and add user if absent.
      Parameters:
      userName - User Name
      Returns:
      User object
    • getUsersInfo

      public ArrayList<UserInfo> getUsersInfo()
      Returns:
      an ArrayList of UserInfo objects who are active in this queue
    • getComputedResourceLimitForActiveUsers

      public org.apache.hadoop.yarn.api.records.Resource getComputedResourceLimitForActiveUsers(String userName, org.apache.hadoop.yarn.api.records.Resource clusterResource, String nodePartition, SchedulingMode schedulingMode)
      Get computed user-limit for all ACTIVE users in this queue. If cached data is invalidated due to resource change, this method also enforce to recompute user-limit.
      Parameters:
      userName - Name of user who has submitted one/more app to given queue.
      clusterResource - total cluster resource
      nodePartition - partition name
      schedulingMode - scheduling mode RESPECT_PARTITION_EXCLUSIVITY/IGNORE_PARTITION_EXCLUSIVITY
      Returns:
      Computed User Limit
    • getComputedResourceLimitForAllUsers

      public org.apache.hadoop.yarn.api.records.Resource getComputedResourceLimitForAllUsers(String userName, org.apache.hadoop.yarn.api.records.Resource clusterResource, String nodePartition, SchedulingMode schedulingMode)
      Get computed user-limit for all users in this queue. If cached data is invalidated due to resource change, this method also enforce to recompute user-limit.
      Parameters:
      userName - Name of user who has submitted one/more app to given queue.
      clusterResource - total cluster resource
      nodePartition - partition name
      schedulingMode - scheduling mode RESPECT_PARTITION_EXCLUSIVITY/IGNORE_PARTITION_EXCLUSIVITY
      Returns:
      Computed User Limit
    • getLatestVersionOfUsersState

      protected long getLatestVersionOfUsersState()
    • updateUsageRatio

      public void updateUsageRatio(String partition, org.apache.hadoop.yarn.api.records.Resource clusterResource)
      Update new usage ratio.
      Parameters:
      partition - Node partition
      clusterResource - cluster resource
    • activateApplication

      public void activateApplication(String user, org.apache.hadoop.yarn.api.records.ApplicationId applicationId)
      Description copied from interface: AbstractUsersManager
      An application has new outstanding requests.
      Specified by:
      activateApplication in interface AbstractUsersManager
      Parameters:
      user - application user
      applicationId - activated application
    • deactivateApplication

      public void deactivateApplication(String user, org.apache.hadoop.yarn.api.records.ApplicationId applicationId)
      Description copied from interface: AbstractUsersManager
      An application has no more outstanding requests.
      Specified by:
      deactivateApplication in interface AbstractUsersManager
      Parameters:
      user - application user
      applicationId - deactivated application
    • getNumActiveUsers

      public int getNumActiveUsers()
      Description copied from interface: AbstractUsersManager
      Get number of active users i.e. users with applications which have pending resource requests.
      Specified by:
      getNumActiveUsers in interface AbstractUsersManager
      Returns:
      number of active users
    • updateUserResourceUsage

      public UsersManager.User updateUserResourceUsage(String userName, org.apache.hadoop.yarn.api.records.Resource resource, org.apache.hadoop.yarn.api.records.Resource clusterResource, String nodePartition, boolean isAllocate)
      During container allocate/release, ensure that all user specific data structures are updated.
      Parameters:
      userName - Name of the user
      resource - Resource to increment/decrement
      clusterResource - Cluster resource (for testing purposes only)
      nodePartition - Node label
      isAllocate - Indicate whether to allocate or release resource
      Returns:
      user
    • updateUserWeights

      public void updateUserWeights()
    • getNumActiveUsersWithOnlyPendingApps

      @VisibleForTesting public int getNumActiveUsersWithOnlyPendingApps()