From 64c7f36ab12faba26a2ecf1e6a0cab7eb2bcffdd Mon Sep 17 00:00:00 2001 From: Sunil G Date: Fri, 10 May 2019 14:26:06 +0530 Subject: [PATCH] YARN-9504. [UI2] Fair scheduler queue view page does not show actual capacity. Contributed by Zoltan Siegl. --- .../webapp/app/components/tree-selector.js | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js index 5168c0e0a7c..9becfc10621 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js @@ -192,7 +192,8 @@ export default Ember.Component.extend({ .style( "fill", function(d) { - const usedCapacity = getUsedCapacity(d.queueData.get("partitionMap"), this.filteredPartition); + const usedCapacity = getUsedCapacity(d.queueData, this.filteredPartition); + if (usedCapacity <= 60.0) { return "#60cea5"; } else if (usedCapacity <= 100.0) { @@ -216,7 +217,8 @@ export default Ember.Component.extend({ }) .text( function(d) { - const usedCapacity = getUsedCapacity(d.queueData.get("partitionMap"), this.filteredPartition); + const usedCapacity = getUsedCapacity(d.queueData, this.filteredPartition); + if (usedCapacity >= 100.0) { return usedCapacity.toFixed(0) + "%"; } else { @@ -372,6 +374,39 @@ export default Ember.Component.extend({ }); -const getUsedCapacity = (partitionMap, filter=PARTITION_LABEL) => { - return partitionMap[filter].absoluteUsedCapacity; +const getUsedCapacity = (queueData, filter=PARTITION_LABEL) => { + + const type = queueData.get("type"); + var result; + + switch (type) { + case "capacity": + const partitionMap = queueData.get("partitionMap"); + if (null == partitionMap || null == partitionMap[filter] || null == partitionMap[filter].absoluteUsedCapacity) { + result = 0.0; + } else { + result = partitionMap[filter].absoluteUsedCapacity; + } + break; + + case "fair": + if (null == queueData.get("fairResources") || null == queueData.get("fairResources").memory || null == queueData.get("usedResources") || null == queueData.get("usedResources").memory || 0 == queueData.get("fairResources").memory) { + result = 0.0; + } else { + result = queueData.get("usedResources").memory / queueData.get("fairResources").memory * 100; + } + break; + + case "fifo": + if (null == queueData.get("usedCapacity") || (null == queueData.get("capacity")) || (queueData.get("capacity") == 0)) { + result = 0.0; + } else { + result = queueData.get("usedCapacity") / queueData.get("capacity") * 100; + } + break; + + default: + result = 0.0; + } + return result; }; \ No newline at end of file