YARN-4525. Fix bug in RLESparseResourceAllocation.getRangeOverlapping(). (Ishai Menache and Carlo Curino via asuresh)
This commit is contained in:
parent
7a9b7372a1
commit
3a154f75ed
|
@ -510,8 +510,12 @@ public class RLESparseResourceAllocation {
|
||||||
long previous = a.floorKey(start);
|
long previous = a.floorKey(start);
|
||||||
a = a.tailMap(previous, true);
|
a = a.tailMap(previous, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (end < a.lastKey()) {
|
||||||
a = a.headMap(end, true);
|
a = a.headMap(end, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
RLESparseResourceAllocation ret =
|
RLESparseResourceAllocation ret =
|
||||||
new RLESparseResourceAllocation(a, resourceCalculator);
|
new RLESparseResourceAllocation(a, resourceCalculator);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -282,6 +282,28 @@ public class TestRLESparseResourceAllocation {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRangeOverlapping() {
|
||||||
|
ResourceCalculator resCalc = new DefaultResourceCalculator();
|
||||||
|
|
||||||
|
RLESparseResourceAllocation r =
|
||||||
|
new RLESparseResourceAllocation(resCalc);
|
||||||
|
int[] alloc = {10, 10, 10, 10, 10, 10};
|
||||||
|
int start = 100;
|
||||||
|
Set<Entry<ReservationInterval, Resource>> inputs =
|
||||||
|
generateAllocation(start, alloc, false).entrySet();
|
||||||
|
for (Entry<ReservationInterval, Resource> ip : inputs) {
|
||||||
|
r.addInterval(ip.getKey(), ip.getValue());
|
||||||
|
}
|
||||||
|
long s = r.getEarliestStartTime();
|
||||||
|
long d = r.getLatestNonNullTime();
|
||||||
|
|
||||||
|
// tries to trigger "out-of-range" bug
|
||||||
|
r = r.getRangeOverlapping(s, d);
|
||||||
|
r = r.getRangeOverlapping(s-1, d-1);
|
||||||
|
r = r.getRangeOverlapping(s+1, d+1);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBlocks() {
|
public void testBlocks() {
|
||||||
ResourceCalculator resCalc = new DefaultResourceCalculator();
|
ResourceCalculator resCalc = new DefaultResourceCalculator();
|
||||||
|
|
Loading…
Reference in New Issue