YARN-6082. Invalid REST api response for getApps since queueUsagePercentage is coming as INF. Contributed by Sunil G.
This commit is contained in:
parent
dc6ec97048
commit
0101267d9d
@ -1037,9 +1037,12 @@ public ApplicationResourceUsageReport getResourceUsageReport() {
|
|||||||
float queueUsagePerc = 0.0f;
|
float queueUsagePerc = 0.0f;
|
||||||
float clusterUsagePerc = 0.0f;
|
float clusterUsagePerc = 0.0f;
|
||||||
if (!calc.isInvalidDivisor(cluster)) {
|
if (!calc.isInvalidDivisor(cluster)) {
|
||||||
queueUsagePerc = calc.divide(cluster, usedResourceClone, Resources
|
float queueCapacityPerc = queue.getQueueInfo(false, false)
|
||||||
.multiply(cluster, queue.getQueueInfo(false, false).getCapacity()))
|
.getCapacity();
|
||||||
* 100;
|
if (queueCapacityPerc != 0) {
|
||||||
|
queueUsagePerc = calc.divide(cluster, usedResourceClone,
|
||||||
|
Resources.multiply(cluster, queueCapacityPerc)) * 100;
|
||||||
|
}
|
||||||
clusterUsagePerc = calc.divide(cluster, usedResourceClone, cluster)
|
clusterUsagePerc = calc.divide(cluster, usedResourceClone, cluster)
|
||||||
* 100;
|
* 100;
|
||||||
}
|
}
|
||||||
|
@ -227,6 +227,18 @@ public void testAppPercentages() throws Exception {
|
|||||||
0.01f);
|
0.01f);
|
||||||
assertEquals(60.0f,
|
assertEquals(60.0f,
|
||||||
app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
|
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
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user