YARN-9504. [UI2] Fair scheduler queue view page does not show actual capacity. Contributed by Zoltan Siegl.

This commit is contained in:
Sunil G 2019-05-10 14:26:06 +05:30
parent b832e174b0
commit 64c7f36ab1
1 changed files with 39 additions and 4 deletions

View File

@ -192,7 +192,8 @@ export default Ember.Component.extend({
.style( .style(
"fill", "fill",
function(d) { function(d) {
const usedCapacity = getUsedCapacity(d.queueData.get("partitionMap"), this.filteredPartition); const usedCapacity = getUsedCapacity(d.queueData, this.filteredPartition);
if (usedCapacity <= 60.0) { if (usedCapacity <= 60.0) {
return "#60cea5"; return "#60cea5";
} else if (usedCapacity <= 100.0) { } else if (usedCapacity <= 100.0) {
@ -216,7 +217,8 @@ export default Ember.Component.extend({
}) })
.text( .text(
function(d) { function(d) {
const usedCapacity = getUsedCapacity(d.queueData.get("partitionMap"), this.filteredPartition); const usedCapacity = getUsedCapacity(d.queueData, this.filteredPartition);
if (usedCapacity >= 100.0) { if (usedCapacity >= 100.0) {
return usedCapacity.toFixed(0) + "%"; return usedCapacity.toFixed(0) + "%";
} else { } else {
@ -372,6 +374,39 @@ export default Ember.Component.extend({
}); });
const getUsedCapacity = (partitionMap, filter=PARTITION_LABEL) => { const getUsedCapacity = (queueData, filter=PARTITION_LABEL) => {
return partitionMap[filter].absoluteUsedCapacity;
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;
}; };