Search in sources :

Example 11 with ReservationSubmissionResponse

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

the class TestReservationSystemWithRMHA method testSubmitReservationFailoverAndUpdate.

@Test
public void testSubmitReservationFailoverAndUpdate() 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();
    // Do the failover
    explicitFailover();
    addNodeCapacityToPlan(rm2, 102400, 100);
    // check if reservation exists after failover
    Plan plan = rm2.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;
    clientService = rm2.getClientRMService();
    try {
        updateResponse = clientService.updateReservation(updateRequest);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(updateResponse);
    validateReservation(plan, reservationID, reservationDefinition);
}
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) ReservationSubmissionResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse) Plan(org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan) Test(org.junit.Test)

Example 12 with ReservationSubmissionResponse

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

the class TestClientRMService method submitReservationTestHelper.

private ReservationSubmissionRequest submitReservationTestHelper(ClientRMService clientService, long arrival, long deadline, long duration) {
    ReservationSubmissionResponse sResponse = null;
    GetNewReservationRequest newReservationRequest = GetNewReservationRequest.newInstance();
    ReservationId reservationID = null;
    try {
        reservationID = clientService.getNewReservation(newReservationRequest).getReservationId();
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    ReservationSubmissionRequest sRequest = ReservationSystemTestUtil.createSimpleReservationRequest(reservationID, 4, arrival, deadline, duration);
    try {
        sResponse = clientService.submitReservation(sRequest);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(sResponse);
    Assert.assertNotNull(reservationID);
    System.out.println("Submit reservation response: " + reservationID);
    return sRequest;
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) GetNewReservationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ReservationSubmissionResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse) 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)

Example 13 with ReservationSubmissionResponse

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

the class TestYarnClient method submitReservationTestHelper.

private ReservationSubmissionRequest submitReservationTestHelper(YarnClient client, long arrival, long deadline, long duration) throws IOException, YarnException {
    ReservationId reservationID = client.createReservation().getReservationId();
    ReservationSubmissionRequest sRequest = createSimpleReservationRequest(reservationID, 4, arrival, deadline, duration);
    ReservationSubmissionResponse sResponse = client.submitReservation(sRequest);
    Assert.assertNotNull(sResponse);
    Assert.assertNotNull(reservationID);
    System.out.println("Submit reservation response: " + reservationID);
    return sRequest;
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ReservationSubmissionResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)

Aggregations

ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)13 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)12 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)11 Test (org.junit.Test)8 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)6 Plan (org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan)6 ReservationDeleteRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest)3 ReservationUpdateRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest)3 RMState (org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState)3 IOException (java.io.IOException)2 ReservationDeleteResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse)2 ReservationUpdateResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 ReservationAllocationStateProto (org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 AccessControlException (java.security.AccessControlException)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1