Search in sources :

Example 11 with ReservationListRequest

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

the class TestReservationInputValidator method testListReservationsInvalidTimeIntervalDefaults.

@Test
public void testListReservationsInvalidTimeIntervalDefaults() {
    ReservationListRequest request = new ReservationListRequestPBImpl();
    request.setQueue(ReservationSystemTestUtil.reservationQ);
    // Negative time gets converted to default values for Start Time and End
    // Time which are 0 and Long.MAX_VALUE respectively.
    request.setEndTime(-2);
    request.setStartTime(-1);
    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)

Example 12 with ReservationListRequest

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

the class TestReservationInputValidator method testListReservationsNullPlan.

@Test
public void testListReservationsNullPlan() {
    ReservationListRequest request = new ReservationListRequestPBImpl();
    request.setQueue(ReservationSystemTestUtil.reservationQ);
    when(rSystem.getPlan(ReservationSystemTestUtil.reservationQ)).thenReturn(null);
    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 queue: " + ReservationSystemTestUtil.reservationQ + " is not managed by reservation system." + " Please try again with a valid reservable queue."));
        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 13 with ReservationListRequest

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

the class TestReservationInputValidator method testListReservationsEmptyQueue.

@Test
public void testListReservationsEmptyQueue() {
    ReservationListRequest request = new ReservationListRequestPBImpl();
    request.setQueue("");
    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 queue is not specified. Please try again with a valid " + "reservable queue."));
        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 14 with ReservationListRequest

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

the class ReservationACLsTestBase method listReservationById.

private ReservationListResponse listReservationById(String lister, ReservationId reservationId, String queueName) throws Exception {
    final ReservationListRequest listRequest = ReservationListRequest.newInstance(queueName, reservationId.toString(), -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 15 with ReservationListRequest

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

the class TestClientRMService method testReservationDelete.

@Test
public void testReservationDelete() {
    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);
    ReservationId reservationID = sRequest.getReservationId();
    // Delete the reservation
    ReservationDeleteRequest dRequest = ReservationDeleteRequest.newInstance(reservationID);
    ReservationDeleteResponse dResponse = null;
    try {
        dResponse = clientService.deleteReservation(dRequest);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(dResponse);
    System.out.println("Delete reservation response: " + dResponse);
    // List reservations, search by non-existent reservationID
    ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, reservationID.toString(), -1, -1, false);
    ReservationListResponse response = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertEquals(0, response.getReservationAllocationState().size());
    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) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ReservationDeleteResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse) ReservationDeleteRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest) 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)

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