YARN-9563. Resource report REST API could return NaN or Inf (Ahmed Hussein via jeagles)
Signed-off-by: Jonathan Eagles <jeagles@gmail.com>
This commit is contained in:
parent
3c63551101
commit
abf76ac371
|
@ -1125,9 +1125,10 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
|
||||||
if (!calc.isInvalidDivisor(cluster)) {
|
if (!calc.isInvalidDivisor(cluster)) {
|
||||||
float queueCapacityPerc = queue.getQueueInfo(false, false)
|
float queueCapacityPerc = queue.getQueueInfo(false, false)
|
||||||
.getCapacity();
|
.getCapacity();
|
||||||
if (queueCapacityPerc != 0) {
|
|
||||||
queueUsagePerc = calc.divide(cluster, usedResourceClone,
|
queueUsagePerc = calc.divide(cluster, usedResourceClone,
|
||||||
Resources.multiply(cluster, queueCapacityPerc)) * 100;
|
Resources.multiply(cluster, queueCapacityPerc)) * 100;
|
||||||
|
if (Float.isNaN(queueUsagePerc) || Float.isInfinite(queueUsagePerc)) {
|
||||||
|
queueUsagePerc = 0.0f;
|
||||||
}
|
}
|
||||||
clusterUsagePerc =
|
clusterUsagePerc =
|
||||||
calc.divide(cluster, usedResourceClone, cluster) * 100;
|
calc.divide(cluster, usedResourceClone, cluster) * 100;
|
||||||
|
|
|
@ -276,7 +276,7 @@ public class TestSchedulerApplicationAttempt {
|
||||||
assertEquals(60.0f,
|
assertEquals(60.0f,
|
||||||
app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
|
app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
|
||||||
|
|
||||||
queue = createQueue("test3", null, 0.0f);
|
queue = createQueue("test3", null, Float.MIN_VALUE);
|
||||||
app = new SchedulerApplicationAttempt(appAttId, user, queue,
|
app = new SchedulerApplicationAttempt(appAttId, user, queue,
|
||||||
queue.getAbstractUsersManager(), rmContext);
|
queue.getAbstractUsersManager(), rmContext);
|
||||||
|
|
||||||
|
|
|
@ -4039,6 +4039,16 @@ public class TestLeafQueue {
|
||||||
0.01f);
|
0.01f);
|
||||||
assertEquals(15.0f,
|
assertEquals(15.0f,
|
||||||
app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
|
app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
|
||||||
|
|
||||||
|
// test that queueUsagePercentage returns neither NaN nor Infinite
|
||||||
|
AbstractCSQueue zeroQueue = createQueue("test2.2", null,
|
||||||
|
Float.MIN_VALUE, Float.MIN_VALUE,
|
||||||
|
Resources.multiply(res, Float.MIN_VALUE));
|
||||||
|
app = new FiCaSchedulerApp(appAttId, user, zeroQueue,
|
||||||
|
qChild.getAbstractUsersManager(), rmContext);
|
||||||
|
app.getAppAttemptResourceUsage().incUsed(requestedResource);
|
||||||
|
assertEquals(0.0f, app.getResourceUsageReport().getQueueUsagePercentage(),
|
||||||
|
0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue