Class ResourceInformation
java.lang.Object
org.apache.hadoop.yarn.api.records.ResourceInformation
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final ResourceInformationstatic final Stringstatic final ResourceInformationstatic final ResourceInformationstatic final Stringstatic final Map<String,ResourceInformation> Special resources that should be treated separately from arbitrary resource types.static final ResourceInformationstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(ResourceInformation other) static voidcopy(ResourceInformation src, ResourceInformation dst) Copies the content of the source ResourceInformation object to the destination object, overwriting all properties of the destination object.booleanGet the attributes of the resource.longGet the maximum allocation for the resource.longGet the minimum allocation for the resource.getName()Get the name for the resource.Get the resource type.getTags()Get resource tags.getUnits()Get units for the resource.longgetValue()Get the value for the resource.inthashCode()static ResourceInformationnewInstance(String name) static ResourceInformationnewInstance(String name, long value) static ResourceInformationnewInstance(String name, String units) static ResourceInformationnewInstance(String name, String units, long value) static ResourceInformationnewInstance(String name, String units, long minRes, long maxRes) static ResourceInformationstatic ResourceInformationnewInstance(String name, String units, long value, ResourceTypes type, long minimumAllocation, long maximumAllocation) static ResourceInformationnewInstance(String name, String units, long value, ResourceTypes type, long minimumAllocation, long maximumAllocation, Set<String> tags, Map<String, String> attributes) static ResourceInformationnewInstance(String name, String units, ResourceTypes resourceType) static ResourceInformationnewInstance(ResourceInformation other) Create a new instance of ResourceInformation from another object.voidsetAttributes(Map<String, String> attributes) Set a map of attributes to the resource.voidsetMaximumAllocation(long maximumAllocation) Set the maximum allocation for the resource.voidsetMinimumAllocation(long minimumAllocation) Set the minimum allocation for the resource.voidSet the name for the resource.voidsetResourceType(ResourceTypes type) Set the resource type.voidAdd tags to the resource.voidSet the units for the resource.voidsetUnitsWithoutValidation(String rUnits) Checking if a unit included by KNOWN_UNITS is an expensive operation.voidsetValue(long rValue) Set the value for the resource.toString()
-
Field Details
-
MEMORY_URI
- See Also:
-
VCORES_URI
- See Also:
-
GPU_URI
- See Also:
-
FPGA_URI
- See Also:
-
MEMORY_MB
-
VCORES
-
GPUS
-
FPGAS
-
SPECIAL_RESOURCES
Special resources that should be treated separately from arbitrary resource types.
-
-
Constructor Details
-
ResourceInformation
public ResourceInformation()
-
-
Method Details
-
getName
Get the name for the resource.- Returns:
- resource name
-
setName
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
Get units for the resource.- Returns:
- units for the resource
-
setUnits
Set the units for the resource.- Parameters:
rUnits- units for the resource
-
setUnitsWithoutValidation
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
Get the resource type.- Returns:
- the resource type
-
setResourceType
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
Get the attributes of the resource.- Returns:
- resource attributes
-
setAttributes
Set a map of attributes to the resource.- Parameters:
attributes- resource attributes
-
getTags
Get resource tags.- Returns:
- resource tags
-
setTags
Add tags to the resource.- Parameters:
tags- resource tags
-
newInstance
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
-
newInstance
-
newInstance
-
newInstance
public static ResourceInformation newInstance(String name, String units, ResourceTypes resourceType) -
newInstance
-
newInstance
-
newInstance
-
copy
Copies the content of the source ResourceInformation object to the destination object, overwriting all properties of the destination object.- Parameters:
src- Source ResourceInformation objectdst- Destination ResourceInformation object
-
toString
-
getShorthandRepresentation
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<ResourceInformation>
-