YARN-6984. DominantResourceCalculator.isAnyMajorResourceZero() should test all resources

(Contributed by Sunil G via Daniel Templeton)

(cherry picked from commit 679f99b145)
This commit is contained in:
Daniel Templeton 2017-10-24 10:04:36 -07:00
parent 0bc3c9fca2
commit 2041448a9d
1 changed files with 9 additions and 1 deletions

View File

@ -557,6 +557,14 @@ public class DominantResourceCalculator extends ResourceCalculator {
@Override @Override
public boolean isAnyMajorResourceZero(Resource resource) { 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;
} }
} }