1. Overview
The following describes how NodeManager starts and registers various services.
Mainly involved Java files
Package org. apache. hadoop. yarn. server. nodemanager under hadoop-yarn-server-nodemanager
NodeManager. java
2. Code Analysis
NodeManager in NodeManager. java: When Hadoop is started, the main function in NodeManager is called.
1). main Function
- Output Information to log, create a NodeMananger object,
- Call initAndStartNodeManager (false)
2). initAndStartNodeManager Function
- After the initAndStartNodeManager () function is called, The system reads the configuration information of YarnConfiguration.
- Call the init () function for initialization. For details, refer to 3)
- Call the start () function. The main operation is to start each Service. See figure 4)
3). init Function
- Perform basic configuration operations, such as reading parameters from the configuration file.
- Create and add DeletionService and NodeHealthCheckerService to an ArrayList <Service> Object serviceList of the parent class.
- Call the createNodeStatusUpdater () function to create the NodeStatusUpdater object, and then call the NodeManager parent class method register to register this object and add the ArrayList of the parent class to the listeners object.
- Call the createContainerManager (), createWebServer (), and createNodeResourceMonitor functions to create the ContainerManagerImpl object, Service object, and NodeResourceMonitor object, and add it to serviceList.
- Register ContainerManagerImpl to the previously created asynchronous event scheduler AsyncDispatcher, and then add the AsyncDispatcher scheduler to the Service Queue serviceList.
- Add the NodeStatusUpdater object to serviceList. The reason for adding this object is that the heartbeat operation must be started after all other services.
- Call the init () function of the parent class to initialize other configurations.
4) start Function
- Perform Security Authentication
- Call the start () function of the parent class to start all the added services in step 3. AsyncDispatcher is responsible for event transmission, NodeStatusUpdater is responsible for generating heartbeat events, and ContainerManagerImpl is responsible for providing functions required by Hadoop RPC, etc.
The overall relationship is given. The relationships among NodeStatusUpdater, AsyncDispatcher, and ContainerManagerImpl are given. These three classes will be involved in code analysis in many aspects in the future.