Class LightWeightResource
- All Implemented Interfaces:
Comparable<Resource>
LightWeightResource extends Resource to handle base resources such
as memory and CPU.
TODO: We have a long term plan to use AbstractResource when additional
resource types are to be handled as well.
This will be used to speed up internal calculation to avoid creating
costly PB-backed Resource object: ResourcePBImpl
Currently it models both memory and CPU.
The unit for memory is megabytes. CPU is modeled with virtual cores (vcores), a unit for expressing parallelism. A node's capacity should be configured with virtual cores equal to its number of physical cores. A container should be requested with the number of cores it can saturate, i.e. the average number of threads it expects to have runnable at a time.
Virtual cores take integer values and thus currently CPU-scheduling is very coarse. A complementary axis for CPU requests that represents processing power will likely be added in the future to enable finer-grained resource configuration.
- See Also:
-
Field Summary
Fields inherited from class org.apache.hadoop.yarn.api.records.Resource
MEMORY_INDEX, resources, VCORES_INDEX -
Constructor Summary
ConstructorsConstructorDescriptionLightWeightResource(long memory, int vcores) LightWeightResource(long memory, int vcores, ResourceInformation[] source) -
Method Summary
Modifier and TypeMethodDescriptionintbooleanintThis method is DEPRECATED: UseResource.getMemorySize()instead Get memory of the resource.longGet memory of the resource.intGet number of virtual cpu cores of the resource.inthashCode()voidsetMemory(int memory) Set memory of the resource.voidsetMemorySize(long memory) Set memory of the resource.voidsetVirtualCores(int vcores) Set number of virtual cpu cores of the resource.Methods inherited from class org.apache.hadoop.yarn.api.records.Resource
castToIntSafely, copy, getAllResourcesListCopy, getFormattedString, getFormattedString, getResourceInformation, getResourceInformation, getResources, getResourceValue, newDefaultInformation, newInstance, newInstance, newInstance, newInstance, setResourceInformation, setResourceInformation, setResources, setResourceValue, setResourceValue, throwExceptionWhenArrayOutOfBound, toFormattedString, toString
-
Constructor Details
-
LightWeightResource
public LightWeightResource(long memory, int vcores) -
LightWeightResource
-
-
Method Details
-
getMemory
public int getMemory()Description copied from class:ResourceThis method is DEPRECATED: UseResource.getMemorySize()instead Get memory of the resource. Note - while memory has never had a unit specified, all YARN configurations have specified memory in MB. The assumption has been that the daemons and applications are always using the same units. With the introduction of the ResourceInformation class we have support for units - so this function will continue to return memory but in the units of MB -
setMemory
public void setMemory(int memory) Description copied from class:ResourceSet memory of the resource. Note - while memory has never had a unit specified, all YARN configurations have specified memory in MB. The assumption has been that the daemons and applications are always using the same units. With the introduction of the ResourceInformation class we have support for units - so this function will continue to set memory but the assumption is that the value passed is in units of MB. -
getMemorySize
public long getMemorySize()Description copied from class:ResourceGet memory of the resource. Note - while memory has never had a unit specified, all YARN configurations have specified memory in MB. The assumption has been that the daemons and applications are always using the same units. With the introduction of the ResourceInformation class we have support for units - so this function will continue to return memory but in the units of MB- Overrides:
getMemorySizein classResource- Returns:
- memory of the resource
-
setMemorySize
public void setMemorySize(long memory) Description copied from class:ResourceSet memory of the resource.- Overrides:
setMemorySizein classResource- Parameters:
memory- memory of the resource
-
getVirtualCores
public int getVirtualCores()Description copied from class:ResourceGet number of virtual cpu cores of the resource. Virtual cores are a unit for expressing CPU parallelism. A node's capacity should be configured with virtual cores equal to its number of physical cores. A container should be requested with the number of cores it can saturate, i.e. the average number of threads it expects to have runnable at a time.- Specified by:
getVirtualCoresin classResource- Returns:
- num of virtual cpu cores of the resource
-
setVirtualCores
public void setVirtualCores(int vcores) Description copied from class:ResourceSet number of virtual cpu cores of the resource. Virtual cores are a unit for expressing CPU parallelism. A node's capacity should be configured with virtual cores equal to its number of physical cores. A container should be requested with the number of cores it can saturate, i.e. the average number of threads it expects to have runnable at a time.- Specified by:
setVirtualCoresin classResource- Parameters:
vcores- number of virtual cpu cores of the resource
-
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<Resource>- Overrides:
compareToin classResource
-
hashCode
public int hashCode()
-