org.apache.hadoop.yarn.client
Class AMRMClientImpl

java.lang.Object
  extended by org.apache.hadoop.yarn.service.AbstractService
      extended by org.apache.hadoop.yarn.client.AMRMClientImpl
All Implemented Interfaces:
AMRMClient, org.apache.hadoop.yarn.service.Service

@InterfaceStability.Unstable
public class AMRMClientImpl
extends org.apache.hadoop.yarn.service.AbstractService
implements AMRMClient


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.yarn.client.AMRMClient
AMRMClient.ContainerRequest
 
Nested classes/interfaces inherited from interface org.apache.hadoop.yarn.service.Service
org.apache.hadoop.yarn.service.Service.STATE
 
Field Summary
protected  org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId
           
protected  Set<org.apache.hadoop.yarn.api.records.ResourceRequest> ask
           
protected  org.apache.hadoop.yarn.api.records.Resource clusterAvailableResources
           
protected  int clusterNodeCount
           
protected  Set<org.apache.hadoop.yarn.api.records.ContainerId> release
           
protected  Map<org.apache.hadoop.yarn.api.records.Priority,Map<String,Map<org.apache.hadoop.yarn.api.records.Resource,org.apache.hadoop.yarn.api.records.ResourceRequest>>> remoteRequestsTable
           
protected  org.apache.hadoop.yarn.api.AMRMProtocol rmClient
           
 
Fields inherited from interface org.apache.hadoop.yarn.client.AMRMClient
ANY
 
Constructor Summary
AMRMClientImpl(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId)
           
 
Method Summary
 void addContainerRequest(AMRMClient.ContainerRequest req)
          Request containers for resources before calling allocate
 org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse allocate(float progressIndicator)
          Request additional containers and receive new container allocations.
 org.apache.hadoop.yarn.api.records.Resource getClusterAvailableResources()
          Get the currently available resources in the cluster.
 int getClusterNodeCount()
          Get the current number of nodes in the cluster.
 void init(org.apache.hadoop.conf.Configuration conf)
           
 org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse registerApplicationMaster(String appHostName, int appHostPort, String appTrackingUrl)
          Register the application master.
 void releaseAssignedContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId)
          Release containers assigned by the Resource Manager.
 void removeContainerRequest(AMRMClient.ContainerRequest req)
          Remove previous container request.
 void start()
           
 void stop()
           
 void unregisterApplicationMaster(org.apache.hadoop.yarn.api.records.FinalApplicationStatus appStatus, String appMessage, String appTrackingUrl)
          Unregister the application master.
 
Methods inherited from class org.apache.hadoop.yarn.service.AbstractService
getConfig, getName, getServiceState, getStartTime, register, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.yarn.service.Service
getConfig, getName, getServiceState, getStartTime, register, unregister
 

Field Detail

rmClient

protected org.apache.hadoop.yarn.api.AMRMProtocol rmClient

appAttemptId

protected final org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId

clusterAvailableResources

protected org.apache.hadoop.yarn.api.records.Resource clusterAvailableResources

clusterNodeCount

protected int clusterNodeCount

remoteRequestsTable

protected final Map<org.apache.hadoop.yarn.api.records.Priority,Map<String,Map<org.apache.hadoop.yarn.api.records.Resource,org.apache.hadoop.yarn.api.records.ResourceRequest>>> remoteRequestsTable

ask

protected final Set<org.apache.hadoop.yarn.api.records.ResourceRequest> ask

release

protected final Set<org.apache.hadoop.yarn.api.records.ContainerId> release
Constructor Detail

AMRMClientImpl

public AMRMClientImpl(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId)
Method Detail

init

public void init(org.apache.hadoop.conf.Configuration conf)
Specified by:
init in interface org.apache.hadoop.yarn.service.Service
Overrides:
init in class org.apache.hadoop.yarn.service.AbstractService

start

public void start()
Specified by:
start in interface org.apache.hadoop.yarn.service.Service
Overrides:
start in class org.apache.hadoop.yarn.service.AbstractService

stop

public void stop()
Specified by:
stop in interface org.apache.hadoop.yarn.service.Service
Overrides:
stop in class org.apache.hadoop.yarn.service.AbstractService

registerApplicationMaster

public org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse registerApplicationMaster(String appHostName,
                                                                                                              int appHostPort,
                                                                                                              String appTrackingUrl)
                                                                                                       throws org.apache.hadoop.yarn.exceptions.YarnRemoteException
Description copied from interface: AMRMClient
Register the application master. This must be called before any other interaction

Specified by:
registerApplicationMaster in interface AMRMClient
Parameters:
appHostName - Name of the host on which master is running
appHostPort - Port master is listening on
appTrackingUrl - URL at which the master info can be seen
Returns:
RegisterApplicationMasterResponse
Throws:
org.apache.hadoop.yarn.exceptions.YarnRemoteException

allocate

public org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse allocate(float progressIndicator)
                                                                     throws org.apache.hadoop.yarn.exceptions.YarnRemoteException
Description copied from interface: AMRMClient
Request additional containers and receive new container allocations. Requests made via 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.

Specified by:
allocate in interface AMRMClient
Parameters:
progressIndicator - Indicates progress made by the master
Returns:
the response of the allocate request
Throws:
org.apache.hadoop.yarn.exceptions.YarnRemoteException

unregisterApplicationMaster

public void unregisterApplicationMaster(org.apache.hadoop.yarn.api.records.FinalApplicationStatus appStatus,
                                        String appMessage,
                                        String appTrackingUrl)
                                 throws org.apache.hadoop.yarn.exceptions.YarnRemoteException
Description copied from interface: AMRMClient
Unregister the application master. This must be called in the end.

Specified by:
unregisterApplicationMaster in interface AMRMClient
Parameters:
appStatus - Success/Failure status of the master
appMessage - Diagnostics message on failure
appTrackingUrl - New URL to get master info
Throws:
org.apache.hadoop.yarn.exceptions.YarnRemoteException

addContainerRequest

public void addContainerRequest(AMRMClient.ContainerRequest req)
Description copied from interface: AMRMClient
Request containers for resources before calling allocate

Specified by:
addContainerRequest in interface AMRMClient
Parameters:
req - Resource request

removeContainerRequest

public void removeContainerRequest(AMRMClient.ContainerRequest req)
Description copied from interface: AMRMClient
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:
removeContainerRequest in interface AMRMClient
Parameters:
req - Resource request

releaseAssignedContainer

public void releaseAssignedContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId)
Description copied from interface: AMRMClient
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:
releaseAssignedContainer in interface AMRMClient

getClusterAvailableResources

public org.apache.hadoop.yarn.api.records.Resource getClusterAvailableResources()
Description copied from interface: AMRMClient
Get the currently available resources in the cluster. A valid value is available after a call to allocate has been made

Specified by:
getClusterAvailableResources in interface AMRMClient
Returns:
Currently available resources

getClusterNodeCount

public int getClusterNodeCount()
Description copied from interface: AMRMClient
Get the current number of nodes in the cluster. A valid values is available after a call to allocate has been made

Specified by:
getClusterNodeCount in interface AMRMClient
Returns:
Current number of nodes in the cluster


Copyright © 2013 Apache Software Foundation. All Rights Reserved.