Class Client

  extended by org.apache.hadoop.yarn.service.AbstractService
      extended by org.apache.hadoop.yarn.client.YarnClientImpl
          extended by org.apache.hadoop.yarn.applications.distributedshell.Client
All Implemented Interfaces:
YarnClient, org.apache.hadoop.yarn.service.Service

public class Client
extends YarnClientImpl

Client for Distributed Shell application submission to YARN.

The distributed shell client allows an application master to be launched that in turn would run the provided shell command on a set of containers.

This client is meant to act as an example on how to write yarn-based applications.

To submit an application, a client first needs to connect to the ResourceManager aka ApplicationsManager or ASM via the ClientRMProtocol. The ClientRMProtocol provides a way for the client to get access to cluster information and to request for a new ApplicationId.

For the actual job submission, the client first has to create an ApplicationSubmissionContext. The ApplicationSubmissionContext defines the application details such as ApplicationId and application name, the priority assigned to the application and the queue to which this application needs to be assigned. In addition to this, the ApplicationSubmissionContext also defines the ContainerLaunchContext which describes the Container with which the ApplicationMaster is launched.

The ContainerLaunchContext in this scenario defines the resources to be allocated for the ApplicationMaster's container, the local resources (jars, configuration files) to be made available and the environment to be set for the ApplicationMaster and the commands to be executed to run the ApplicationMaster.

Using the ApplicationSubmissionContext, the client submits the application to the ResourceManager and then monitors the application by requesting the ResourceManager for an ApplicationReport at regular time intervals. In case of the application taking too long, the client kills the application by submitting a KillApplicationRequest to the ResourceManager.

Field Summary
Fields inherited from class org.apache.hadoop.yarn.client.YarnClientImpl
rmAddress, rmClient
Constructor Summary
Client(Configuration conf)
Method Summary
 boolean init(String[] args)
          Parse command line options
static void main(String[] args)
 boolean run()
          Main run function for the client
Methods inherited from class org.apache.hadoop.yarn.client.YarnClientImpl
getAllQueues, getApplicationList, getApplicationReport, getChildQueueInfos, getNewApplication, getNodeReports, getQueueAclsInfo, getQueueInfo, getRMDelegationToken, getRootQueueInfos, getYarnClusterMetrics, init, killApplication, start, stop, submitApplication
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

Constructor Detail


public Client(Configuration conf)
       throws Exception


public Client()
       throws Exception
Method Detail


public static void main(String[] args)
args - Command line arguments


public boolean init(String[] args)
             throws org.apache.commons.cli.ParseException
Parse command line options

args - Parsed command line options
Whether the init was successful to run the client


public boolean run()
            throws IOException
Main run function for the client

true if application completed successfully

Copyright © 2012 Apache Software Foundation. All Rights Reserved.