Detailed description of Application state machine

Source: Internet
Author: User

The following describes the state machine of RM. The state machine of NM is analyzed. The state machine of NM includes three states: Container, Application, and LocalizedResource. First, we analyze the state machine of the Application. NodeManager maintains the Application executed by the node. As shown in figure 1, it maintains the user, containers, AppId, and status information. The Application implementation class is ApplicationImpl. Figure 2 shows the state machine of the Application. Figure 1 Application interface Figure 2 Application state machine diagram Application state transition and Interpretation NEW. At NM, ContainerManagerImpl implements the ContainerManagementProtocol protocol, therefore, RM and AM can use RPC to call the startContainers method command NM to start the corresponding iner. In the startContainers method of NM, the ApplicationImpl object is created and its initial status is NEW. INITING: In the startContainers method of NM, after the ApplicationImpl object is generated, the ApplicationEventType. INIT_APPLICATION event is created. ApplicationImpl calls AppInitTransition to process this event and sets the status to INITING. RUNNING, which must be initialized to the RUNNING state. Initialize HDFS and local directory respectively. LogHandlerEventType is created in AppInitTransition. APPLICATION_STARTED event, LogHandler will handle this event. In fact, as the implementation class of LogHandler, LogAggregationService initializes the App mainly to create a directory (usually on HDFS, through remoteFS. getWorkingDirectory () method or corresponding directory) and initialize AppAggregator (responsible for collecting logs of container and storing them on HDFS). After initialization, create ApplicationEventType. APPLICATION_LOG_HANDLING_INITED event. ApplicationImpl calls AppLogInitDoneTransition to process this event, creates the LocalizationEventType. INIT_APPLICATION_RESOURCES event, and sets ApplicationImpl to INITING. ResourceLocalizationService is responsible for processing LocalizationEventType. INIT_APPLICATION_RESOURCES event, that is, initialize the local directory, and then create ApplicationEventType. APPLICATION_INITED event. ApplicationImpl calls AppInitDoneTransition to handle this event. At this time, ContainerEventType is created for each container in the App. INIT_CONTAINER event, and finally set ApplicationImpl to RUNNING. FINISHING_CONTAINERS_WAIT. If RM returns the NM heartbeat information to show that the App belongs to the appsToCleanup list or the NM stops the service, ApplicationEventType is created. FINISH_APPLICATION event. ApplicationImpl calls AppFinishTriggeredTransition to handle this event. If the App does not have a iner, ApplicationImpl is set to ApplicationState. APPLICATION_RESOURCES_CLEANINGUP; creates ContainerEventType for each iner. KILL_CONTAINER event, and then set ApplicationImpl to ApplicationState. FINISHING_CONTAINERS_WAIT. Here I will explain why the ending trigger is the NM ending service and the RM notifying NM. It is easy to understand that the NM ending service then notifies the App, but in normal cases, why is RM notifying NM to end the corresponding App? In this case, if RM knows this information after the ApplicationMaster ends, then it notifies NM that the corresponding container of this App should be notified. APPLICATION_RESOURCES_CLEANINGUP: When the iner ends, an upload event is created. ApplicationImpl calls AppFinishTransition to handle this event. If no iner exists in the App, set ApplicationImpl to APPLICATION_RESOURCES_CLEANINGUP. FINISHED: before you set ApplicationImpl to APPLICATION_RESOURCES_CLEANINGUP, ApplicationImpl creates LocalizationEventType. DESTROY_APPLICATION_RESOURCES and AuxServicesEventType. APPLICATION_STOP event. ResourceLocalizationService is responsible for the DESTROY_APPLICATION_RESOURCES event. It asynchronously deletes temporary files of local apps, such as directories such as appcache and nmPrivate. The ApplicationEventType. APPLICATION_RESOURCES_CLEANEDUP event is generated. ApplicationImpl calls AppCompletelyDoneTransition to process this event, generates a LogHandlerEventType. APPLICATION_FINISHED event, and sets the ApplicationImpl status to FINISHED.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.