From c818c85238b91407e41f3b29a888394170ff447a Mon Sep 17 00:00:00 2001 From: Daniel Templeton Date: Tue, 24 Oct 2017 10:04:36 -0700 Subject: [PATCH] YARN-6984. DominantResourceCalculator.isAnyMajorResourceZero() should test all resources (Contributed by Sunil G via Daniel Templeton) (cherry picked from commit 679f99b1455a1fcd785aef8ddc705f63cf0e6518) --- .../yarn/util/resource/DominantResourceCalculator.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 ca828a5251b..6b284e34f80 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 @@ -557,6 +557,14 @@ public class DominantResourceCalculator extends ResourceCalculator { @Override public boolean isAnyMajorResourceZero(Resource resource) { - return resource.getMemorySize() == 0f || resource.getVirtualCores() == 0; + int maxLength = ResourceUtils.getNumberOfKnownResourceTypes(); + for (int i = 0; i < maxLength; i++) { + ResourceInformation resourceInformation = resource + .getResourceInformation(i); + if (resourceInformation.getValue() == 0L) { + return true; + } + } + return false; } }