Search in sources :

Example 6 with ReservationListRequest

use of org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest in project hadoop by apache.

the class TestClientRMService method testListReservationsByTimeInterval.

@Test
public void testListReservationsByTimeInterval() {
    ResourceManager rm = setupResourceManager();
    ClientRMService clientService = rm.getClientRMService();
    Clock clock = new UTCClock();
    long arrival = clock.getTime();
    long duration = 60000;
    long deadline = (long) (arrival + 1.05 * duration);
    ReservationSubmissionRequest sRequest = submitReservationTestHelper(clientService, arrival, deadline, duration);
    // List reservations, search by a point in time within the reservation
    // range.
    arrival = clock.getTime();
    ReservationId reservationID = sRequest.getReservationId();
    ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", arrival + duration / 2, arrival + duration / 2, true);
    ReservationListResponse response = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertEquals(1, response.getReservationAllocationState().size());
    Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
    // List reservations, search by time within reservation interval.
    request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, Long.MAX_VALUE, true);
    response = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertEquals(1, response.getReservationAllocationState().size());
    Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
    // Verify that the full resource allocations exist.
    Assert.assertTrue(response.getReservationAllocationState().get(0).getResourceAllocationRequests().size() > 0);
    // Verify that the full RDL is returned.
    ReservationRequests reservationRequests = response.getReservationAllocationState().get(0).getReservationDefinition().getReservationRequests();
    Assert.assertTrue(reservationRequests.getInterpreter().toString().equals("R_ALL"));
    Assert.assertTrue(reservationRequests.getReservationResources().get(0).getDuration() == duration);
    rm.stop();
}
Also used : ReservationListResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) UTCClock(org.apache.hadoop.yarn.util.UTCClock) Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) IOException(java.io.IOException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) AccessControlException(java.security.AccessControlException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 7 with ReservationListRequest

use of org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest in project hadoop by apache.

the class ReservationACLsTestBase method listReservation.

private ReservationListResponse listReservation(String lister, String queueName) throws Exception {
    final ReservationListRequest listRequest = ReservationListRequest.newInstance(queueName, null, -1, -1, false);
    ApplicationClientProtocol ownerClient = getRMClientForUser(lister);
    return ownerClient.listReservations(listRequest);
}
Also used : ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol)

Example 8 with ReservationListRequest

use of org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest in project hadoop by apache.

the class TestYarnClient method testListReservationsByInvalidTimeInterval.

@Test
public void testListReservationsByInvalidTimeInterval() throws Exception {
    MiniYARNCluster cluster = setupMiniYARNCluster();
    YarnClient client = setupYarnClient(cluster);
    try {
        Clock clock = new UTCClock();
        long arrival = clock.getTime();
        long duration = 60000;
        long deadline = (long) (arrival + 1.05 * duration);
        ReservationSubmissionRequest sRequest = submitReservationTestHelper(client, arrival, deadline, duration);
        // List reservations, search by invalid end time == -1.
        ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, -1, true);
        ReservationListResponse response = client.listReservations(request);
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getReservationAllocationState().size());
        Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), sRequest.getReservationId().getId());
        // List reservations, search by invalid end time < -1.
        request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, -10, true);
        response = client.listReservations(request);
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getReservationAllocationState().size());
        Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), sRequest.getReservationId().getId());
    } finally {
        // clean-up
        if (client != null) {
            client.stop();
        }
        cluster.stop();
    }
}
Also used : ReservationListResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse) ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster) UTCClock(org.apache.hadoop.yarn.util.UTCClock) Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) Test(org.junit.Test)

Example 9 with ReservationListRequest

use of org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest in project hadoop by apache.

the class TestReservationInputValidator method testListReservationsInvalidTimeInterval.

@Test
public void testListReservationsInvalidTimeInterval() {
    ReservationListRequest request = new ReservationListRequestPBImpl();
    request.setQueue(ReservationSystemTestUtil.reservationQ);
    request.setEndTime(1000);
    request.setStartTime(2000);
    when(rSystem.getPlan(ReservationSystemTestUtil.reservationQ)).thenReturn(this.plan);
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationListRequest(rSystem, request);
        Assert.fail();
    } catch (YarnException e) {
        Assert.assertNull(plan);
        String message = e.getMessage();
        Assert.assertTrue(message.equals("The specified end time must be " + "greater than the specified start time."));
        LOG.info(message);
    }
}
Also used : ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ReservationListRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationListRequestPBImpl) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 10 with ReservationListRequest

use of org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest in project hadoop by apache.

the class TestReservationInputValidator method testListReservationsNormal.

@Test
public void testListReservationsNormal() {
    ReservationListRequest request = new ReservationListRequestPBImpl();
    request.setQueue(ReservationSystemTestUtil.reservationQ);
    request.setEndTime(1000);
    request.setStartTime(0);
    when(rSystem.getPlan(ReservationSystemTestUtil.reservationQ)).thenReturn(this.plan);
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationListRequest(rSystem, request);
    } catch (YarnException e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(plan);
}
Also used : ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ReservationListRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationListRequestPBImpl) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Aggregations

ReservationListRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest)18 Test (org.junit.Test)15 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)11 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)11 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)10 Clock (org.apache.hadoop.yarn.util.Clock)10 UTCClock (org.apache.hadoop.yarn.util.UTCClock)10 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)6 IOException (java.io.IOException)5 AccessControlException (java.security.AccessControlException)5 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)5 ReservationListRequestPBImpl (org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationListRequestPBImpl)5 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)5 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)5 MiniYARNCluster (org.apache.hadoop.yarn.server.MiniYARNCluster)5 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)2 ReservationDeleteRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest)2 ReservationDeleteResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse)2 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1