private void decrementAllocation(ReservationAllocation reservation) { assert (readWriteLock.isWriteLockedByCurrentThread()); Map<ReservationInterval, ReservationRequest> allocationRequests = reservation.getAllocationRequests(); String user = reservation.getUser(); RLESparseResourceAllocation resAlloc = userResourceAlloc.get(user); for (Map.Entry<ReservationInterval, ReservationRequest> r : allocationRequests .entrySet()) { resAlloc.removeInterval(r.getKey(), r.getValue()); rleSparseVector.removeInterval(r.getKey(), r.getValue()); } if (resAlloc.isEmpty()) { userResourceAlloc.remove(user); } }
private void decrementAllocation(ReservationAllocation reservation) { assert (readWriteLock.isWriteLockedByCurrentThread()); Map<ReservationInterval, ReservationRequest> allocationRequests = reservation.getAllocationRequests(); String user = reservation.getUser(); RLESparseResourceAllocation resAlloc = userResourceAlloc.get(user); for (Map.Entry<ReservationInterval, ReservationRequest> r : allocationRequests .entrySet()) { resAlloc.removeInterval(r.getKey(), r.getValue()); rleSparseVector.removeInterval(r.getKey(), r.getValue()); } if (resAlloc.isEmpty()) { userResourceAlloc.remove(user); } }
private void incrementAllocation(ReservationAllocation reservation) { assert (readWriteLock.isWriteLockedByCurrentThread()); Map<ReservationInterval, ReservationRequest> allocationRequests = reservation.getAllocationRequests(); // check if we have encountered the user earlier and if not add an entry String user = reservation.getUser(); RLESparseResourceAllocation resAlloc = userResourceAlloc.get(user); if (resAlloc == null) { resAlloc = new RLESparseResourceAllocation(resCalc, minAlloc); userResourceAlloc.put(user, resAlloc); } for (Map.Entry<ReservationInterval, ReservationRequest> r : allocationRequests .entrySet()) { resAlloc.addInterval(r.getKey(), r.getValue()); rleSparseVector.addInterval(r.getKey(), r.getValue()); } }
private void incrementAllocation(ReservationAllocation reservation) { assert (readWriteLock.isWriteLockedByCurrentThread()); Map<ReservationInterval, ReservationRequest> allocationRequests = reservation.getAllocationRequests(); // check if we have encountered the user earlier and if not add an entry String user = reservation.getUser(); RLESparseResourceAllocation resAlloc = userResourceAlloc.get(user); if (resAlloc == null) { resAlloc = new RLESparseResourceAllocation(resCalc, minAlloc); userResourceAlloc.put(user, resAlloc); } for (Map.Entry<ReservationInterval, ReservationRequest> r : allocationRequests .entrySet()) { resAlloc.addInterval(r.getKey(), r.getValue()); rleSparseVector.addInterval(r.getKey(), r.getValue()); } }
public static List<ReservationAllocationState> convertAllocationsToReservationInfo(Set<ReservationAllocation> res, boolean includeResourceAllocations) { List<ReservationAllocationState> reservationInfo = new ArrayList<>(); Map<ReservationInterval, Resource> requests; for (ReservationAllocation allocation : res) { List<ResourceAllocationRequest> allocations = new ArrayList<>(); if (includeResourceAllocations) { requests = allocation.getAllocationRequests(); for (Map.Entry<ReservationInterval, Resource> request : requests.entrySet()) { ReservationInterval interval = request.getKey(); allocations.add(ResourceAllocationRequest.newInstance( interval.getStartTime(), interval.getEndTime(), request.getValue())); } } reservationInfo.add(ReservationAllocationState.newInstance( allocation.getAcceptanceTime(), allocation.getUser(), allocations, allocation.getReservationId(), allocation.getReservationDefinition())); } return reservationInfo; } }
private void decrementAllocation(ReservationAllocation reservation) { assert (readWriteLock.isWriteLockedByCurrentThread()); Map<ReservationInterval, Resource> allocationRequests = reservation.getAllocationRequests(); String user = reservation.getUser(); long period = reservation.getPeriodicity();
private void incrementAllocation(ReservationAllocation reservation) { assert (readWriteLock.isWriteLockedByCurrentThread()); Map<ReservationInterval, Resource> allocationRequests = reservation.getAllocationRequests();
public static ReservationAllocationStateProto buildStateProto( ReservationAllocation allocation) { ReservationAllocationStateProto.Builder builder = ReservationAllocationStateProto.newBuilder(); builder.setAcceptanceTime(allocation.getAcceptanceTime()); builder.setContainsGangs(allocation.containsGangs()); builder.setStartTime(allocation.getStartTime()); builder.setEndTime(allocation.getEndTime()); builder.setUser(allocation.getUser()); ReservationDefinitionProto definitionProto = convertToProtoFormat( allocation.getReservationDefinition()); builder.setReservationDefinition(definitionProto); for (Map.Entry<ReservationInterval, Resource> entry : allocation.getAllocationRequests().entrySet()) { ResourceAllocationRequestProto p = ResourceAllocationRequestProto.newBuilder() .setStartTime(entry.getKey().getStartTime()) .setEndTime(entry.getKey().getEndTime()) .setResource(convertToProtoFormat(entry.getValue())) .build(); builder.addAllocationRequests(p); } ReservationAllocationStateProto allocationProto = builder.build(); return allocationProto; }
private void doAssertions(ReservationAllocation rAllocation, ReservationId reservationID, ReservationDefinition rDef, Map<ReservationInterval, ReservationRequest> allocations, int start, int[] alloc) { Assert.assertEquals(reservationID, rAllocation.getReservationId()); Assert.assertEquals(rDef, rAllocation.getReservationDefinition()); Assert.assertEquals(allocations, rAllocation.getAllocationRequests()); Assert.assertEquals(user, rAllocation.getUser()); Assert.assertEquals(planName, rAllocation.getPlanName()); Assert.assertEquals(start, rAllocation.getStartTime()); Assert.assertEquals(start + alloc.length + 1, rAllocation.getEndTime()); }
private void doAssertions(ReservationAllocation rAllocation, ReservationId reservationID, ReservationDefinition rDef, Map<ReservationInterval, Resource> allocations, int start, int[] alloc) { Assert.assertEquals(reservationID, rAllocation.getReservationId()); Assert.assertEquals(rDef, rAllocation.getReservationDefinition()); Assert.assertEquals(allocations, rAllocation.getAllocationRequests()); Assert.assertEquals(user, rAllocation.getUser()); Assert.assertEquals(planName, rAllocation.getPlanName()); Assert.assertEquals(start, rAllocation.getStartTime()); Assert.assertEquals(start + alloc.length + 1, rAllocation.getEndTime()); }
void assertAllocationStateEqual( ReservationAllocation expected, ReservationAllocationStateProto actual) { Assert.assertEquals( expected.getAcceptanceTime(), actual.getAcceptanceTime()); Assert.assertEquals(expected.getStartTime(), actual.getStartTime()); Assert.assertEquals(expected.getEndTime(), actual.getEndTime()); Assert.assertEquals(expected.containsGangs(), actual.getContainsGangs()); Assert.assertEquals(expected.getUser(), actual.getUser()); assertEquals( expected.getReservationDefinition(), ReservationSystemUtil.convertFromProtoFormat( actual.getReservationDefinition())); assertEquals( expected.getAllocationRequests(), ReservationSystemUtil.toAllocations( actual.getAllocationRequestsList())); } }