YARN-5185. StageAllocaterGreedyRLE: Fix NPE in corner case. (Carlo Curino via asuresh)

(cherry picked from commit 7a9b7372a1)
This commit is contained in:
Arun Suresh 2016-06-06 21:06:52 -07:00
parent 06e38c835d
commit f0a869b52a
1 changed files with 12 additions and 4 deletions

View File

@ -168,14 +168,22 @@ public class StageAllocatorGreedyRLE implements StageAllocator {
if (allocateLeft) {
// set earliest start to the min of the constraining "range" or my the
// end of this allocation
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
if(partialMap.higherKey(minPoint) == null){
stageDeadline = stageDeadline - dur;
} else {
stageDeadline =
Math.max(partialMap.higherKey(minPoint), stageDeadline - dur);
}
}
}
// if no gangs are left to place we succeed and return the allocation
if (gangsToPlace == 0) {