diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/reservation/planning/StageAllocatorGreedyRLE.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/reservation/planning/StageAllocatorGreedyRLE.java index c5a3192625c..5e748fc5553 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/reservation/planning/StageAllocatorGreedyRLE.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/reservation/planning/StageAllocatorGreedyRLE.java @@ -168,12 +168,20 @@ public class StageAllocatorGreedyRLE implements StageAllocator { if (allocateLeft) { // set earliest start to the min of the constraining "range" or my the // end of this allocation - stageEarliestStart = - Math.min(partialMap.higherKey(minPoint), stageEarliestStart + dur); + if(partialMap.higherKey(minPoint) == null){ + stageEarliestStart = stageEarliestStart + dur; + } else { + stageEarliestStart = + Math.min(partialMap.higherKey(minPoint), stageEarliestStart + dur); + } } else { // same as above moving right-to-left - stageDeadline = - Math.max(partialMap.higherKey(minPoint), stageDeadline - dur); + if(partialMap.higherKey(minPoint) == null){ + stageDeadline = stageDeadline - dur; + } else { + stageDeadline = + Math.max(partialMap.higherKey(minPoint), stageDeadline - dur); + } } }