YARN-6082. Invalid REST api response for getApps since queueUsagePercentage is coming as INF. Contributed by Sunil G.
(cherry picked from commit 0101267d9d
)
This commit is contained in:
parent
94b326f2c8
commit
26c4cfb653
|
@ -901,9 +901,12 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
|
|||
float queueUsagePerc = 0.0f;
|
||||
float clusterUsagePerc = 0.0f;
|
||||
if (!calc.isInvalidDivisor(cluster)) {
|
||||
queueUsagePerc = calc.divide(cluster, usedResourceClone, Resources
|
||||
.multiply(cluster, queue.getQueueInfo(false, false).getCapacity()))
|
||||
* 100;
|
||||
float queueCapacityPerc = queue.getQueueInfo(false, false)
|
||||
.getCapacity();
|
||||
if (queueCapacityPerc != 0) {
|
||||
queueUsagePerc = calc.divide(cluster, usedResourceClone,
|
||||
Resources.multiply(cluster, queueCapacityPerc)) * 100;
|
||||
}
|
||||
clusterUsagePerc = calc.divide(cluster, usedResourceClone, cluster)
|
||||
* 100;
|
||||
}
|
||||
|
|
|
@ -228,6 +228,18 @@ public class TestSchedulerApplicationAttempt {
|
|||
0.01f);
|
||||
assertEquals(60.0f,
|
||||
app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
|
||||
|
||||
queue = createQueue("test3", null, 0.0f);
|
||||
app = new SchedulerApplicationAttempt(appAttId, user, queue,
|
||||
queue.getActiveUsersManager(), rmContext);
|
||||
|
||||
// Resource request
|
||||
app.attemptResourceUsage.incUsed(requestedResource);
|
||||
|
||||
assertEquals(0.0f, app.getResourceUsageReport().getQueueUsagePercentage(),
|
||||
0.01f);
|
||||
assertEquals(15.0f,
|
||||
app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue