Search in sources :

Example 6 with ReservationUpdateRequest

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

the class TestReservationInputValidator method testUpdateReservationNoDefinition.

@Test
public void testUpdateReservationNoDefinition() {
    ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
    request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
    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 definition. Please try again by specifying a reservation definition."));
        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)

Example 7 with ReservationUpdateRequest

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

the class TestReservationInputValidator method testUpdateReservationExceedsGangSize.

@Test
public void testUpdateReservationExceedsGangSize() {
    ReservationUpdateRequest request = createSimpleReservationUpdateRequest(1, 1, 1, 5, 4);
    Resource resource = Resource.newInstance(512, 1);
    when(plan.getTotalCapacity()).thenReturn(resource);
    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 size of the largest gang in the reservation definition"));
        Assert.assertTrue(message.contains("exceed the capacity available "));
        LOG.info(message);
    }
}
Also used : ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) Resource(org.apache.hadoop.yarn.api.records.Resource) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 8 with ReservationUpdateRequest

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

the class RMWebServices method createReservationUpdateRequest.

private ReservationUpdateRequest createReservationUpdateRequest(ReservationUpdateRequestInfo resContext) throws IOException {
    // defending against a couple of common submission format problems
    if (resContext == null) {
        throw new BadRequestException("Input ReservationSubmissionContext should not be null");
    }
    ReservationDefinitionInfo resInfo = resContext.getReservationDefinition();
    if (resInfo == null) {
        throw new BadRequestException("Input ReservationDefinition should not be null");
    }
    ReservationRequestsInfo resReqsInfo = resInfo.getReservationRequests();
    if (resReqsInfo == null || resReqsInfo.getReservationRequest() == null || resReqsInfo.getReservationRequest().size() == 0) {
        throw new BadRequestException("The ReservationDefinition should" + " contain at least one ReservationRequest");
    }
    if (resContext.getReservationId() == null) {
        throw new BadRequestException("Update operations must specify an existing ReservaitonId");
    }
    ReservationRequestInterpreter[] values = ReservationRequestInterpreter.values();
    ReservationRequestInterpreter resInt = values[resReqsInfo.getReservationRequestsInterpreter()];
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    for (ReservationRequestInfo resReqInfo : resReqsInfo.getReservationRequest()) {
        ResourceInfo rInfo = resReqInfo.getCapability();
        Resource capability = Resource.newInstance(rInfo.getMemorySize(), rInfo.getvCores());
        int numContainers = resReqInfo.getNumContainers();
        int minConcurrency = resReqInfo.getMinConcurrency();
        long duration = resReqInfo.getDuration();
        ReservationRequest rr = ReservationRequest.newInstance(capability, numContainers, minConcurrency, duration);
        list.add(rr);
    }
    ReservationRequests reqs = ReservationRequests.newInstance(list, resInt);
    ReservationDefinition rDef = ReservationDefinition.newInstance(resInfo.getArrival(), resInfo.getDeadline(), reqs, resInfo.getReservationName());
    ReservationUpdateRequest request = ReservationUpdateRequest.newInstance(rDef, ReservationId.parseReservationId(resContext.getReservationId()));
    return request;
}
Also used : ReservationRequestsInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestsInfo) ResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo) LocalResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LocalResourceInfo) ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) ReservationRequestInterpreter(org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) GetNewReservationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ArrayList(java.util.ArrayList) Resource(org.apache.hadoop.yarn.api.records.Resource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) ReservationRequestInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestInfo) ReservationDefinitionInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationDefinitionInfo) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException)

Example 9 with ReservationUpdateRequest

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

the class ReservationACLsTestBase method verifyUpdateReservationFailure.

private void verifyUpdateReservationFailure(String updater, String originalSubmitter, String queueName) throws Exception {
    ReservationId reservationId = createReservation(originalSubmitter);
    submitReservation(originalSubmitter, queueName, reservationId);
    final ReservationUpdateRequest updateRequest = ReservationUpdateRequest.newInstance(makeSimpleReservationDefinition(), reservationId);
    ApplicationClientProtocol unauthorizedClient = getRMClientForUser(updater);
    try {
        unauthorizedClient.updateReservation(updateRequest);
        Assert.fail("Reservation updating by the enemy should fail.");
    } catch (YarnException e) {
        handleAdministerException(e, updater, queueName, ReservationACL.ADMINISTER_RESERVATIONS.name());
    }
    deleteReservation(originalSubmitter, reservationId);
}
Also used : ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 10 with ReservationUpdateRequest

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

the class TestReservationSystemWithRMHA method testSubmitUpdateReservationFailoverAndDelete.

@Test
public void testSubmitUpdateReservationFailoverAndDelete() throws Exception {
    startRMs();
    addNodeCapacityToPlan(rm1, 102400, 100);
    ClientRMService clientService = rm1.getClientRMService();
    ReservationId reservationID = getNewReservation(clientService).getReservationId();
    // create a reservation
    ReservationSubmissionRequest request = createReservationSubmissionRequest(reservationID);
    ReservationSubmissionResponse response = null;
    try {
        response = clientService.submitReservation(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertNotNull(reservationID);
    LOG.info("Submit reservation response: " + reservationID);
    ReservationDefinition reservationDefinition = request.getReservationDefinition();
    // check if reservation is submitted successfully
    Plan plan = rm1.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
    validateReservation(plan, reservationID, reservationDefinition);
    // update the reservation
    long newDeadline = reservationDefinition.getDeadline() + 100;
    reservationDefinition.setDeadline(newDeadline);
    ReservationUpdateRequest updateRequest = ReservationUpdateRequest.newInstance(reservationDefinition, reservationID);
    ReservationUpdateResponse updateResponse = null;
    try {
        updateResponse = clientService.updateReservation(updateRequest);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(updateResponse);
    validateReservation(plan, reservationID, reservationDefinition);
    // Do the failover
    explicitFailover();
    addNodeCapacityToPlan(rm2, 102400, 100);
    // check if reservation exists after failover
    plan = rm2.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
    validateReservation(plan, reservationID, reservationDefinition);
    // delete the reservation
    ReservationDeleteRequest deleteRequest = ReservationDeleteRequest.newInstance(reservationID);
    ReservationDeleteResponse deleteResponse = null;
    clientService = rm2.getClientRMService();
    try {
        deleteResponse = clientService.deleteReservation(deleteRequest);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(deleteResponse);
    Assert.assertNull(plan.getReservationById(reservationID));
}
Also used : ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationUpdateResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ReservationDeleteResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse) ReservationDeleteRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest) ReservationSubmissionResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse) Plan(org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan) 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