YARN-9563. Resource report REST API could return NaN or Inf (Ahmed Hussein via jeagles)
Signed-off-by: Jonathan Eagles <jeagles@gmail.com>
(cherry picked from commit 9d63fc7ed6
)
This commit is contained in:
parent
2cbd7eb5b6
commit
dc4d7f69ce
|
@ -1037,9 +1037,10 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
|
|||
if (!calc.isInvalidDivisor(cluster)) {
|
||||
float queueCapacityPerc = queue.getQueueInfo(false, false)
|
||||
.getCapacity();
|
||||
if (queueCapacityPerc != 0) {
|
||||
queueUsagePerc = calc.divide(cluster, usedResourceClone,
|
||||
queueUsagePerc = calc.divide(cluster, usedResourceClone,
|
||||
Resources.multiply(cluster, queueCapacityPerc)) * 100;
|
||||
if (Float.isNaN(queueUsagePerc) || Float.isInfinite(queueUsagePerc)) {
|
||||
queueUsagePerc = 0.0f;
|
||||
}
|
||||
clusterUsagePerc = calc.divide(cluster, usedResourceClone, cluster)
|
||||
* 100;
|
||||
|
|
|
@ -1031,7 +1031,9 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
|
|||
Resources.multiply(totalPartitionRes, queueAbsMaxCapPerPartition))
|
||||
* 100;
|
||||
}
|
||||
report.setQueueUsagePercentage(queueUsagePerc);
|
||||
if (!(Float.isNaN(queueUsagePerc) || Float.isInfinite(queueUsagePerc))) {
|
||||
report.setQueueUsagePercentage(queueUsagePerc);
|
||||
}
|
||||
}
|
||||
return report;
|
||||
} finally {
|
||||
|
|
|
@ -3967,6 +3967,15 @@ public class TestLeafQueue {
|
|||
0.01f);
|
||||
assertEquals(15.0f,
|
||||
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);
|
||||
app = new FiCaSchedulerApp(appAttId, user, zeroQueue,
|
||||
qChild.getAbstractUsersManager(), rmContext);
|
||||
app.getAppAttemptResourceUsage().incUsed(requestedResource);
|
||||
assertEquals(0.0f, app.getResourceUsageReport().getQueueUsagePercentage(),
|
||||
0.01f);
|
||||
}
|
||||
|
||||
private ApplicationAttemptId createAppAttemptId(int appId, int attemptId) {
|
||||
|
|
Loading…
Reference in New Issue