@InterfaceAudience.Private @InterfaceStability.Unstable public class AMRMClientImpl<T extends AMRMClient.ContainerRequest> extends AMRMClient<T>
AMRMClient.ContainerRequest
Service.STATE
Modifier and Type | Field and Description |
---|---|
protected Set<ResourceRequest> |
ask |
protected Set<String> |
blacklistAdditions |
protected Set<String> |
blacklistRemovals |
protected Resource |
clusterAvailableResources |
protected int |
clusterNodeCount |
protected Set<ContainerId> |
release |
protected Map<Priority,Map<String,TreeMap<Resource,org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo>>> |
remoteRequestsTable |
protected ApplicationMasterProtocol |
rmClient |
Constructor and Description |
---|
AMRMClientImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addContainerRequest(T req)
Request containers for resources before calling
allocate |
AllocateResponse |
allocate(float progressIndicator)
Request additional containers and receive new container allocations.
|
Resource |
getAvailableResources()
Get the currently available resources in the cluster.
|
int |
getClusterNodeCount()
Get the current number of nodes in the cluster.
|
List<? extends Collection<T>> |
getMatchingRequests(Priority priority,
String resourceName,
Resource capability)
Get outstanding
ContainerRequest s matching the given
parameters. |
protected void |
populateNMTokens(AllocateResponse allocateResponse) |
RegisterApplicationMasterResponse |
registerApplicationMaster(String appHostName,
int appHostPort,
String appTrackingUrl)
Register the application master.
|
void |
releaseAssignedContainer(ContainerId containerId)
Release containers assigned by the Resource Manager.
|
void |
removeContainerRequest(T req)
Remove previous container request.
|
protected void |
serviceInit(Configuration conf)
All initialization code needed by a service.
|
protected void |
serviceStart()
Actions called during the INITED to STARTED transition.
|
protected void |
serviceStop()
Actions called during the transition to the STOPPED state.
|
void |
unregisterApplicationMaster(FinalApplicationStatus appStatus,
String appMessage,
String appTrackingUrl)
Unregister the application master.
|
void |
updateBlacklist(List<String> blacklistAdditions,
List<String> blacklistRemovals)
Update application's blacklist with addition or removal resources.
|
createAMRMClient
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
protected ApplicationMasterProtocol rmClient
protected Resource clusterAvailableResources
protected int clusterNodeCount
protected final Map<Priority,Map<String,TreeMap<Resource,org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo>>> remoteRequestsTable
protected final Set<ResourceRequest> ask
protected final Set<ContainerId> release
protected void serviceInit(Configuration conf) throws Exception
AbstractService
AbstractService.init(Configuration)
prevents re-entrancy.
The base implementation checks to see if the subclass has created
a new configuration instance, and if so, updates the base class valueserviceInit
in class AbstractService
conf
- configurationException
- on a failure -these will be caught,
possibly wrapped, and wil; trigger a service stopprotected void serviceStart() throws Exception
AbstractService
AbstractService.start()
prevents re-entrancy.serviceStart
in class AbstractService
Exception
- if needed -these will be caught,
wrapped, and trigger a service stopprotected void serviceStop() throws Exception
AbstractService
AbstractService.stop()
prevents re-entrancy.
Implementations MUST write this to be robust against failures, including
checks for null references -and for the first failure to not stop other
attempts to shut down parts of the service.serviceStop
in class AbstractService
Exception
- if needed -these will be caught and logged.public RegisterApplicationMasterResponse registerApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl) throws YarnException, IOException
AMRMClient
registerApplicationMaster
in class AMRMClient<T extends AMRMClient.ContainerRequest>
appHostName
- Name of the host on which master is runningappHostPort
- Port master is listening onappTrackingUrl
- URL at which the master info can be seenRegisterApplicationMasterResponse
YarnException
IOException
public AllocateResponse allocate(float progressIndicator) throws YarnException, IOException
AMRMClient
addContainerRequest
are sent to the
ResourceManager
. 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.allocate
in class AMRMClient<T extends AMRMClient.ContainerRequest>
progressIndicator
- Indicates progress made by the masterYarnException
IOException
@InterfaceAudience.Private protected void populateNMTokens(AllocateResponse allocateResponse)
public void unregisterApplicationMaster(FinalApplicationStatus appStatus, String appMessage, String appTrackingUrl) throws YarnException, IOException
AMRMClient
unregisterApplicationMaster
in class AMRMClient<T extends AMRMClient.ContainerRequest>
appStatus
- Success/Failure status of the masterappMessage
- Diagnostics message on failureappTrackingUrl
- New URL to get master infoYarnException
IOException
public void addContainerRequest(T req)
AMRMClient
allocate
addContainerRequest
in class AMRMClient<T extends AMRMClient.ContainerRequest>
req
- Resource requestpublic void removeContainerRequest(T req)
AMRMClient
removeContainerRequest
in class AMRMClient<T extends AMRMClient.ContainerRequest>
req
- Resource requestpublic void releaseAssignedContainer(ContainerId containerId)
AMRMClient
releaseAssignedContainer
in class AMRMClient<T extends AMRMClient.ContainerRequest>
public Resource getAvailableResources()
AMRMClient
getAvailableResources
in class AMRMClient<T extends AMRMClient.ContainerRequest>
public int getClusterNodeCount()
AMRMClient
getClusterNodeCount
in class AMRMClient<T extends AMRMClient.ContainerRequest>
public List<? extends Collection<T>> getMatchingRequests(Priority priority, String resourceName, Resource capability)
AMRMClient
ContainerRequest
s matching the given
parameters. These ContainerRequests should have been added via
addContainerRequest
earlier 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 identical
Resource
size that fit in the given capability. In a
collection, requests will be returned in the same order as they were added.getMatchingRequests
in class AMRMClient<T extends AMRMClient.ContainerRequest>
public void updateBlacklist(List<String> blacklistAdditions, List<String> blacklistRemovals)
AMRMClient
updateBlacklist
in class AMRMClient<T extends AMRMClient.ContainerRequest>
blacklistAdditions
- list of resources which should be added to the
application blacklistblacklistRemovals
- list of resources which should be removed from the
application blacklistCopyright © 2013 Apache Software Foundation. All rights reserved.