Class AMRMClientAsyncImpl<T extends AMRMClient.ContainerRequest>
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.client.api.async.AMRMClientAsync<T>
org.apache.hadoop.yarn.client.api.async.impl.AMRMClientAsyncImpl<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service
@Private
@Unstable
public class AMRMClientAsyncImpl<T extends AMRMClient.ContainerRequest>
extends AMRMClientAsync<T>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.yarn.client.api.async.AMRMClientAsync
AMRMClientAsync.AbstractCallbackHandler, AMRMClientAsync.CallbackHandlerNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
Fields inherited from class org.apache.hadoop.yarn.client.api.async.AMRMClientAsync
client, handler, heartbeatIntervalMs -
Constructor Summary
ConstructorsConstructorDescriptionAMRMClientAsyncImpl(int intervalMs, AMRMClientAsync.AbstractCallbackHandler callbackHandler) AMRMClientAsyncImpl(int intervalMs, AMRMClientAsync.CallbackHandler callbackHandler) Deprecated.AMRMClientAsyncImpl(AMRMClient<T> client, int intervalMs, AMRMClientAsync.AbstractCallbackHandler callbackHandler) AMRMClientAsyncImpl(AMRMClient<T> client, int intervalMs, AMRMClientAsync.CallbackHandler callbackHandler) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContainerRequest(T req) Request containers for resources before callingallocatevoidaddSchedulingRequests(Collection<org.apache.hadoop.yarn.api.records.SchedulingRequest> schedulingRequests) Add a Collection of SchedulingRequests.org.apache.hadoop.yarn.api.records.ResourceGet the currently available resources in the cluster.intGet the current number of nodes in the cluster.List<? extends Collection<T>>getMatchingRequests(org.apache.hadoop.yarn.api.records.Priority priority, String resourceName, org.apache.hadoop.yarn.api.records.Resource capability) org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponseregisterApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl) Registers this application master with the resource manager.org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponseregisterApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl, Map<Set<String>, org.apache.hadoop.yarn.api.resource.PlacementConstraint> placementConstraintsMap) Registers this application master with the resource manager.voidreleaseAssignedContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Release containers assigned by the Resource Manager.voidremoveContainerRequest(T req) Remove previous container request.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 voidTells the heartbeat and handler threads to stop and waits for them to terminate.voidunregisterApplicationMaster(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.async.AMRMClientAsync
createAMRMClientAsync, createAMRMClientAsync, createAMRMClientAsync, createAMRMClientAsync, getMatchingRequests, getMatchingRequests, getRegisteredTimelineV2Client, registerTimelineV2Client, requestContainerResourceChange, setHeartbeatInterval, 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
-
Constructor Details
-
AMRMClientAsyncImpl
- Parameters:
intervalMs- heartbeat interval in milliseconds between AM and RMcallbackHandler- callback handler that processes responses from theResourceManager
-
AMRMClientAsyncImpl
public AMRMClientAsyncImpl(AMRMClient<T> client, int intervalMs, AMRMClientAsync.AbstractCallbackHandler callbackHandler) -
AMRMClientAsyncImpl
@Deprecated public AMRMClientAsyncImpl(int intervalMs, AMRMClientAsync.CallbackHandler callbackHandler) Deprecated. -
AMRMClientAsyncImpl
@Private @VisibleForTesting @Deprecated public AMRMClientAsyncImpl(AMRMClient<T> client, int intervalMs, AMRMClientAsync.CallbackHandler callbackHandler) Deprecated.
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
Tells the heartbeat and handler threads to stop and waits for them to terminate.- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
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) - Specified by:
getMatchingRequestsin classAMRMClientAsync<T extends AMRMClient.ContainerRequest>
-
addSchedulingRequests
public void addSchedulingRequests(Collection<org.apache.hadoop.yarn.api.records.SchedulingRequest> schedulingRequests) Description copied from class:AMRMClientAsyncAdd a Collection of SchedulingRequests. The AMRMClient will ensure that all requests in the same batch are sent in the same allocate call.- Overrides:
addSchedulingRequestsin classAMRMClientAsync<T extends AMRMClient.ContainerRequest>- Parameters:
schedulingRequests- Collection of Scheduling Requests.
-
registerApplicationMaster
public org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse registerApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException Registers this application master with the resource manager. On successful registration, starts the heartbeating thread.- Specified by:
registerApplicationMasterin classAMRMClientAsync<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:
- Register AM Response.
- 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, IOExceptionRegisters this application master with the resource manager. On successful registration, starts the heartbeating thread.- Overrides:
registerApplicationMasterin classAMRMClientAsync<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 Mapping.- Returns:
- Register AM Response.
- Throws:
org.apache.hadoop.yarn.exceptions.YarnExceptionIOException
-
unregisterApplicationMaster
public void unregisterApplicationMaster(org.apache.hadoop.yarn.api.records.FinalApplicationStatus appStatus, String appMessage, String appTrackingUrl) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException Unregister the application master. This must be called in the end.- Specified by:
unregisterApplicationMasterin classAMRMClientAsync<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
Request containers for resources before callingallocate- Specified by:
addContainerRequestin classAMRMClientAsync<T extends AMRMClient.ContainerRequest>- Parameters:
req- Resource request
-
removeContainerRequest
Remove 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 classAMRMClientAsync<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:AMRMClientAsyncRequest a container update before callingallocate. Any previous pending update request of the same container will be removed.- Specified by:
requestContainerUpdatein classAMRMClientAsync<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) Release 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 classAMRMClientAsync<T extends AMRMClient.ContainerRequest>- Parameters:
containerId-
-
getAvailableResources
public org.apache.hadoop.yarn.api.records.Resource getAvailableResources()Get the currently available resources in the cluster. A valid value is available after a call to allocate has been made- Specified by:
getAvailableResourcesin classAMRMClientAsync<T extends AMRMClient.ContainerRequest>- Returns:
- Currently available resources
-
getClusterNodeCount
public int getClusterNodeCount()Get the current number of nodes in the cluster. A valid values is available after a call to allocate has been made- Specified by:
getClusterNodeCountin classAMRMClientAsync<T extends AMRMClient.ContainerRequest>- Returns:
- Current number of nodes in the cluster
-
updateBlacklist
Update application's blacklist with addition or removal resources.- Specified by:
updateBlacklistin classAMRMClientAsync<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:AMRMClientAsyncUpdate application's tracking url on next heartbeat.- Overrides:
updateTrackingUrlin classAMRMClientAsync<T extends AMRMClient.ContainerRequest>- Parameters:
trackingUrl- new tracking url for this application
-
AMRMClientAsyncImpl(int, AMRMClientAsync.AbstractCallbackHandler)instead.