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

(cherry picked from commit 7a9b7372a1a917c7b5e1beca7e13c0419e3dbfef)
(cherry picked from commit f0a869b52a4e4ad7e02143a7e703700a4f4b1f88)
This commit is contained in:
Arun Suresh 2016-06-06 21:06:52 -07:00
parent 0274636529
commit 934bd8989b

View File

@ -168,12 +168,20 @@ public Map<ReservationInterval, Resource> computeStageAllocation(Plan plan,
if (allocateLeft) { if (allocateLeft) {
// set earliest start to the min of the constraining "range" or my the // set earliest start to the min of the constraining "range" or my the
// end of this allocation // end of this allocation
stageEarliestStart = if(partialMap.higherKey(minPoint) == null){
Math.min(partialMap.higherKey(minPoint), stageEarliestStart + dur); stageEarliestStart = stageEarliestStart + dur;
} else {
stageEarliestStart =
Math.min(partialMap.higherKey(minPoint), stageEarliestStart + dur);
}
} else { } else {
// same as above moving right-to-left // same as above moving right-to-left
stageDeadline = if(partialMap.higherKey(minPoint) == null){
Math.max(partialMap.higherKey(minPoint), stageDeadline - dur); stageDeadline = stageDeadline - dur;
} else {
stageDeadline =
Math.max(partialMap.higherKey(minPoint), stageDeadline - dur);
}
} }
} }