@InterfaceAudience.Private @InterfaceStability.Unstable public class LightWeightResource extends 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.
Resource
MEMORY_INDEX, resources, VCORES_INDEX
Constructor and Description |
---|
LightWeightResource(long memory,
int vcores) |
LightWeightResource(long memory,
int vcores,
ResourceInformation[] source) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Resource other) |
boolean |
equals(Object obj) |
int |
getMemory()
This method is DEPRECATED:
Use
Resource.getMemorySize() instead
Get memory of the resource. |
long |
getMemorySize()
Get memory of the resource.
|
int |
getVirtualCores()
Get number of virtual cpu cores of the resource.
|
int |
hashCode() |
void |
setMemory(int memory)
Set memory of the resource.
|
void |
setMemorySize(long memory)
Set memory of the resource.
|
void |
setVirtualCores(int vcores)
Set number of virtual cpu cores of the resource.
|
castToIntSafely, copy, getAllResourcesListCopy, getFormattedString, getFormattedString, getResourceInformation, getResourceInformation, getResources, getResourceValue, newDefaultInformation, newInstance, newInstance, newInstance, newInstance, setResourceInformation, setResourceInformation, setResources, setResourceValue, setResourceValue, throwExceptionWhenArrayOutOfBound, toFormattedString, toString
public LightWeightResource(long memory, int vcores)
public LightWeightResource(long memory, int vcores, ResourceInformation[] source)
public int getMemory()
Resource
Resource.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 MBpublic void setMemory(int memory)
Resource
public long getMemorySize()
Resource
getMemorySize
in class Resource
public void setMemorySize(long memory)
Resource
setMemorySize
in class Resource
memory
- memory of the resourcepublic int getVirtualCores()
Resource
getVirtualCores
in class Resource
public void setVirtualCores(int vcores)
Resource
setVirtualCores
in class Resource
vcores
- number of virtual cpu cores of the resourcepublic int compareTo(Resource other)
compareTo
in interface Comparable<Resource>
compareTo
in class Resource
Copyright © 2008–2024 Apache Software Foundation. All rights reserved.