From 48aa23eb3b8439c0c039d3b310d29a55af4e6f9e 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. (cherry picked from commit c4581827a92d9715ad1f11eb4012e4d537bb4046) --- .../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 db62a895e6e..135f3486ceb 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 class DominantResourceCalculator extends ResourceCalculator { @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; } }