org.apache.hadoop.yarn.api.records
Class Resource

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

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract class Resource
extends Object
implements Comparable<Resource>

Resource models a set of computer resources in the cluster.

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.

Typically, applications request Resource of suitable capability to run their component tasks.

See Also:
ResourceRequest, ApplicationMasterProtocol.allocate(org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest)

Constructor Summary
Resource()
           
 
Method Summary
 boolean equals(Object obj)
           
abstract  int getMemory()
          Get memory of the resource.
abstract  int getVirtualCores()
          Get number of virtual cpu cores of the resource.
 int hashCode()
           
static Resource newInstance(int memory, int vCores)
           
abstract  void setMemory(int memory)
          Set memory of the resource.
abstract  void setVirtualCores(int vCores)
          Set number of virtual cpu cores of the resource.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

Resource

public Resource()
Method Detail

newInstance

@InterfaceAudience.Public
@InterfaceStability.Stable
public static Resource newInstance(int memory,
                                                                                      int vCores)

getMemory

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract int getMemory()
Get memory of the resource.

Returns:
memory of the resource

setMemory

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract void setMemory(int memory)
Set memory of the resource.

Parameters:
memory - memory of the resource

getVirtualCores

@InterfaceAudience.Public
@InterfaceStability.Evolving
public abstract int getVirtualCores()
Get 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.

Returns:
num of virtual cpu cores of the resource

setVirtualCores

@InterfaceAudience.Public
@InterfaceStability.Evolving
public abstract void setVirtualCores(int vCores)
Set 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.

Parameters:
vCores - number of virtual cpu cores of the resource

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 Apache Software Foundation. All Rights Reserved.