Class ResourceInformation

java.lang.Object
org.apache.hadoop.yarn.api.records.ResourceInformation
All Implemented Interfaces:
Comparable<ResourceInformation>

public class ResourceInformation extends Object implements Comparable<ResourceInformation>
Class to encapsulate information about a Resource - the name of the resource, the units(milli, micro, etc), the type(countable), and the value.
  • Field Details

  • Constructor Details

    • ResourceInformation

      public ResourceInformation()
  • Method Details

    • getName

      public String getName()
      Get the name for the resource.
      Returns:
      resource name
    • setName

      public void setName(String rName)
      Set the name for the resource. A valid resource name must begin with a letter and contain only letters, numbers, and any of: '.', '_', or '-'. A valid resource name may also be optionally preceded by a name space followed by a slash. A valid name space consists of period-separated groups of letters, numbers, and dashes."
      Parameters:
      rName - name for the resource
    • getUnits

      public String getUnits()
      Get units for the resource.
      Returns:
      units for the resource
    • setUnits

      public void setUnits(String rUnits)
      Set the units for the resource.
      Parameters:
      rUnits - units for the resource
    • setUnitsWithoutValidation

      @Private public void setUnitsWithoutValidation(String rUnits)
      Checking if a unit included by KNOWN_UNITS is an expensive operation. This can be avoided in critical path in RM.
      Parameters:
      rUnits - units for the resource
    • getResourceType

      public ResourceTypes getResourceType()
      Get the resource type.
      Returns:
      the resource type
    • setResourceType

      public void setResourceType(ResourceTypes type)
      Set the resource type.
      Parameters:
      type - the resource type
    • getValue

      public long getValue()
      Get the value for the resource.
      Returns:
      the resource value
    • setValue

      public void setValue(long rValue)
      Set the value for the resource.
      Parameters:
      rValue - the resource value
    • getMinimumAllocation

      public long getMinimumAllocation()
      Get the minimum allocation for the resource.
      Returns:
      the minimum allocation for the resource
    • setMinimumAllocation

      public void setMinimumAllocation(long minimumAllocation)
      Set the minimum allocation for the resource.
      Parameters:
      minimumAllocation - the minimum allocation for the resource
    • getMaximumAllocation

      public long getMaximumAllocation()
      Get the maximum allocation for the resource.
      Returns:
      the maximum allocation for the resource
    • setMaximumAllocation

      public void setMaximumAllocation(long maximumAllocation)
      Set the maximum allocation for the resource.
      Parameters:
      maximumAllocation - the maximum allocation for the resource
    • getAttributes

      public Map<String,String> getAttributes()
      Get the attributes of the resource.
      Returns:
      resource attributes
    • setAttributes

      public void setAttributes(Map<String,String> attributes)
      Set a map of attributes to the resource.
      Parameters:
      attributes - resource attributes
    • getTags

      public Set<String> getTags()
      Get resource tags.
      Returns:
      resource tags
    • setTags

      public void setTags(Set<String> tags)
      Add tags to the resource.
      Parameters:
      tags - resource tags
    • newInstance

      public static ResourceInformation newInstance(ResourceInformation other)
      Create a new instance of ResourceInformation from another object.
      Parameters:
      other - the object from which the new object should be created
      Returns:
      the new ResourceInformation object
    • newInstance

      public static ResourceInformation newInstance(String name, String units, long value, ResourceTypes type, long minimumAllocation, long maximumAllocation)
    • newInstance

      public static ResourceInformation newInstance(String name, String units, long value, ResourceTypes type, long minimumAllocation, long maximumAllocation, Set<String> tags, Map<String,String> attributes)
    • newInstance

      public static ResourceInformation newInstance(String name, String units, long value)
    • newInstance

      public static ResourceInformation newInstance(String name, String units)
    • newInstance

      public static ResourceInformation newInstance(String name, String units, long value, Set<String> tags, Map<String,String> attributes)
    • newInstance

      public static ResourceInformation newInstance(String name, String units, ResourceTypes resourceType)
    • newInstance

      public static ResourceInformation newInstance(String name, String units, long minRes, long maxRes)
    • newInstance

      public static ResourceInformation newInstance(String name, long value)
    • newInstance

      public static ResourceInformation newInstance(String name)
    • copy

      public static void copy(ResourceInformation src, ResourceInformation dst)
      Copies the content of the source ResourceInformation object to the destination object, overwriting all properties of the destination object.
      Parameters:
      src - Source ResourceInformation object
      dst - Destination ResourceInformation object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getShorthandRepresentation

      public String getShorthandRepresentation()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(ResourceInformation other)
      Specified by:
      compareTo in interface Comparable<ResourceInformation>