When a container recieved a Init_container event, the state machine of Containerimpl would execute the transaction requestr Esourcestransition, one of the whose resposibility is to check if there are any resource requirement. If there is any, it'll be transformed it to the localresourcerequest. It also gathers the resource with same localresource and then record the gathering into the Containerimpl.
The brand new Localresourcerequest is added to the Containerimpl ' s resource request records list. Then a Map with a visibility typed key and a Localresourcerequest collection value are wrapped into a event called Containe Rlocalizationrequestevent. The event is passed to NM central event dispatcher then dispatch to Resourcelocalizationservice.
Resourcelocalizationservice
1.is a service;
2.is the access point of NM;
3.When recieves containerlocalizationrequestevent, it create a file status cache firstly. Then create a localizercontext to define the basic information of this download, of the cause the file status cache are in the Localizercontext. This service would find a localresourcetracker to handle the Localresourcer
Equest. The Localresourcetracker selection is based on the resource visibility, if the resource are a public one, a LOCALRESOURCETR Acker for Public Resou
Rce would be selected, if the resource are in private level, a localresourcetracker is selected according to the user ID, an D if the resource is at an appliction level, a Localresourcetracker is selected by Applicatoin ID.
Localresourcestracker
1. is a event handler;
2. Maintains a map with localresourcerequest typed key, and Localizedresource typed value;
3. When localresourcerequest is recieved, it'll check whether the resource is isn't only existing in memory, but also Exis TS in local disk. If the file is missing, it'll decrease the counter and re-download the resource by passing the resource request to a LOC Alizedresource;
Localizedresource
1. Is a event handler with a state machine;
2. When recieved resource downloading request event, it account in itself, and send a localizerresourcerequestevent messag E to Localizertracker
Localizertracker
1.is a service;
2.is a EventHandler;
3.process heartbeat from downloading threads;
4.Localizer have a publiclocalizer and an group of Localizerrunner;
5.when recieves localizerresourcerequestevent, it'll check the visibility of the event, if it's public, the event would be added to public localizer,
Otherwise, 'll be add to Localizerrunner only if the Localizerrunner for this container (distinguished by container ID) is Not exist and then the Locaizerr
Unner is started. After that, the event is passed to Localizer.
6. When Containerlocalizer was up, it would talk to Localisertracker by Heartbeat, but the Heartbeat was pass to Correspondin g container ID;
Localizerrunner
1. A thread;
2. Launch a Container Executer to the start up download threads;
3. Process heartbeat to see whether there are pending tasks, if any, keep downloading the resources, all resource of a cont Ainer is downloaded serially;
Containerexecuter
1. Launch the Containerlocalizer to download local resource in blocking mode.
Class Responsibility Analysis of YARN NodeManager