akiyamaneko opened a new pull request #2439:
URL: https://github.com/apache/hadoop/pull/2439


   fix [YARN-10484](https://issues.apache.org/jira/browse/YARN-10484)
   
   ## Problem Reason
   The current drawing logic of 
Containers([nodes-heatmap.js#L184](https://github.com/akiyamaneko/hadoop/blob/7e52c0975f79b7b5739e91b224ced14c8dc76cf6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/nodes-heatmap.js#L184)
 and 
[nodes-heatmap.js#L185](https://github.com/akiyamaneko/hadoop/blob/7e52c0975f79b7b5739e91b224ced14c8dc76cf6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/nodes-heatmap.js#L185))
 can be simplified as follows:
   
   ```javascri
   for (i = 0; i < racksArray.length; i++) {
        ...
        for (var j = 0; j < data.length; j++) {
                var rack = data[j].get("rack");
           if (rack === racksArray[i]) {
                this.totalContainers += data[j].get("numContainers");
                // please notice here: 
                // it will draw nodes directly, and totalContainers will not 
add (j + 1) until data.length
                this.addNode(g, xOffset, yOffset, colorFunc, data[j]);
                ....
           }
         }
   }
   ```
   
   
   
   The node[j] starts to draw the node directly after accumulating the 
`numContainers` values of the node[0]~node[j]. 
   
   In this case, the `numContainers` value of the node[j+1]~node[data.length-1] 
 is not included in the calculation, resulting in The `totalContainers` item of 
different nodes on the page display inconsistencies
   
   
   ## Problem Solution
   My modification considered two factors:
   
   1. The `totalContainers` displayed by different nodes in the same rack 
should be consistent
   2. The drawing of each node will recalculate the rack list and the` 
totalContainer` corresponding to each racj. This is not necessary.
   
   I try to introduce an array to represent the list of racks,  and a Map to 
represent the `totalContainers` of each rack .  Whenever we switch to the 
`container` option, the `array` and `map` will be both re-initialized, when we 
switch to other options, only the array will be re-initialized.
   
   ## Test
   The manual test results are as follows:
   
![fix-1](https://user-images.githubusercontent.com/52202080/98232952-4a2f4000-1f99-11eb-80e6-c826844915b1.png)
   
![fix-2](https://user-images.githubusercontent.com/52202080/98232958-4ac7d680-1f99-11eb-8890-5a0f208840f0.png)
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to