From 37a82241010a949c0ac80d1379791e027a5dbace Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Mon, 8 Jan 2018 15:52:03 +0530 Subject: [PATCH] YARN-7699. queueUsagePercentage is coming as INF for getApp REST api call. Contributed by Sunil G. (cherry picked from commit 281350674c70d65233363849a8b60e9b7dc965cf) --- .../scheduler/common/fica/FiCaSchedulerApp.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java index cb6ff312406..1d91316f74f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java @@ -995,14 +995,17 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt { getAppAMNodePartitionName(), cluster); ResourceCalculator calc = rmContext.getScheduler().getResourceCalculator(); + float queueUsagePerc = 0.0f; if (!calc.isInvalidDivisor(totalPartitionRes)) { float queueAbsMaxCapPerPartition = ((AbstractCSQueue) getQueue()).getQueueCapacities() .getAbsoluteCapacity(getAppAMNodePartitionName()); - float queueUsagePerc = calc.divide(totalPartitionRes, - report.getUsedResources(), - Resources.multiply(totalPartitionRes, queueAbsMaxCapPerPartition)) - * 100; + if (queueAbsMaxCapPerPartition != 0) { + queueUsagePerc = calc.divide(totalPartitionRes, + report.getUsedResources(), + Resources.multiply(totalPartitionRes, queueAbsMaxCapPerPartition)) + * 100; + } report.setQueueUsagePercentage(queueUsagePerc); } return report;