YARN-6152. Used queue percentage not accurate in UI for 2.7 and below when using DominantResourceCalculator. Contributed by Jonathan Hung

This commit is contained in:
Eric Payne 2017-02-07 11:33:28 -06:00
parent 086ee0adf8
commit bc3e188e11
1 changed files with 11 additions and 10 deletions

View File

@ -545,16 +545,17 @@ public abstract class AbstractCSQueue implements CSQueue {
* @return used resources by this queue for specified label * @return used resources by this queue for specified label
*/ */
public final synchronized float getUsedCapacity(final String nodeLabel) { public final synchronized float getUsedCapacity(final String nodeLabel) {
Resource totalPartitionResource =
labelManager.getResourceByLabel(nodeLabel, this.clusterResource);
Resource availableToQueue = Resource availableToQueue =
Resources.multiply( Resources.multiply(totalPartitionResource,
labelManager.getResourceByLabel(nodeLabel, this.clusterResource),
queueCapacities.getAbsoluteCapacity(nodeLabel)); queueCapacities.getAbsoluteCapacity(nodeLabel));
if (!Resources.greaterThan(resourceCalculator, this.clusterResource, if (!Resources.greaterThan(resourceCalculator, totalPartitionResource,
availableToQueue, Resources.none())) { availableToQueue, Resources.none())) {
return 0.0f; return 0.0f;
} }
return return
Resources.divide(resourceCalculator, this.clusterResource, Resources.divide(resourceCalculator, totalPartitionResource,
queueUsage.getUsed(nodeLabel), availableToQueue); queueUsage.getUsed(nodeLabel), availableToQueue);
} }
@ -564,13 +565,13 @@ public abstract class AbstractCSQueue implements CSQueue {
* @return absolute used resources by this queue for specified label * @return absolute used resources by this queue for specified label
*/ */
public final synchronized float getAbsoluteUsedCapacity(final String nodeLabel) { public final synchronized float getAbsoluteUsedCapacity(final String nodeLabel) {
Resource labeledResources = Resource totalPartitionResource =
labelManager.getResourceByLabel(nodeLabel, this.clusterResource); labelManager.getResourceByLabel(nodeLabel, this.clusterResource);
if (!Resources.greaterThan(resourceCalculator, this.clusterResource, if (!Resources.greaterThan(resourceCalculator, totalPartitionResource,
labeledResources, Resources.none())) { totalPartitionResource, Resources.none())) {
return 0.0f; return 0.0f;
} }
return Resources.divide(resourceCalculator, this.clusterResource, return Resources.divide(resourceCalculator, totalPartitionResource,
queueUsage.getUsed(nodeLabel), labeledResources); queueUsage.getUsed(nodeLabel), totalPartitionResource);
} }
} }