@Override public long getLastEndTime() { readLock.lock(); try { return rleSparseVector.getLatestNonNullTime(); } finally { readLock.unlock(); } }
protected static boolean validateOrderNoGap( RLESparseResourceAllocation allocations, Map<ReservationInterval, Resource> curAlloc, boolean allocateLeft) { // Left to right if (allocateLeft) { Long stageStartTime = findEarliestTime(curAlloc); Long allocationEndTime = allocations.getLatestNonNullTime(); // Check that there is no gap between stages if ((allocationEndTime != -1) && (allocationEndTime < stageStartTime)) { return false; } // Right to left } else { Long stageEndTime = findLatestTime(curAlloc); Long allocationStartTime = allocations.getEarliestStartTime(); // Check that there is no gap between stages if ((allocationStartTime != -1) && (stageEndTime < allocationStartTime)) { return false; } } // Check that the stage allocation does not violate ORDER_NO_GAP if (!isNonPreemptiveAllocation(curAlloc)) { return false; } // The allocation is legal return true; }
Long allocationEndTime = allocations.getLatestNonNullTime(); if (allocationEndTime != -1) { stageArrival = allocationEndTime;
@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); }