Search in sources :

Example 11 with ReservationSubmissionRequest

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

the class ReservationACLsTestBase method submitReservation.

private void submitReservation(String submitter, String queueName, ReservationId reservationId) throws Exception {
    ApplicationClientProtocol submitterClient = getRMClientForUser(submitter);
    ReservationSubmissionRequest reservationSubmissionRequest = ReservationSubmissionRequest.newInstance(makeSimpleReservationDefinition(), queueName, reservationId);
    ReservationSubmissionResponse response = submitterClient.submitReservation(reservationSubmissionRequest);
}
Also used : ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ReservationSubmissionResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol)

Example 12 with ReservationSubmissionRequest

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

the class TestYarnClient method testListReservationsByInvalidTimeInterval.

@Test
public void testListReservationsByInvalidTimeInterval() throws Exception {
    MiniYARNCluster cluster = setupMiniYARNCluster();
    YarnClient client = setupYarnClient(cluster);
    try {
        Clock clock = new UTCClock();
        long arrival = clock.getTime();
        long duration = 60000;
        long deadline = (long) (arrival + 1.05 * duration);
        ReservationSubmissionRequest sRequest = submitReservationTestHelper(client, arrival, deadline, duration);
        // List reservations, search by invalid end time == -1.
        ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, -1, true);
        ReservationListResponse response = client.listReservations(request);
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getReservationAllocationState().size());
        Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), sRequest.getReservationId().getId());
        // List reservations, search by invalid end time < -1.
        request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, -10, true);
        response = client.listReservations(request);
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getReservationAllocationState().size());
        Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), sRequest.getReservationId().getId());
    } finally {
        // clean-up
        if (client != null) {
            client.stop();
        }
        cluster.stop();
    }
}
Also used : ReservationListResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse) ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster) UTCClock(org.apache.hadoop.yarn.util.UTCClock) Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) Test(org.junit.Test)

Example 13 with ReservationSubmissionRequest

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

the class TestReservationSystemWithRMHA method testReservationResizeAfterFailover.

@Test
public void testReservationResizeAfterFailover() throws Exception {
    startRMs();
    addNodeCapacityToPlan(rm1, 102400, 100);
    ClientRMService clientService = rm1.getClientRMService();
    ReservationId resID1 = getNewReservation(clientService).getReservationId();
    // create a reservation
    ReservationSubmissionRequest request = createReservationSubmissionRequest(resID1);
    ReservationDefinition reservationDefinition = request.getReservationDefinition();
    ReservationSubmissionResponse response = null;
    try {
        response = clientService.submitReservation(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertNotNull(resID1);
    LOG.info("Submit reservation response: " + resID1);
    ReservationId resID2 = getNewReservation(clientService).getReservationId();
    request.setReservationId(resID2);
    try {
        response = clientService.submitReservation(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertNotNull(resID2);
    LOG.info("Submit reservation response: " + resID2);
    ReservationId resID3 = getNewReservation(clientService).getReservationId();
    request.setReservationId(resID3);
    try {
        response = clientService.submitReservation(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertNotNull(resID3);
    LOG.info("Submit reservation response: " + resID3);
    // allow the reservations to become active
    waitForReservationActivation(rm1, resID1, ReservationSystemTestUtil.reservationQ);
    // validate reservations before failover
    Plan plan = rm1.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
    validateReservation(plan, resID1, reservationDefinition);
    validateReservation(plan, resID2, reservationDefinition);
    validateReservation(plan, resID3, reservationDefinition);
    ResourceScheduler scheduler = rm1.getResourceScheduler();
    QueueInfo resQ1 = scheduler.getQueueInfo(resID1.toString(), false, false);
    Assert.assertEquals(0.05, resQ1.getCapacity(), 0.001f);
    QueueInfo resQ2 = scheduler.getQueueInfo(resID2.toString(), false, false);
    Assert.assertEquals(0.05, resQ2.getCapacity(), 0.001f);
    QueueInfo resQ3 = scheduler.getQueueInfo(resID3.toString(), false, false);
    Assert.assertEquals(0.05, resQ3.getCapacity(), 0.001f);
    // Do the failover
    explicitFailover();
    addNodeCapacityToPlan(rm2, 5120, 5);
    // check if reservations exists after failover
    plan = rm2.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
    validateReservation(plan, resID1, reservationDefinition);
    validateReservation(plan, resID3, reservationDefinition);
    // verify if the reservations have been resized
    scheduler = rm2.getResourceScheduler();
    resQ1 = scheduler.getQueueInfo(resID1.toString(), false, false);
    Assert.assertEquals(1f / 3f, resQ1.getCapacity(), 0.001f);
    resQ2 = scheduler.getQueueInfo(resID2.toString(), false, false);
    Assert.assertEquals(1f / 3f, resQ2.getCapacity(), 0.001f);
    resQ3 = scheduler.getQueueInfo(resID3.toString(), false, false);
    Assert.assertEquals(1f / 3f, resQ3.getCapacity(), 0.001f);
}
Also used : QueueInfo(org.apache.hadoop.yarn.api.records.QueueInfo) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ResourceScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler) ReservationSubmissionResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse) Plan(org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan) Test(org.junit.Test)

Example 14 with ReservationSubmissionRequest

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

the class TestReservationSystemWithRMHA method testFailoverAndSubmitReservation.

@Test
public void testFailoverAndSubmitReservation() throws Exception {
    startRMs();
    addNodeCapacityToPlan(rm1, 102400, 100);
    // Do the failover
    explicitFailover();
    addNodeCapacityToPlan(rm2, 102400, 100);
    ClientRMService clientService = rm2.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 = rm2.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
    validateReservation(plan, reservationID, reservationDefinition);
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) 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 15 with ReservationSubmissionRequest

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

the class TestReservationSystemWithRMHA method testSubmitReservationFailoverAndDelete.

@Test
public void testSubmitReservationFailoverAndDelete() 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);
    // 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 : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) 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

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