org.apache.hadoop.yarn.client.api.impl
Class YarnClientImpl

java.lang.Object
  extended by org.apache.hadoop.service.AbstractService
      extended by org.apache.hadoop.yarn.client.api.YarnClient
          extended by org.apache.hadoop.yarn.client.api.impl.YarnClientImpl
All Implemented Interfaces:
Closeable, org.apache.hadoop.service.Service

@InterfaceAudience.Private
@InterfaceStability.Unstable
public class YarnClientImpl
extends YarnClient


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE
 
Field Summary
protected  InetSocketAddress rmAddress
           
protected  org.apache.hadoop.yarn.api.ApplicationClientProtocol rmClient
           
protected  long statePollIntervalMillis
           
 
Constructor Summary
YarnClientImpl()
           
 
Method Summary
 YarnClientApplication createApplication()
           Obtain a YarnClientApplication for a new application, which in turn contains the ApplicationSubmissionContext and GetNewApplicationResponse objects.
 List<org.apache.hadoop.yarn.api.records.QueueInfo> getAllQueues()
           Get information (QueueInfo) about all queues, recursively if there is a hierarchy
 org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.AMRMTokenIdentifier> getAMRMToken(org.apache.hadoop.yarn.api.records.ApplicationId appId)
          Get the AMRM token of the application.
 org.apache.hadoop.yarn.api.records.ApplicationReport getApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationId appId)
           Get a report of the given Application.
 List<org.apache.hadoop.yarn.api.records.ApplicationReport> getApplications()
           Get a report (ApplicationReport) of all Applications in the cluster.
 List<org.apache.hadoop.yarn.api.records.ApplicationReport> getApplications(EnumSet<org.apache.hadoop.yarn.api.records.YarnApplicationState> applicationStates)
           Get a report (ApplicationReport) of Applications matching the given application states in the cluster.
 List<org.apache.hadoop.yarn.api.records.ApplicationReport> getApplications(Set<String> applicationTypes)
           Get a report (ApplicationReport) of Applications matching the given application types in the cluster.
 List<org.apache.hadoop.yarn.api.records.ApplicationReport> getApplications(Set<String> applicationTypes, EnumSet<org.apache.hadoop.yarn.api.records.YarnApplicationState> applicationStates)
           Get a report (ApplicationReport) of Applications matching the given application types and application states in the cluster.
 List<org.apache.hadoop.yarn.api.records.QueueInfo> getChildQueueInfos(String parent)
           Get information (QueueInfo) about all the immediate children queues of the given queue
 List<org.apache.hadoop.yarn.api.records.NodeReport> getNodeReports(org.apache.hadoop.yarn.api.records.NodeState... states)
           Get a report of nodes (NodeReport) in the cluster.
 List<org.apache.hadoop.yarn.api.records.QueueUserACLInfo> getQueueAclsInfo()
           Get information about acls for current user on all the existing queues.
 org.apache.hadoop.yarn.api.records.QueueInfo getQueueInfo(String queueName)
           Get information (QueueInfo) about a given queue.
 org.apache.hadoop.yarn.api.records.Token getRMDelegationToken(org.apache.hadoop.io.Text renewer)
           Get a delegation token so as to be able to talk to YARN using those tokens.
 List<org.apache.hadoop.yarn.api.records.QueueInfo> getRootQueueInfos()
           Get information (QueueInfo) about top level queues.
 org.apache.hadoop.yarn.api.records.YarnClusterMetrics getYarnClusterMetrics()
           Get metrics (YarnClusterMetrics) about the cluster.
 void killApplication(org.apache.hadoop.yarn.api.records.ApplicationId applicationId)
           Kill an application identified by given ID.
protected  void serviceInit(org.apache.hadoop.conf.Configuration conf)
           
protected  void serviceStart()
           
protected  void serviceStop()
           
 void setRMClient(org.apache.hadoop.yarn.api.ApplicationClientProtocol rmClient)
           
 org.apache.hadoop.yarn.api.records.ApplicationId submitApplication(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext appContext)
           Submit a new application to YARN. It is a blocking call, such that it will not return ApplicationId until the submitted application has been submitted and accepted by the ResourceManager.
 
Methods inherited from class org.apache.hadoop.yarn.client.api.YarnClient
createYarnClient
 
Methods 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rmClient

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

rmAddress

protected InetSocketAddress rmAddress

statePollIntervalMillis

protected long statePollIntervalMillis
Constructor Detail

YarnClientImpl

public YarnClientImpl()
Method Detail

serviceInit

protected void serviceInit(org.apache.hadoop.conf.Configuration conf)
                    throws Exception
Overrides:
serviceInit in class org.apache.hadoop.service.AbstractService
Throws:
Exception

serviceStart

protected void serviceStart()
                     throws Exception
Overrides:
serviceStart in class org.apache.hadoop.service.AbstractService
Throws:
Exception

serviceStop

protected void serviceStop()
                    throws Exception
Overrides:
serviceStop in class org.apache.hadoop.service.AbstractService
Throws:
Exception

createApplication

public YarnClientApplication createApplication()
                                        throws org.apache.hadoop.yarn.exceptions.YarnException,
                                               IOException
Description copied from class: YarnClient

Obtain a YarnClientApplication for a new application, which in turn contains the ApplicationSubmissionContext and GetNewApplicationResponse objects.

Specified by:
createApplication in class YarnClient
Returns:
YarnClientApplication built for a new application
Throws:
org.apache.hadoop.yarn.exceptions.YarnException
IOException

submitApplication

public org.apache.hadoop.yarn.api.records.ApplicationId submitApplication(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext appContext)
                                                                   throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                          IOException
Description copied from class: YarnClient

Submit a new application to YARN. It is a blocking call, such that it will not return ApplicationId until the submitted application has been submitted and accepted by the ResourceManager.

Specified by:
submitApplication in class YarnClient
Parameters:
appContext - ApplicationSubmissionContext containing all the details needed to submit a new application
Returns:
ApplicationId of the accepted application
Throws:
org.apache.hadoop.yarn.exceptions.YarnException
IOException
See Also:
YarnClient.createApplication()

killApplication

public void killApplication(org.apache.hadoop.yarn.api.records.ApplicationId applicationId)
                     throws org.apache.hadoop.yarn.exceptions.YarnException,
                            IOException
Description copied from class: YarnClient

Kill an application identified by given ID.

Specified by:
killApplication in class YarnClient
Parameters:
applicationId - ApplicationId of the application that needs to be killed
Throws:
org.apache.hadoop.yarn.exceptions.YarnException - in case of errors or if YARN rejects the request due to access-control restrictions.
IOException
See Also:
YarnClient.getQueueAclsInfo()

getApplicationReport

public org.apache.hadoop.yarn.api.records.ApplicationReport getApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationId appId)
                                                                          throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                 IOException
Description copied from class: YarnClient

Get a report of the given Application.

In secure mode, YARN verifies access to the application, queue etc. before accepting the request.

If the user does not have VIEW_APP access then the following fields in the report will be set to stubbed values:

Specified by:
getApplicationReport in class YarnClient
Parameters:
appId - ApplicationId of the application that needs a report
Returns:
application report
Throws:
org.apache.hadoop.yarn.exceptions.YarnException
IOException

getAMRMToken

public org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.AMRMTokenIdentifier> getAMRMToken(org.apache.hadoop.yarn.api.records.ApplicationId appId)
                                                                                                         throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                                                IOException
Description copied from class: YarnClient
Get the AMRM token of the application.

The AMRM token is required for AM to RM scheduling operations. For managed Application Masters Yarn takes care of injecting it. For unmanaged Applications Masters, the token must be obtained via this method and set in the UserGroupInformation of the current user.

The AMRM token will be returned only if all the following conditions are met:

    • the requester is the owner of the ApplicationMaster
      the application master is an unmanaged ApplicationMaster
      the application master is in ACCEPTED state
  • Else this method returns NULL.

    Specified by:
    getAMRMToken in class YarnClient
    Parameters:
    appId - ApplicationId of the application to get the AMRM token
    Returns:
    the AMRM token if available
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getApplications

    public List<org.apache.hadoop.yarn.api.records.ApplicationReport> getApplications()
                                                                               throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                      IOException
    Description copied from class: YarnClient

    Get a report (ApplicationReport) of all Applications in the cluster.

    If the user does not have VIEW_APP access for an application then the corresponding report will be filtered as described in YarnClient.getApplicationReport(ApplicationId).

    Specified by:
    getApplications in class YarnClient
    Returns:
    a list of reports of all running applications
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getApplications

    public List<org.apache.hadoop.yarn.api.records.ApplicationReport> getApplications(Set<String> applicationTypes)
                                                                               throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                      IOException
    Description copied from class: YarnClient

    Get a report (ApplicationReport) of Applications matching the given application types in the cluster.

    If the user does not have VIEW_APP access for an application then the corresponding report will be filtered as described in YarnClient.getApplicationReport(ApplicationId).

    Specified by:
    getApplications in class YarnClient
    Returns:
    a list of reports of applications
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getApplications

    public List<org.apache.hadoop.yarn.api.records.ApplicationReport> getApplications(EnumSet<org.apache.hadoop.yarn.api.records.YarnApplicationState> applicationStates)
                                                                               throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                      IOException
    Description copied from class: YarnClient

    Get a report (ApplicationReport) of Applications matching the given application states in the cluster.

    If the user does not have VIEW_APP access for an application then the corresponding report will be filtered as described in YarnClient.getApplicationReport(ApplicationId).

    Specified by:
    getApplications in class YarnClient
    Returns:
    a list of reports of applications
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getApplications

    public List<org.apache.hadoop.yarn.api.records.ApplicationReport> getApplications(Set<String> applicationTypes,
                                                                                      EnumSet<org.apache.hadoop.yarn.api.records.YarnApplicationState> applicationStates)
                                                                               throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                      IOException
    Description copied from class: YarnClient

    Get a report (ApplicationReport) of Applications matching the given application types and application states in the cluster.

    If the user does not have VIEW_APP access for an application then the corresponding report will be filtered as described in YarnClient.getApplicationReport(ApplicationId).

    Specified by:
    getApplications in class YarnClient
    Returns:
    a list of reports of applications
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getYarnClusterMetrics

    public org.apache.hadoop.yarn.api.records.YarnClusterMetrics getYarnClusterMetrics()
                                                                                throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                       IOException
    Description copied from class: YarnClient

    Get metrics (YarnClusterMetrics) about the cluster.

    Specified by:
    getYarnClusterMetrics in class YarnClient
    Returns:
    cluster metrics
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getNodeReports

    public List<org.apache.hadoop.yarn.api.records.NodeReport> getNodeReports(org.apache.hadoop.yarn.api.records.NodeState... states)
                                                                       throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                              IOException
    Description copied from class: YarnClient

    Get a report of nodes (NodeReport) in the cluster.

    Specified by:
    getNodeReports in class YarnClient
    Parameters:
    states - The NodeStates to filter on. If no filter states are given, nodes in all states will be returned.
    Returns:
    A list of node reports
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getRMDelegationToken

    public org.apache.hadoop.yarn.api.records.Token getRMDelegationToken(org.apache.hadoop.io.Text renewer)
                                                                  throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                         IOException
    Description copied from class: YarnClient

    Get a delegation token so as to be able to talk to YARN using those tokens.

    Specified by:
    getRMDelegationToken in class YarnClient
    Parameters:
    renewer - Address of the renewer who can renew these tokens when needed by securely talking to YARN.
    Returns:
    a delegation token (Token) that can be used to talk to YARN
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getQueueInfo

    public org.apache.hadoop.yarn.api.records.QueueInfo getQueueInfo(String queueName)
                                                              throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                     IOException
    Description copied from class: YarnClient

    Get information (QueueInfo) about a given queue.

    Specified by:
    getQueueInfo in class YarnClient
    Parameters:
    queueName - Name of the queue whose information is needed
    Returns:
    queue information
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException - in case of errors or if YARN rejects the request due to access-control restrictions.
    IOException

    getQueueAclsInfo

    public List<org.apache.hadoop.yarn.api.records.QueueUserACLInfo> getQueueAclsInfo()
                                                                               throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                      IOException
    Description copied from class: YarnClient

    Get information about acls for current user on all the existing queues.

    Specified by:
    getQueueAclsInfo in class YarnClient
    Returns:
    a list of queue acls (QueueUserACLInfo) for current user
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getAllQueues

    public List<org.apache.hadoop.yarn.api.records.QueueInfo> getAllQueues()
                                                                    throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                           IOException
    Description copied from class: YarnClient

    Get information (QueueInfo) about all queues, recursively if there is a hierarchy

    Specified by:
    getAllQueues in class YarnClient
    Returns:
    a list of queue-information for all queues
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getRootQueueInfos

    public List<org.apache.hadoop.yarn.api.records.QueueInfo> getRootQueueInfos()
                                                                         throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                IOException
    Description copied from class: YarnClient

    Get information (QueueInfo) about top level queues.

    Specified by:
    getRootQueueInfos in class YarnClient
    Returns:
    a list of queue-information for all the top-level queues
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    getChildQueueInfos

    public List<org.apache.hadoop.yarn.api.records.QueueInfo> getChildQueueInfos(String parent)
                                                                          throws org.apache.hadoop.yarn.exceptions.YarnException,
                                                                                 IOException
    Description copied from class: YarnClient

    Get information (QueueInfo) about all the immediate children queues of the given queue

    Specified by:
    getChildQueueInfos in class YarnClient
    Parameters:
    parent - Name of the queue whose child-queues' information is needed
    Returns:
    a list of queue-information for all queues who are direct children of the given parent queue.
    Throws:
    org.apache.hadoop.yarn.exceptions.YarnException
    IOException

    setRMClient

    @InterfaceAudience.Private
    public void setRMClient(org.apache.hadoop.yarn.api.ApplicationClientProtocol rmClient)


    Copyright © 2014 Apache Software Foundation. All Rights Reserved.