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

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

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

ResourceRequest represents the request made by an application to the ResourceManager to obtain various Container allocations.

It includes:

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

Nested Class Summary
static class ResourceRequest.ResourceRequestComparator
           
 
Field Summary
static String ANY
          The constant string representing no locality.
 
Constructor Summary
ResourceRequest()
           
 
Method Summary
 int compareTo(ResourceRequest other)
           
 boolean equals(Object obj)
           
abstract  Resource getCapability()
          Get the Resource capability of the request.
abstract  int getNumContainers()
          Get the number of containers required with the given specifications.
abstract  Priority getPriority()
          Get the Priority of the request.
abstract  boolean getRelaxLocality()
          Get whether locality relaxation is enabled with this ResourceRequest.
abstract  String getResourceName()
          Get the resource (e.g.
 int hashCode()
           
static boolean isAnyLocation(String hostName)
          Check whether the given host/rack string represents an arbitrary host name.
static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers)
           
static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality)
           
abstract  void setCapability(Resource capability)
          Set the Resource capability of the request
abstract  void setNumContainers(int numContainers)
          Set the number of containers required with the given specifications
abstract  void setPriority(Priority priority)
          Set the Priority of the request
abstract  void setRelaxLocality(boolean relaxLocality)
          For a request at a network hierarchy level, set whether locality can be relaxed to that level and beyond.
abstract  void setResourceName(String resourceName)
          Set the resource name (e.g.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANY

public static final String ANY
The constant string representing no locality. It should be used by all references that want to pass an arbitrary host name in.

See Also:
Constant Field Values
Constructor Detail

ResourceRequest

public ResourceRequest()
Method Detail

newInstance

@InterfaceAudience.Public
@InterfaceStability.Stable
public static ResourceRequest newInstance(Priority priority,
                                                                                             String hostName,
                                                                                             Resource capability,
                                                                                             int numContainers)

newInstance

@InterfaceAudience.Public
@InterfaceStability.Stable
public static ResourceRequest newInstance(Priority priority,
                                                                                             String hostName,
                                                                                             Resource capability,
                                                                                             int numContainers,
                                                                                             boolean relaxLocality)

isAnyLocation

@InterfaceAudience.Public
@InterfaceStability.Stable
public static boolean isAnyLocation(String hostName)
Check whether the given host/rack string represents an arbitrary host name.

Parameters:
hostName - host/rack on which the allocation is desired
Returns:
whether the given host/rack string represents an arbitrary host name

getPriority

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract Priority getPriority()
Get the Priority of the request.

Returns:
Priority of the request

setPriority

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract void setPriority(Priority priority)
Set the Priority of the request

Parameters:
priority - Priority of the request

getResourceName

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract String getResourceName()
Get the resource (e.g. host/rack) on which the allocation is desired. A special value of * signifies that any resource (host/rack) is acceptable.

Returns:
resource (e.g. host/rack) on which the allocation is desired

setResourceName

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract void setResourceName(String resourceName)
Set the resource name (e.g. host/rack) on which the allocation is desired. A special value of * signifies that any resource name (e.g. host/rack) is acceptable.

Parameters:
resourceName - (e.g. host/rack) on which the allocation is desired

getCapability

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract Resource getCapability()
Get the Resource capability of the request.

Returns:
Resource capability of the request

setCapability

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract void setCapability(Resource capability)
Set the Resource capability of the request

Parameters:
capability - Resource capability of the request

getNumContainers

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract int getNumContainers()
Get the number of containers required with the given specifications.

Returns:
number of containers required with the given specifications

setNumContainers

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract void setNumContainers(int numContainers)
Set the number of containers required with the given specifications

Parameters:
numContainers - number of containers required with the given specifications

getRelaxLocality

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract boolean getRelaxLocality()
Get whether locality relaxation is enabled with this ResourceRequest. Defaults to true.

Returns:
whether locality relaxation is enabled with this ResourceRequest.

setRelaxLocality

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract void setRelaxLocality(boolean relaxLocality)

For a request at a network hierarchy level, set whether locality can be relaxed to that level and beyond.

If the flag is off on a rack-level ResourceRequest, containers at that request's priority will not be assigned to nodes on that request's rack unless requests specifically for those nodes have also been submitted.

If the flag is off on an ANY-level ResourceRequest, containers at that request's priority will only be assigned on racks for which specific requests have also been submitted.

For example, to request a container strictly on a specific node, the corresponding rack-level and any-level requests should have locality relaxation set to false. Similarly, to request a container strictly on a specific rack, the corresponding any-level request should have locality relaxation set to false.

Parameters:
relaxLocality - whether locality relaxation is enabled with this ResourceRequest.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

compareTo

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


Copyright © 2013 Apache Software Foundation. All Rights Reserved.