org.apache.hadoop.yarn.client.api
Class YarnClient

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

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract class YarnClient
extends AbstractService


Constructor Summary
protected YarnClient(String name)
           
 
Method Summary
abstract  YarnClientApplication createApplication()
           Obtain a YarnClientApplication for a new application, which in turn contains the ApplicationSubmissionContext and GetNewApplicationResponse objects.
static YarnClient createYarnClient()
          Create a new instance of YarnClient.
abstract  List<QueueInfo> getAllQueues()
           Get information (QueueInfo) about all queues, recursively if there is a hierarchy
abstract  org.apache.hadoop.security.token.Token<AMRMTokenIdentifier> getAMRMToken(ApplicationId appId)
          Get the AMRM token of the application.
abstract  ApplicationAttemptReport getApplicationAttemptReport(ApplicationAttemptId applicationAttemptId)
           Get a report of the given ApplicationAttempt.
abstract  List<ApplicationAttemptReport> getApplicationAttempts(ApplicationId applicationId)
           Get a report of all (ApplicationAttempts) of Application in the cluster.
abstract  ApplicationReport getApplicationReport(ApplicationId appId)
           Get a report of the given Application.
abstract  List<ApplicationReport> getApplications()
           Get a report (ApplicationReport) of all Applications in the cluster.
abstract  List<ApplicationReport> getApplications(EnumSet<YarnApplicationState> applicationStates)
           Get a report (ApplicationReport) of Applications matching the given application states in the cluster.
abstract  List<ApplicationReport> getApplications(Set<String> applicationTypes)
           Get a report (ApplicationReport) of Applications matching the given application types in the cluster.
abstract  List<ApplicationReport> getApplications(Set<String> applicationTypes, EnumSet<YarnApplicationState> applicationStates)
           Get a report (ApplicationReport) of Applications matching the given application types and application states in the cluster.
abstract  List<QueueInfo> getChildQueueInfos(String parent)
           Get information (QueueInfo) about all the immediate children queues of the given queue
abstract  ContainerReport getContainerReport(ContainerId containerId)
           Get a report of the given Container.
abstract  List<ContainerReport> getContainers(ApplicationAttemptId applicationAttemptId)
           Get a report of all (Containers) of ApplicationAttempt in the cluster.
abstract  List<NodeReport> getNodeReports(NodeState... states)
           Get a report of nodes (NodeReport) in the cluster.
abstract  List<QueueUserACLInfo> getQueueAclsInfo()
           Get information about acls for current user on all the existing queues.
abstract  QueueInfo getQueueInfo(String queueName)
           Get information (QueueInfo) about a given queue.
abstract  Token getRMDelegationToken(Text renewer)
           Get a delegation token so as to be able to talk to YARN using those tokens.
abstract  List<QueueInfo> getRootQueueInfos()
           Get information (QueueInfo) about top level queues.
abstract  YarnClusterMetrics getYarnClusterMetrics()
           Get metrics (YarnClusterMetrics) about the cluster.
abstract  void killApplication(ApplicationId applicationId)
           Kill an application identified by given ID.
abstract  void moveApplicationAcrossQueues(ApplicationId appId, String queue)
           Attempts to move the given application to the given queue.
abstract  ApplicationId submitApplication(ApplicationSubmissionContext appContext)
           Submit a new application to YARN. It is a blocking call - it will not return ApplicationId until the submitted application is submitted successfully and accepted by the ResourceManager.
 
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, serviceInit, serviceStart, serviceStop, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

YarnClient

@InterfaceAudience.Private
protected YarnClient(String name)
Method Detail

createYarnClient

@InterfaceAudience.Public
public static YarnClient createYarnClient()
Create a new instance of YarnClient.


createApplication

public abstract YarnClientApplication createApplication()
                                                 throws YarnException,
                                                        IOException

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

Returns:
YarnClientApplication built for a new application
Throws:
YarnException
IOException

submitApplication

public abstract ApplicationId submitApplication(ApplicationSubmissionContext appContext)
                                         throws YarnException,
                                                IOException

Submit a new application to YARN. It is a blocking call - it will not return ApplicationId until the submitted application is submitted successfully and accepted by the ResourceManager.

Users should provide an ApplicationId as part of the parameter ApplicationSubmissionContext when submitting a new application, otherwise it will throw the ApplicationIdNotProvidedException.

This internally calls (SubmitApplicationRequest), and after that, it internally invokes (GetApplicationReportRequest) and waits till it can make sure that the application gets properly submitted. If RM fails over or RM restart happens before ResourceManager saves the application's state, #getApplicationReport(GetApplicationReportRequest) will throw the ApplicationNotFoundException. This API automatically resubmits the application with the same ApplicationSubmissionContext when it catches the ApplicationNotFoundException

Parameters:
appContext - ApplicationSubmissionContext containing all the details needed to submit a new application
Returns:
ApplicationId of the accepted application
Throws:
YarnException
IOException
See Also:
createApplication()

killApplication

public abstract void killApplication(ApplicationId applicationId)
                              throws YarnException,
                                     IOException

Kill an application identified by given ID.

Parameters:
applicationId - ApplicationId of the application that needs to be killed
Throws:
YarnException - in case of errors or if YARN rejects the request due to access-control restrictions.
IOException
See Also:
getQueueAclsInfo()

getApplicationReport

public abstract ApplicationReport getApplicationReport(ApplicationId appId)
                                                throws YarnException,
                                                       IOException

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:

Parameters:
appId - ApplicationId of the application that needs a report
Returns:
application report
Throws:
YarnException
IOException

getAMRMToken

public abstract org.apache.hadoop.security.token.Token<AMRMTokenIdentifier> getAMRMToken(ApplicationId appId)
                                                                                  throws YarnException,
                                                                                         IOException
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.

    Parameters:
    appId - ApplicationId of the application to get the AMRM token
    Returns:
    the AMRM token if available
    Throws:
    YarnException
    IOException

    getApplications

    public abstract List<ApplicationReport> getApplications()
                                                     throws YarnException,
                                                            IOException

    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 getApplicationReport(ApplicationId).

    Returns:
    a list of reports of all running applications
    Throws:
    YarnException
    IOException

    getApplications

    public abstract List<ApplicationReport> getApplications(Set<String> applicationTypes)
                                                     throws YarnException,
                                                            IOException

    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 getApplicationReport(ApplicationId).

    Parameters:
    applicationTypes -
    Returns:
    a list of reports of applications
    Throws:
    YarnException
    IOException

    getApplications

    public abstract List<ApplicationReport> getApplications(EnumSet<YarnApplicationState> applicationStates)
                                                     throws YarnException,
                                                            IOException

    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 getApplicationReport(ApplicationId).

    Parameters:
    applicationStates -
    Returns:
    a list of reports of applications
    Throws:
    YarnException
    IOException

    getApplications

    public abstract List<ApplicationReport> getApplications(Set<String> applicationTypes,
                                                            EnumSet<YarnApplicationState> applicationStates)
                                                     throws YarnException,
                                                            IOException

    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 getApplicationReport(ApplicationId).

    Parameters:
    applicationTypes -
    applicationStates -
    Returns:
    a list of reports of applications
    Throws:
    YarnException
    IOException

    getYarnClusterMetrics

    public abstract YarnClusterMetrics getYarnClusterMetrics()
                                                      throws YarnException,
                                                             IOException

    Get metrics (YarnClusterMetrics) about the cluster.

    Returns:
    cluster metrics
    Throws:
    YarnException
    IOException

    getNodeReports

    public abstract List<NodeReport> getNodeReports(NodeState... states)
                                             throws YarnException,
                                                    IOException

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

    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:
    YarnException
    IOException

    getRMDelegationToken

    public abstract Token getRMDelegationToken(Text renewer)
                                        throws YarnException,
                                               IOException

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

    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:
    YarnException
    IOException

    getQueueInfo

    public abstract QueueInfo getQueueInfo(String queueName)
                                    throws YarnException,
                                           IOException

    Get information (QueueInfo) about a given queue.

    Parameters:
    queueName - Name of the queue whose information is needed
    Returns:
    queue information
    Throws:
    YarnException - in case of errors or if YARN rejects the request due to access-control restrictions.
    IOException

    getAllQueues

    public abstract List<QueueInfo> getAllQueues()
                                          throws YarnException,
                                                 IOException

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

    Returns:
    a list of queue-information for all queues
    Throws:
    YarnException
    IOException

    getRootQueueInfos

    public abstract List<QueueInfo> getRootQueueInfos()
                                               throws YarnException,
                                                      IOException

    Get information (QueueInfo) about top level queues.

    Returns:
    a list of queue-information for all the top-level queues
    Throws:
    YarnException
    IOException

    getChildQueueInfos

    public abstract List<QueueInfo> getChildQueueInfos(String parent)
                                                throws YarnException,
                                                       IOException

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

    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:
    YarnException
    IOException

    getQueueAclsInfo

    public abstract List<QueueUserACLInfo> getQueueAclsInfo()
                                                     throws YarnException,
                                                            IOException

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

    Returns:
    a list of queue acls (QueueUserACLInfo) for current user
    Throws:
    YarnException
    IOException

    getApplicationAttemptReport

    public abstract ApplicationAttemptReport getApplicationAttemptReport(ApplicationAttemptId applicationAttemptId)
                                                                  throws YarnException,
                                                                         IOException

    Get a report of the given ApplicationAttempt.

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

    Parameters:
    applicationAttemptId - ApplicationAttemptId of the application attempt that needs a report
    Returns:
    application attempt report
    Throws:
    YarnException
    {@link - ApplicationAttemptNotFoundException} if application attempt not found
    IOException

    getApplicationAttempts

    public abstract List<ApplicationAttemptReport> getApplicationAttempts(ApplicationId applicationId)
                                                                   throws YarnException,
                                                                          IOException

    Get a report of all (ApplicationAttempts) of Application in the cluster.

    Parameters:
    applicationId -
    Returns:
    a list of reports for all application attempts for specified application.
    Throws:
    YarnException
    IOException

    getContainerReport

    public abstract ContainerReport getContainerReport(ContainerId containerId)
                                                throws YarnException,
                                                       IOException

    Get a report of the given Container.

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

    Parameters:
    containerId - ContainerId of the container that needs a report
    Returns:
    container report
    Throws:
    YarnException
    {@link - ContainerNotFoundException} if container not found.
    IOException

    getContainers

    public abstract List<ContainerReport> getContainers(ApplicationAttemptId applicationAttemptId)
                                                 throws YarnException,
                                                        IOException

    Get a report of all (Containers) of ApplicationAttempt in the cluster.

    Parameters:
    applicationAttemptId -
    Returns:
    a list of reports of all containers for specified application attempts
    Throws:
    YarnException
    IOException

    moveApplicationAcrossQueues

    public abstract void moveApplicationAcrossQueues(ApplicationId appId,
                                                     String queue)
                                              throws YarnException,
                                                     IOException

    Attempts to move the given application to the given queue.

    Parameters:
    appId - Application to move.
    queue - Queue to place it in to.
    Throws:
    YarnException
    IOException


    Copyright © 2014 Apache Software Foundation. All Rights Reserved.