Class AMRMClientImpl<T extends AMRMClient.ContainerRequest>
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.client.api.AMRMClient<T>
org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service
@Private
@Unstable
public class AMRMClientImpl<T extends AMRMClient.ContainerRequest>
extends AMRMClient<T>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.yarn.client.api.AMRMClient
AMRMClient.ContainerRequestNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected intprotected Stringprotected final Set<org.apache.hadoop.yarn.api.records.ResourceRequest>protected final Map<org.apache.hadoop.yarn.api.records.ContainerId,AbstractMap.SimpleEntry<org.apache.hadoop.yarn.api.records.Container, org.apache.hadoop.yarn.api.records.UpdateContainerRequest>> protected org.apache.hadoop.yarn.api.records.Resourceprotected intprotected Stringprotected final Map<org.apache.hadoop.yarn.api.records.ContainerId,AbstractMap.SimpleEntry<org.apache.hadoop.yarn.api.records.Container, org.apache.hadoop.yarn.api.records.UpdateContainerRequest>> protected Set<org.apache.hadoop.yarn.api.records.ContainerId>protected final Set<org.apache.hadoop.yarn.api.records.ContainerId>protected org.apache.hadoop.yarn.api.ApplicationMasterProtocol -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContainerRequest(T req) Request containers for resources before callingallocatevoidaddSchedulingRequests(Collection<org.apache.hadoop.yarn.api.records.SchedulingRequest> newSchedulingRequests) Add a Collection of SchedulingRequests.org.apache.hadoop.yarn.api.protocolrecords.AllocateResponseallocate(float progressIndicator) Request additional containers and receive new container allocations.org.apache.hadoop.yarn.api.records.ResourceGet the currently available resources in the cluster.intGet the current number of nodes in the cluster.getMatchingRequests(long allocationRequestId) Get outstandingContainerRequests matching the given allocationRequestId.List<? extends Collection<T>>getMatchingRequests(org.apache.hadoop.yarn.api.records.Priority priority, String resourceName, org.apache.hadoop.yarn.api.records.ExecutionType executionType, org.apache.hadoop.yarn.api.records.Resource capability) Get outstandingContainerRequests matching the given parameters.List<? extends Collection<T>>getMatchingRequests(org.apache.hadoop.yarn.api.records.Priority priority, String resourceName, org.apache.hadoop.yarn.api.records.ExecutionType executionType, org.apache.hadoop.yarn.api.records.Resource capability, String profile) List<? extends Collection<T>>getMatchingRequests(org.apache.hadoop.yarn.api.records.Priority priority, String resourceName, org.apache.hadoop.yarn.api.records.Resource capability) Get outstandingContainerRequests matching the given parameters.protected voidpopulateNMTokens(List<org.apache.hadoop.yarn.api.records.NMToken> nmTokens) org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponseregisterApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl) Register the application master.org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponseregisterApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl, Map<Set<String>, org.apache.hadoop.yarn.api.resource.PlacementConstraint> placementConstraintsMap) Register the application master.voidreleaseAssignedContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Release containers assigned by the Resource Manager.voidremoveContainerRequest(T req) Remove previous container request.protected voidremovePendingChangeRequests(List<org.apache.hadoop.yarn.api.records.UpdatedContainer> changedContainers) protected voidremovePendingReleaseRequests(List<org.apache.hadoop.yarn.api.records.ContainerStatus> completedContainersStatuses) voidrequestContainerUpdate(org.apache.hadoop.yarn.api.records.Container container, org.apache.hadoop.yarn.api.records.UpdateContainerRequest updateContainerRequest) Request a container update before callingallocate.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) protected voidprotected voidvoidunregisterApplicationMaster(org.apache.hadoop.yarn.api.records.FinalApplicationStatus appStatus, String appMessage, String appTrackingUrl) Unregister the application master.voidupdateBlacklist(List<String> blacklistAdditions, List<String> blacklistRemovals) Update application's blacklist with addition or removal resources.voidupdateTrackingUrl(String trackingUrl) Update application's tracking url on next heartbeat.Methods inherited from class org.apache.hadoop.yarn.client.api.AMRMClient
createAMRMClient, getNMTokenCache, getRegisteredTimelineV2Client, registerTimelineV2Client, requestContainerResourceChange, setNMTokenCache, waitFor, waitFor, waitForMethods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Field Details
-
appHostName
-
appHostPort
protected int appHostPort -
appTrackingUrl
-
newTrackingUrl
-
rmClient
protected org.apache.hadoop.yarn.api.ApplicationMasterProtocol rmClient -
clusterAvailableResources
protected org.apache.hadoop.yarn.api.records.Resource clusterAvailableResources -
clusterNodeCount
protected int clusterNodeCount -
blacklistedNodes
-
blacklistAdditions
-
blacklistRemovals
-
resourceProfilesMap
-
ask
-
release
-
pendingRelease
-
change
protected final Map<org.apache.hadoop.yarn.api.records.ContainerId,AbstractMap.SimpleEntry<org.apache.hadoop.yarn.api.records.Container, changeorg.apache.hadoop.yarn.api.records.UpdateContainerRequest>> -
pendingChange
protected final Map<org.apache.hadoop.yarn.api.records.ContainerId,AbstractMap.SimpleEntry<org.apache.hadoop.yarn.api.records.Container, pendingChangeorg.apache.hadoop.yarn.api.records.UpdateContainerRequest>>
-
-
Constructor Details
-
AMRMClientImpl
public AMRMClientImpl()
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
registerApplicationMaster
public org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse registerApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException Description copied from class:AMRMClientRegister the application master. This must be called before any other interaction- Specified by:
registerApplicationMasterin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
appHostName- Name of the host on which master is runningappHostPort- Port master is listening onappTrackingUrl- URL at which the master info can be seen- Returns:
RegisterApplicationMasterResponse- Throws:
org.apache.hadoop.yarn.exceptions.YarnExceptionIOException
-
registerApplicationMaster
public org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse registerApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl, Map<Set<String>, org.apache.hadoop.yarn.api.resource.PlacementConstraint> placementConstraintsMap) throws org.apache.hadoop.yarn.exceptions.YarnException, IOExceptionDescription copied from class:AMRMClientRegister the application master. This must be called before any other interaction- Overrides:
registerApplicationMasterin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
appHostName- Name of the host on which master is runningappHostPort- Port master is listening onappTrackingUrl- URL at which the master info can be seenplacementConstraintsMap- Placement Constraints mappings.- Returns:
RegisterApplicationMasterResponse- Throws:
org.apache.hadoop.yarn.exceptions.YarnExceptionIOException
-
addSchedulingRequests
public void addSchedulingRequests(Collection<org.apache.hadoop.yarn.api.records.SchedulingRequest> newSchedulingRequests) Description copied from class:AMRMClientAdd a Collection of SchedulingRequests. The AMRMClient will ensure that all requests in the same batch are sent in the same allocate call.- Overrides:
addSchedulingRequestsin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
newSchedulingRequests- Collection of Scheduling Requests.
-
allocate
public org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse allocate(float progressIndicator) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException Description copied from class:AMRMClientRequest additional containers and receive new container allocations. Requests made viaaddContainerRequestare sent to theResourceManager. New containers assigned to the master are retrieved. Status of completed containers and node health updates are also retrieved. This also doubles up as a heartbeat to the ResourceManager and must be made periodically. The call may not always return any new allocations of containers. App should not make concurrent allocate requests. May cause request loss.Note : If the user has not removed container requests that have already been satisfied, then the re-register may end up sending the entire container requests to the RM (including matched requests). Which would mean the RM could end up giving it a lot of new allocated containers.
- Specified by:
allocatein classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
progressIndicator- Indicates progress made by the master- Returns:
- the response of the allocate request
- Throws:
org.apache.hadoop.yarn.exceptions.YarnExceptionIOException
-
removePendingReleaseRequests
protected void removePendingReleaseRequests(List<org.apache.hadoop.yarn.api.records.ContainerStatus> completedContainersStatuses) -
removePendingChangeRequests
protected void removePendingChangeRequests(List<org.apache.hadoop.yarn.api.records.UpdatedContainer> changedContainers) -
populateNMTokens
@Private @VisibleForTesting protected void populateNMTokens(List<org.apache.hadoop.yarn.api.records.NMToken> nmTokens) -
unregisterApplicationMaster
public void unregisterApplicationMaster(org.apache.hadoop.yarn.api.records.FinalApplicationStatus appStatus, String appMessage, String appTrackingUrl) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException Description copied from class:AMRMClientUnregister the application master. This must be called in the end.- Specified by:
unregisterApplicationMasterin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
appStatus- Success/Failure status of the masterappMessage- Diagnostics message on failureappTrackingUrl- New URL to get master info- Throws:
org.apache.hadoop.yarn.exceptions.YarnExceptionIOException
-
addContainerRequest
Description copied from class:AMRMClientRequest containers for resources before callingallocate- Specified by:
addContainerRequestin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
req- Resource request
-
removeContainerRequest
Description copied from class:AMRMClientRemove previous container request. The previous container request may have already been sent to the ResourceManager. So even after the remove request the app must be prepared to receive an allocation for the previous request even after the remove request- Specified by:
removeContainerRequestin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
req- Resource request
-
requestContainerUpdate
public void requestContainerUpdate(org.apache.hadoop.yarn.api.records.Container container, org.apache.hadoop.yarn.api.records.UpdateContainerRequest updateContainerRequest) Description copied from class:AMRMClientRequest a container update before callingallocate. Any previous pending update request of the same container will be removed.- Specified by:
requestContainerUpdatein classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
container- The container returned from the last successful resource allocation or updateupdateContainerRequest- TheUpdateContainerRequest.
-
releaseAssignedContainer
public void releaseAssignedContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Description copied from class:AMRMClientRelease containers assigned by the Resource Manager. If the app cannot use the container or wants to give up the container then it can release them. The app needs to make new requests for the released resource capability if it still needs it. eg. it released non-local resources- Specified by:
releaseAssignedContainerin classAMRMClient<T extends AMRMClient.ContainerRequest>
-
getAvailableResources
public org.apache.hadoop.yarn.api.records.Resource getAvailableResources()Description copied from class:AMRMClientGet the currently available resources in the cluster. A valid value is available after a call to allocate has been made- Specified by:
getAvailableResourcesin classAMRMClient<T extends AMRMClient.ContainerRequest>- Returns:
- Currently available resources
-
getClusterNodeCount
public int getClusterNodeCount()Description copied from class:AMRMClientGet the current number of nodes in the cluster. A valid values is available after a call to allocate has been made- Specified by:
getClusterNodeCountin classAMRMClient<T extends AMRMClient.ContainerRequest>- Returns:
- Current number of nodes in the cluster
-
getMatchingRequests
Description copied from class:AMRMClientGet outstandingContainerRequests matching the given allocationRequestId. These ContainerRequests should have been added viaaddContainerRequestearlier in the lifecycle. For performance, the AMRMClient may return its internal collection directly without creating a copy. Users should not perform mutable operations on the return value. NOTE: This API only matches Container requests that were created by the client WITH the allocationRequestId being set to a non-default value.- Specified by:
getMatchingRequestsin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
allocationRequestId- Allocation Request Id- Returns:
- Collection of request matching the parameters
-
getMatchingRequests
public List<? extends Collection<T>> getMatchingRequests(org.apache.hadoop.yarn.api.records.Priority priority, String resourceName, org.apache.hadoop.yarn.api.records.Resource capability) Description copied from class:AMRMClientGet outstandingContainerRequests matching the given parameters. These ContainerRequests should have been added viaaddContainerRequestearlier in the lifecycle. For performance, the AMRMClient may return its internal collection directly without creating a copy. Users should not perform mutable operations on the return value. Each collection in the list contains requests with identicalResourcesize that fit in the given capability. In a collection, requests will be returned in the same order as they were added. NOTE: This API only matches Container requests that were created by the client WITHOUT the allocationRequestId being set.- Specified by:
getMatchingRequestsin classAMRMClient<T extends AMRMClient.ContainerRequest>- Returns:
- Collection of request matching the parameters
-
getMatchingRequests
public List<? extends Collection<T>> getMatchingRequests(org.apache.hadoop.yarn.api.records.Priority priority, String resourceName, org.apache.hadoop.yarn.api.records.ExecutionType executionType, org.apache.hadoop.yarn.api.records.Resource capability, String profile) - Overrides:
getMatchingRequestsin classAMRMClient<T extends AMRMClient.ContainerRequest>
-
getMatchingRequests
public List<? extends Collection<T>> getMatchingRequests(org.apache.hadoop.yarn.api.records.Priority priority, String resourceName, org.apache.hadoop.yarn.api.records.ExecutionType executionType, org.apache.hadoop.yarn.api.records.Resource capability) Description copied from class:AMRMClientGet outstandingContainerRequests matching the given parameters. These ContainerRequests should have been added viaaddContainerRequestearlier in the lifecycle. For performance, the AMRMClient may return its internal collection directly without creating a copy. Users should not perform mutable operations on the return value. Each collection in the list contains requests with identicalResourcesize that fit in the given capability. In a collection, requests will be returned in the same order as they were added. specify anExecutionType. NOTE: This API only matches Container requests that were created by the client WITHOUT the allocationRequestId being set.- Overrides:
getMatchingRequestsin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
priority- PriorityresourceName- LocationexecutionType- ExecutionTypecapability- Capability- Returns:
- Collection of request matching the parameters
-
updateBlacklist
Description copied from class:AMRMClientUpdate application's blacklist with addition or removal resources.- Specified by:
updateBlacklistin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
blacklistAdditions- list of resources which should be added to the application blacklistblacklistRemovals- list of resources which should be removed from the application blacklist
-
updateTrackingUrl
Description copied from class:AMRMClientUpdate application's tracking url on next heartbeat.- Overrides:
updateTrackingUrlin classAMRMClient<T extends AMRMClient.ContainerRequest>- Parameters:
trackingUrl- new tracking url for this application
-