From c4581827a92d9715ad1f11eb4012e4d537bb4046 Mon Sep 17 00:00:00 2001 From: Jim Brennan Date: Tue, 25 May 2021 18:07:28 +0000 Subject: [PATCH] YARN-10691. DominantResourceCalculator isInvalidDivisor should consider only countable resource types. Contributed by Bilwa S T. --- .../yarn/util/resource/DominantResourceCalculator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/DominantResourceCalculator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/DominantResourceCalculator.java index db62a895e6..135f3486ce 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/DominantResourceCalculator.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/DominantResourceCalculator.java @@ -380,8 +380,9 @@ public float divide(Resource clusterResource, @Override public boolean isInvalidDivisor(Resource r) { - for (ResourceInformation res : r.getResources()) { - if (res.getValue() == 0L) { + int maxLength = ResourceUtils.getNumberOfCountableResourceTypes(); + for (int i = 0; i < maxLength; i++) { + if (r.getResourceInformation(i).getValue() == 0L) { return true; } }