Search in sources :

Example 26 with ReservationSubmissionRequest

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

the class TestClientRMService method testListReservationsByReservationId.

@Test
public void testListReservationsByReservationId() {
    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();
    ReservationListResponse response = null;
    ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, reservationID.toString(), -1, -1, false);
    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());
    Assert.assertEquals(response.getReservationAllocationState().get(0).getResourceAllocationRequests().size(), 0);
    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) 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 27 with ReservationSubmissionRequest

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

the class TestReservationInputValidator method testSubmitReservationNoDefinition.

@Test
public void testSubmitReservationNoDefinition() {
    ReservationSubmissionRequest request = new ReservationSubmissionRequestPBImpl();
    request.setQueue(PLAN_NAME);
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationSubmissionRequest(rSystem, request, ReservationSystemTestUtil.getNewReservationId());
        Assert.fail();
    } catch (YarnException e) {
        Assert.assertNull(plan);
        String message = e.getMessage();
        Assert.assertTrue(message.equals("Missing reservation definition. Please try again by specifying a reservation definition."));
        LOG.info(message);
    }
}
Also used : ReservationSubmissionRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationSubmissionRequestPBImpl) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 28 with ReservationSubmissionRequest

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

the class ReservationSystemTestUtil method createSimpleReservationRequest.

public static ReservationSubmissionRequest createSimpleReservationRequest(ReservationId reservationId, int numContainers, long arrival, long deadline, long duration, Priority priority) {
    // create a request with a single atomic ask
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), numContainers, 1, duration);
    ReservationRequests reqs = ReservationRequests.newInstance(Collections.singletonList(r), ReservationRequestInterpreter.R_ALL);
    ReservationDefinition rDef = ReservationDefinition.newInstance(arrival, deadline, reqs, "testClientRMService#reservation", "0", priority);
    ReservationSubmissionRequest request = ReservationSubmissionRequest.newInstance(rDef, reservationQ, reservationId);
    return request;
}
Also used : ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)

Example 29 with ReservationSubmissionRequest

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

the class TestReservationInputValidator method testSubmitReservationNegativeRecurrenceExpression.

@Test
public void testSubmitReservationNegativeRecurrenceExpression() {
    ReservationSubmissionRequest request = createSimpleReservationSubmissionRequest(1, 1, 1, 5, 3, "-1234");
    plan = null;
    try {
        plan = rrValidator.validateReservationSubmissionRequest(rSystem, request, ReservationSystemTestUtil.getNewReservationId());
        Assert.fail();
    } catch (YarnException e) {
        Assert.assertNull(plan);
        String message = e.getMessage();
        Assert.assertTrue(message.startsWith("Negative Period : "));
        LOG.info(message);
    }
}
Also used : ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 30 with ReservationSubmissionRequest

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

the class TestReservationInputValidator method testSubmitReservationNormal.

@Test
public void testSubmitReservationNormal() {
    ReservationSubmissionRequest request = createSimpleReservationSubmissionRequest(1, 1, 1, 5, 3);
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationSubmissionRequest(rSystem, request, ReservationSystemTestUtil.getNewReservationId());
    } catch (YarnException e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(plan);
}
Also used : ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Aggregations

ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)42 Test (org.junit.Test)34 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)22 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)19 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)14 Clock (org.apache.hadoop.yarn.util.Clock)14 UTCClock (org.apache.hadoop.yarn.util.UTCClock)14 ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)12 IOException (java.io.IOException)10 ReservationListRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest)10 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)10 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)9 AccessControlException (java.security.AccessControlException)8 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)8 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)7 MiniYARNCluster (org.apache.hadoop.yarn.server.MiniYARNCluster)7 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)6 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)6 ReservationDeleteRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest)5 ReservationUpdateRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest)5