Class ResourceRequest
- All Implemented Interfaces:
Comparable<ResourceRequest>
ResourceRequest represents the request made
by an application to the ResourceManager
to obtain various Container allocations.
It includes:
Priorityof the request.- The name of the host or rack on which the allocation is desired. A special value of * signifies that any host/rack is acceptable to the application.
Resourcerequired for each request.- Number of containers, of above specifications, which are required by the application.
-
A boolean relaxLocality flag, defaulting to
true, which tells theResourceManagerif 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).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classClass to construct instances ofResourceRequestwith specific options.static class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceRequestclone(ResourceRequest rr) Clone a ResourceRequest object (shallow copy).intcompareTo(ResourceRequest other) booleanlongGet the optional ID corresponding to this allocation request.abstract ResourceGet theResourcecapability of the request.Get whether locality relaxation is enabled with thisResourceRequest.abstract StringGet node-label-expression for this Resource Request.abstract intGet the number of containers required with the given specifications.abstract PriorityGet thePriorityof the request.abstract booleanGet whether locality relaxation is enabled with thisResourceRequest.abstract StringGet the resource (e.g.inthashCode()static booleanisAnyLocation(String hostName) Check whether the given host/rack string represents an arbitrary host name.static ResourceRequestnewInstance(Priority priority, String hostName, Resource capability, int numContainers) static ResourceRequestnewInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality) static ResourceRequestnewInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality, String labelExpression) static ResourceRequestnewInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality, String labelExpression, ExecutionTypeRequest executionTypeRequest) voidsetAllocationRequestId(long allocationRequestID) Set the optional ID corresponding to this allocation request.abstract voidsetCapability(Resource capability) Set theResourcecapability of the request.voidsetExecutionTypeRequest(ExecutionTypeRequest execSpec) Set theExecutionTypeRequestof the requested container.abstract voidsetNodeLabelExpression(String nodelabelExpression) Set node label expression of this resource request.abstract voidsetNumContainers(int numContainers) Set the number of containers required with the given specificationsabstract voidsetPriority(Priority priority) Set thePriorityof the requestabstract voidsetRelaxLocality(boolean relaxLocality) For a request at a network hierarchy level, set whether locality can be relaxed to that level and beyond.abstract voidsetResourceName(String resourceName) Set the resource name (e.g.
-
Field Details
-
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:
-
-
Constructor Details
-
ResourceRequest
public ResourceRequest()
-
-
Method Details
-
newInstance
@Public @Stable public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers) -
newInstance
@Public @Stable public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality) -
newInstance
@Public @Stable public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality, String labelExpression) -
newInstance
@Public @Evolving public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality, String labelExpression, ExecutionTypeRequest executionTypeRequest) -
clone
Clone a ResourceRequest object (shallow copy). Please keep it loaded with all (new) fields- Parameters:
rr- the object to copy from- Returns:
- the copied object
-
newBuilder
-
isAnyLocation
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
Get thePriorityof the request.- Returns:
Priorityof the request
-
setPriority
Set thePriorityof the request- Parameters:
priority-Priorityof the request
-
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
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
-
getNumContainers
@Public @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
@Public @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
@Public @Stable public abstract boolean getRelaxLocality()Get whether locality relaxation is enabled with thisResourceRequest. Defaults to true.- Returns:
- whether locality relaxation is enabled with this
ResourceRequest.
-
setExecutionTypeRequest
Set theExecutionTypeRequestof the requested container.- Parameters:
execSpec- ExecutionTypeRequest of the requested container
-
getExecutionTypeRequest
Get whether locality relaxation is enabled with thisResourceRequest. Defaults to true.- Returns:
- whether locality relaxation is enabled with this
ResourceRequest.
-
setRelaxLocality
@Public @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-levelResourceRequest, 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 thisResourceRequest.
-
getNodeLabelExpression
Get node-label-expression for this Resource Request. If this is set, all containers allocated to satisfy this resource-request will be only on those nodes that satisfy this node-label-expression. Please note that node label expression now can only take effect when the resource request has resourceName = ANY- Returns:
- node-label-expression
-
setNodeLabelExpression
Set node label expression of this resource request. Now only support specifying a single node label. In the future we will support more complex node label expression specification likeAND(&&), OR(||), etc. Any please note that node label expression now can only take effect when the resource request has resourceName = ANY- Parameters:
nodelabelExpression- node-label-expression of this ResourceRequest
-
getAllocationRequestId
@Public @Evolving public long getAllocationRequestId()Get the optional ID corresponding to this allocation request. This ID is an identifier for differentResourceRequests from the same application. The allocatedContainer(s) received as part of theAllocateResponseresponse will have the ID corresponding to the originalResourceRequestfor which the RM made the allocation.The scheduler may return multiple
AllocateResponses corresponding to the same ID as and when scheduler allocatesContainer(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
ResourceRequestcorresponding to a specific ID, they can simply cancel the correspondingResourceRequestand submit a new one afresh.- Returns:
- the ID corresponding to this allocation request.
-
setAllocationRequestId
@Public @Evolving public void setAllocationRequestId(long allocationRequestID) Set the optional ID corresponding to this allocation request. This ID is an identifier for differentResourceRequests from the same application. The allocatedContainer(s) received as part of theAllocateResponseresponse will have the ID corresponding to the originalResourceRequestfor which the RM made the allocation.The scheduler may return multiple
AllocateResponses corresponding to the same ID as and when scheduler allocatesContainer(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
ResourceRequestcorresponding to a specific ID, they can simply cancel the correspondingResourceRequestand 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.- Parameters:
allocationRequestID- the ID corresponding to this allocation request.
-
setCapability
Set theResourcecapability of the request.- Parameters:
capability-Resourcecapability of the request
-
getCapability
Get theResourcecapability of the request.- Returns:
Resourcecapability of the request
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<ResourceRequest>
-