netAvailableResources.getCumulative();
public PeriodicRLESparseResourceAllocation( RLESparseResourceAllocation rleVector, Long timePeriod) { super(rleVector.getCumulative(), rleVector.getResourceCalculator()); this.timePeriod = timePeriod;
/** * Merges the range start to end of two {@code RLESparseResourceAllocation} * using a given {@code RLEOperator}. * * @param resCalc the resource calculator * @param clusterResource the total cluster resources (for DRF) * @param a the left operand * @param b the right operand * @param operator the operator to be applied during merge * @param start the start-time of the range to be considered * @param end the end-time of the range to be considered * @return the a merged RLESparseResourceAllocation, produced by applying * "operator" to "a" and "b" * @throws PlanningException in case the operator is subtractTestPositive and * the result would contain a negative value */ public static RLESparseResourceAllocation merge(ResourceCalculator resCalc, Resource clusterResource, RLESparseResourceAllocation a, RLESparseResourceAllocation b, RLEOperator operator, long start, long end) throws PlanningException { NavigableMap<Long, Resource> cumA = a.getRangeOverlapping(start, end).getCumulative(); NavigableMap<Long, Resource> cumB = b.getRangeOverlapping(start, end).getCumulative(); NavigableMap<Long, Resource> out = merge(resCalc, clusterResource, cumA, cumB, start, end, operator); return new RLESparseResourceAllocation(out, resCalc); }
/** * Get the minimum capacity in the specified time range. * * @param interval the {@link ReservationInterval} to be searched * @return minimum resource allocation */ public Resource getMinimumCapacityInInterval(ReservationInterval interval) { Resource minCapacity = Resource.newInstance(Integer.MAX_VALUE, Integer.MAX_VALUE); long start = interval.getStartTime(); long end = interval.getEndTime(); NavigableMap<Long, Resource> capacityRange = getRangeOverlapping(start, end).getCumulative(); if (!capacityRange.isEmpty()) { for (Map.Entry<Long, Resource> entry : capacityRange.entrySet()) { if (entry.getValue() != null) { minCapacity = Resources.componentwiseMin(minCapacity, entry.getValue()); } } } return minCapacity; }
NavigableMap<Long, Resource> mapCurrentLoad = currentLoad.getCumulative();
public static Map<ReservationInterval, Resource> toAllocation( RLESparseResourceAllocation rle, long start, long end) { Map<ReservationInterval, Resource> resAlloc = new TreeMap<>(); for (Map.Entry<Long, Resource> e : rle.getCumulative().entrySet()) { Long nextKey = rle.getCumulative().higherKey(e.getKey()); if (nextKey == null) { break; } else { if (e.getKey() >= start && e.getKey() <= end && nextKey >= start && nextKey <= end) { resAlloc.put(new ReservationInterval(e.getKey(), nextKey), e.getValue()); } } } return resAlloc; }
readLock.lock(); try { NavigableMap<Long, Resource> a = this.getCumulative(); if (a != null && !a.isEmpty()) {
private void validate(RLESparseResourceAllocation out, long[] time, int[] alloc) { int i = 0; for (Entry<Long, Resource> res : out.getCumulative().entrySet()) { assertEquals(time[i], ((long) res.getKey())); if (i > alloc.length - 1) { assertNull(res.getValue()); } else { assertEquals(alloc[i], res.getValue().getVirtualCores()); } i++; } assertEquals(time.length, i); }
NavigableMap<Long, Resource> availableMap = available.getCumulative();
for (Map.Entry<Long, Resource> pointToCheck : toCheck.getCumulative() .entrySet()) { Resource resourceToCheck = pointToCheck.getValue(); Long nextPoint = toCheck.getCumulative().higherKey(timeToCheck); if (nextPoint == null || toCheck.getCumulative().get(nextPoint) == null) { continue; temp.putAll(toCheck.getCumulative());