use of org.apache.hadoop.yarn.api.records.ReservationAllocationState in project hadoop by apache.
the class TestReservationSystemUtil method testConvertAllocationsToReservationInfoNoAllocations.
@Test
public void testConvertAllocationsToReservationInfoNoAllocations() {
long startTime = new Date().getTime();
long step = 10000;
int[] alloc = { 10, 10, 10 };
ReservationId id = ReservationSystemTestUtil.getNewReservationId();
ReservationAllocation allocation = createReservationAllocation(startTime, startTime + 10 * step, step, alloc, id, createResource(4000, 2));
List<ReservationAllocationState> infoList = ReservationSystemUtil.convertAllocationsToReservationInfo(Collections.singleton(allocation), false);
Assert.assertEquals(infoList.size(), 1);
Assert.assertEquals(infoList.get(0).getReservationId().toString(), id.toString());
Assert.assertTrue(infoList.get(0).getResourceAllocationRequests().isEmpty());
}
use of org.apache.hadoop.yarn.api.records.ReservationAllocationState in project hadoop by apache.
the class TestReservationSystemUtil method testConvertAllocationsToReservationInfo.
@Test
public void testConvertAllocationsToReservationInfo() {
long startTime = new Date().getTime();
long step = 10000;
int[] alloc = { 10, 10, 10 };
ReservationId id = ReservationSystemTestUtil.getNewReservationId();
ReservationAllocation allocation = createReservationAllocation(startTime, startTime + 10 * step, step, alloc, id, createResource(4000, 2));
List<ReservationAllocationState> infoList = ReservationSystemUtil.convertAllocationsToReservationInfo(Collections.singleton(allocation), true);
Assert.assertEquals(infoList.size(), 1);
Assert.assertEquals(infoList.get(0).getReservationId().toString(), id.toString());
Assert.assertFalse(infoList.get(0).getResourceAllocationRequests().isEmpty());
}
use of org.apache.hadoop.yarn.api.records.ReservationAllocationState in project hadoop by apache.
the class TestReservationSystemUtil method testConvertAllocationsToReservationInfoEmptyAllocations.
@Test
public void testConvertAllocationsToReservationInfoEmptyAllocations() {
long startTime = new Date().getTime();
long step = 10000;
int[] alloc = {};
ReservationId id = ReservationSystemTestUtil.getNewReservationId();
ReservationAllocation allocation = createReservationAllocation(startTime, startTime + 10 * step, step, alloc, id, createResource(4000, 2));
List<ReservationAllocationState> infoList = ReservationSystemUtil.convertAllocationsToReservationInfo(Collections.singleton(allocation), false);
Assert.assertEquals(infoList.size(), 1);
Assert.assertEquals(infoList.get(0).getReservationId().toString(), id.toString());
Assert.assertTrue(infoList.get(0).getResourceAllocationRequests().isEmpty());
}
use of org.apache.hadoop.yarn.api.records.ReservationAllocationState in project hadoop by apache.
the class ClientRMService method listReservations.
@Override
public ReservationListResponse listReservations(ReservationListRequest requestInfo) throws YarnException, IOException {
// Check if reservation system is enabled
checkReservationSytem(AuditConstants.LIST_RESERVATION_REQUEST);
ReservationListResponse response = recordFactory.newRecordInstance(ReservationListResponse.class);
Plan plan = rValidator.validateReservationListRequest(reservationSystem, requestInfo);
boolean includeResourceAllocations = requestInfo.getIncludeResourceAllocations();
ReservationId reservationId = null;
if (requestInfo.getReservationId() != null && !requestInfo.getReservationId().isEmpty()) {
reservationId = ReservationId.parseReservationId(requestInfo.getReservationId());
}
checkReservationACLs(requestInfo.getQueue(), AuditConstants.LIST_RESERVATION_REQUEST, reservationId);
long startTime = Math.max(requestInfo.getStartTime(), 0);
long endTime = requestInfo.getEndTime() <= -1 ? Long.MAX_VALUE : requestInfo.getEndTime();
Set<ReservationAllocation> reservations;
reservations = plan.getReservations(reservationId, new ReservationInterval(startTime, endTime));
List<ReservationAllocationState> info = ReservationSystemUtil.convertAllocationsToReservationInfo(reservations, includeResourceAllocations);
response.setReservationAllocationState(info);
return response;
}
Aggregations