From 679f99b1455a1fcd785aef8ddc705f63cf0e6518 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) --- .../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 ca828a5251..6b284e34f8 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 boolean fitsIn(Resource smaller, Resource bigger) { @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; } }