Writing YARN Applications
Link:http://hadoop.apache.org/docs/r2.7.2/hadoop-yarn/hadoop-yarn-site/writingyarnapplications.html
Application Submission Client submits a application,rm, NM, am processing flow to Yarn ResourceManager .
First, create a Yarnclient object and start it, and then the client can set the ApplicationContext. Prepare the first container for the app to containeapplicationmaster, and then submit the application.
RM starts Applicationmaster in the container that you have specified. AM communicates with yarn cluster to handle the execution of application. During the app launch process (the app initiates an AM to communicate with RM is asynchronous), the main work of AM is:
(1) Communicate with RM, negotiate the allocation of resources after containers (through Amrmclientasync object, Amrmclientasync.callbackhandler to specify event handling method);
(2) After the container is assigned, communicate with Nodemanagers, start the containers of the app on which they are located (start a Runnable object, and then start containers after assigning resources to containers. As part of the startup container, am needs to specify the containerlaunchcontextwith the boot information).
During application execution, Applicationmaster communicates with Nodemanagers through the Nmclientasync object. All containers events are handled by Nmclientasync.callbackhandler.
A callback handler handles the client's Start,stop,status update and error.
Original:
the general concept are that an application submission Client submits an application to the yarn ResourceManager (RM). This can is done through setting up a yarnclient Object. after yarnclient is started, the client can then set Up application context, prepare the very first container of the application, contains the applicationmaster (AM), and then submit the application. You need to provide information such as the details about the local files/jars, need to being available for your applicat Ion to run, the actual command this needs to being executed (with the necessary command line arguments), any OS environment s Ettings (optional), etc. Effectively, you need to describe the Unix process (es) that needs to being launched for your applicationmaster.
The YARN ResourceManager would then launch the Applicationmaster (as specified) in an allocated container. The Applicationmaster communicates with YARN cluster, and handles application execution. It performs operations in an asynchronous fashion. During application launch time, the main tasks of the Applicationmaster are:a) communicating with the ResourceManager to Negotiate and allocate resources for the future containers, and B) after container allocation, communicating YARN *nodemanager *s (NMs) to launch application containers on them. Task a) can be performed asynchronously through anAmrmclientasyncobject, with event handling methods specified in a amrmclientasync.callbackhandler type of event handler . The event handler needs to is set to the client explicitly. Task b) can be performed by launching a Runnable object, then launches containers when there is containers allocated. As part of launching this container, the AM have to specify the Containerlaunchcontext that have the launch in Formation such as command line specification, environment, etc.
Learn about Hadoop2.7.2 documentation-yarn part (4) Yarn application