@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:
Priority
of the request.Resource
required for each request.true
,
which tells the ResourceManager
if the application wants
locality to be loose (i.e. allows fall-through to rack or any)
or strict (i.e. specify hard constraint on resource allocation).
Modifier and Type | Class and Description |
---|---|
static class |
ResourceRequest.ResourceRequestBuilder
Class to construct instances of
ResourceRequest with specific
options. |
static class |
ResourceRequest.ResourceRequestComparator |
Modifier and Type | Field and Description |
---|---|
static String |
ANY
The constant string representing no locality.
|
Constructor and Description |
---|
ResourceRequest() |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ResourceRequest other) |
boolean |
equals(Object obj) |
long |
getAllocationRequestId()
Get the optional ID corresponding to this allocation request.
|
abstract Resource |
getCapability()
Get the
Resource capability of the request. |
ExecutionTypeRequest |
getExecutionTypeRequest()
Get whether locality relaxation is enabled with this
ResourceRequest . |
abstract String |
getNodeLabelExpression()
Get node-label-expression for this Resource 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.ResourceRequestBuilder |
newBuilder() |
static ResourceRequest |
newInstance(Priority priority,
String hostName,
Resource capability,
int numContainers) |
static ResourceRequest |
newInstance(Priority priority,
String hostName,
Resource capability,
int numContainers,
boolean relaxLocality) |
static ResourceRequest |
newInstance(Priority priority,
String hostName,
Resource capability,
int numContainers,
boolean relaxLocality,
String labelExpression) |
static ResourceRequest |
newInstance(Priority priority,
String hostName,
Resource capability,
int numContainers,
boolean relaxLocality,
String labelExpression,
ExecutionTypeRequest executionTypeRequest) |
void |
setAllocationRequestId(long allocationRequestID)
Set the optional ID corresponding to this allocation request.
|
abstract void |
setCapability(Resource capability)
Set the
Resource capability of the request. |
void |
setExecutionTypeRequest(ExecutionTypeRequest execSpec)
Set the
ExecutionTypeRequest of the requested container. |
abstract void |
setNodeLabelExpression(String nodelabelExpression)
Set node label expression of this resource 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.
|
public static final String ANY
@InterfaceAudience.Public @InterfaceStability.Stable public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers)
@InterfaceAudience.Public @InterfaceStability.Stable public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality)
@InterfaceAudience.Public @InterfaceStability.Stable public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality, String labelExpression)
@InterfaceAudience.Public @InterfaceStability.Evolving public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality, String labelExpression, ExecutionTypeRequest executionTypeRequest)
@InterfaceAudience.Public @InterfaceStability.Unstable public static ResourceRequest.ResourceRequestBuilder newBuilder()
@InterfaceAudience.Public @InterfaceStability.Stable public static boolean isAnyLocation(String hostName)
hostName
- host/rack on which the allocation is desired@InterfaceAudience.Public @InterfaceStability.Stable public abstract Priority getPriority()
Priority
of the request.Priority
of the request@InterfaceAudience.Public @InterfaceStability.Stable public abstract void setPriority(Priority priority)
Priority
of the requestpriority
- Priority
of the request@InterfaceAudience.Public @InterfaceStability.Stable public abstract String getResourceName()
@InterfaceAudience.Public @InterfaceStability.Stable public abstract void setResourceName(String resourceName)
resourceName
- (e.g. host/rack) on which the
allocation is desired@InterfaceAudience.Public @InterfaceStability.Stable public abstract int getNumContainers()
@InterfaceAudience.Public @InterfaceStability.Stable public abstract void setNumContainers(int numContainers)
numContainers
- number of containers required with the given
specifications@InterfaceAudience.Public @InterfaceStability.Stable public abstract boolean getRelaxLocality()
ResourceRequest
. Defaults to true.ResourceRequest
.@InterfaceAudience.Public @InterfaceStability.Evolving public void setExecutionTypeRequest(ExecutionTypeRequest execSpec)
ExecutionTypeRequest
of the requested container.execSpec
- ExecutionTypeRequest of the requested container@InterfaceAudience.Public @InterfaceStability.Evolving public ExecutionTypeRequest getExecutionTypeRequest()
ResourceRequest
. Defaults to true.ResourceRequest
.@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.
relaxLocality
- whether locality relaxation is enabled with this
ResourceRequest
.@InterfaceAudience.Public @InterfaceStability.Evolving public abstract String getNodeLabelExpression()
@InterfaceAudience.Public @InterfaceStability.Evolving public abstract void setNodeLabelExpression(String nodelabelExpression)
AND(&&), OR(||)
, etc.
Any please note that node label expression now can only take effect when
the resource request has resourceName = ANYnodelabelExpression
- node-label-expression of this ResourceRequest@InterfaceAudience.Public @InterfaceStability.Evolving public long getAllocationRequestId()
ResourceRequest
s from the same
application. The allocated Container
(s) received as part of the
AllocateResponse
response will have the ID corresponding to the
original ResourceRequest
for which the RM made the allocation.
The scheduler may return multiple AllocateResponse
s corresponding
to the same ID as and when scheduler allocates Container
(s).
Applications can continue to completely ignore the returned ID in
the response and use the allocation for any of their outstanding requests.
If one wishes to replace an entire ResourceRequest
corresponding to
a specific ID, they can simply cancel the corresponding ResourceRequest
and submit a new one afresh.
@InterfaceAudience.Public @InterfaceStability.Evolving public void setAllocationRequestId(long allocationRequestID)
ResourceRequest
s from the same
application. The allocated Container
(s) received as part of the
AllocateResponse
response will have the ID corresponding to the
original ResourceRequest
for which the RM made the allocation.
The scheduler may return multiple AllocateResponse
s corresponding
to the same ID as and when scheduler allocates Container
(s).
Applications can continue to completely ignore the returned ID in
the response and use the allocation for any of their outstanding requests.
If one wishes to replace an entire ResourceRequest
corresponding to
a specific ID, they can simply cancel the corresponding ResourceRequest
and submit a new one afresh.
If the ID is not set, scheduler will continue to work as previously and all
allocated Container
(s) will have the default ID, -1.
allocationRequestID
- the ID corresponding to this allocation
request.@InterfaceAudience.Public @InterfaceStability.Stable public abstract void setCapability(Resource capability)
Resource
capability of the request.capability
- Resource
capability of the request@InterfaceAudience.Public @InterfaceStability.Stable public abstract Resource getCapability()
Resource
capability of the request.Resource
capability of the requestpublic int compareTo(ResourceRequest other)
compareTo
in interface Comparable<ResourceRequest>
Copyright © 2018 Apache Software Foundation. All rights reserved.