Search in sources :

Example 1 with ReservationAllocationState

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());
}
Also used : ReservationAllocationState(org.apache.hadoop.yarn.api.records.ReservationAllocationState) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) Date(java.util.Date) Test(org.junit.Test)

Example 2 with ReservationAllocationState

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());
}
Also used : ReservationAllocationState(org.apache.hadoop.yarn.api.records.ReservationAllocationState) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) Date(java.util.Date) Test(org.junit.Test)

Example 3 with ReservationAllocationState

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());
}
Also used : ReservationAllocationState(org.apache.hadoop.yarn.api.records.ReservationAllocationState) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) Date(java.util.Date) Test(org.junit.Test)

Example 4 with ReservationAllocationState

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;
}
Also used : ReservationListResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse) ReservationAllocationState(org.apache.hadoop.yarn.api.records.ReservationAllocationState) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationInterval(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationInterval) Plan(org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan) ReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)

Aggregations

ReservationAllocationState (org.apache.hadoop.yarn.api.records.ReservationAllocationState)4 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)4 Date (java.util.Date)3 Test (org.junit.Test)3 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)1 Plan (org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan)1 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)1 ReservationInterval (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationInterval)1