Search in sources :

Example 11 with ReservationUpdateRequest

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

the class TestReservationInputValidator method testUpdateReservationInvalidDuration.

@Test
public void testUpdateReservationInvalidDuration() {
    ReservationUpdateRequest request = createSimpleReservationUpdateRequest(1, 1, 1, 3, 4);
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationUpdateRequest(rSystem, request);
        Assert.fail();
    } catch (YarnException e) {
        Assert.assertNull(plan);
        String message = e.getMessage();
        Assert.assertTrue(message.contains("must  be greater or equal to the minimum resource duration"));
        LOG.info(message);
    }
}
Also used : ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 12 with ReservationUpdateRequest

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

the class TestReservationInputValidator method testUpdateReservationNormal.

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

Example 13 with ReservationUpdateRequest

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

the class TestReservationInputValidator method testUpdateReservationInvalidDeadline.

@Test
public void testUpdateReservationInvalidDeadline() {
    ReservationUpdateRequest request = createSimpleReservationUpdateRequest(1, 1, 1, 0, 3);
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationUpdateRequest(rSystem, request);
        Assert.fail();
    } catch (YarnException e) {
        Assert.assertNull(plan);
        String message = e.getMessage();
        Assert.assertTrue(message.startsWith("The specified deadline: 0 is the past"));
        LOG.info(message);
    }
}
Also used : ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 14 with ReservationUpdateRequest

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

the class TestReservationInputValidator method createSimpleReservationUpdateRequest.

private ReservationUpdateRequest createSimpleReservationUpdateRequest(int numRequests, int numContainers, long arrival, long deadline, long duration) {
    // create a request with a single atomic ask
    ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
    ReservationDefinition rDef = new ReservationDefinitionPBImpl();
    rDef.setArrival(arrival);
    rDef.setDeadline(deadline);
    if (numRequests > 0) {
        ReservationRequests reqs = new ReservationRequestsPBImpl();
        rDef.setReservationRequests(reqs);
        if (numContainers > 0) {
            ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), numContainers, 1, duration);
            reqs.setReservationResources(Collections.singletonList(r));
            reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
        }
    }
    request.setReservationDefinition(rDef);
    request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
    return request;
}
Also used : ReservationUpdateRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationUpdateRequestPBImpl) ReservationRequestsPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl) ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationDefinitionPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests)

Example 15 with ReservationUpdateRequest

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

the class TestReservationInputValidator method testUpdateReservationNoID.

@Test
public void testUpdateReservationNoID() {
    ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationUpdateRequest(rSystem, request);
        Assert.fail();
    } catch (YarnException e) {
        Assert.assertNull(plan);
        String message = e.getMessage();
        Assert.assertTrue(message.startsWith("Missing reservation id. Please try again by specifying a reservation id."));
        LOG.info(message);
    }
}
Also used : ReservationUpdateRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationUpdateRequestPBImpl) ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Aggregations

ReservationUpdateRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest)20 Test (org.junit.Test)15 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)13 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)8 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)7 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)5 ReservationUpdateResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse)4 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)4 ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)3 ReservationUpdateRequestPBImpl (org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationUpdateRequestPBImpl)3 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)2 GetNewReservationRequest (org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest)2 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)2 Resource (org.apache.hadoop.yarn.api.records.Resource)2 Plan (org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan)2 Clock (org.apache.hadoop.yarn.util.Clock)2 UTCClock (org.apache.hadoop.yarn.util.UTCClock)2 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)2 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1