Search in sources :

Example 11 with ReservationDeleteRequest

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

the class TestYarnClient method testReservationDelete.

@Test
public void testReservationDelete() 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);
        ReservationId reservationID = sRequest.getReservationId();
        // Delete the reservation
        ReservationDeleteRequest dRequest = ReservationDeleteRequest.newInstance(reservationID);
        ReservationDeleteResponse dResponse = client.deleteReservation(dRequest);
        Assert.assertNotNull(dResponse);
        System.out.println("Delete reservation response: " + dResponse);
        // List reservations, search by non-existent reservationID
        ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, reservationID.toString(), -1, -1, false);
        ReservationListResponse response = client.listReservations(request);
        Assert.assertNotNull(response);
        Assert.assertEquals(0, response.getReservationAllocationState().size());
    } finally {
        // clean-up
        if (client != null) {
            client.stop();
        }
        cluster.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) ReservationDeleteResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse) ReservationDeleteRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest) 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)

Aggregations

ReservationDeleteRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest)11 Test (org.junit.Test)9 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)8 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)6 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)5 ReservationDeleteResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse)4 ReservationDeleteRequestPBImpl (org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationDeleteRequestPBImpl)4 ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)3 ReservationListRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest)2 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)2 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)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 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 AccessControlException (java.security.AccessControlException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 Consumes (javax.ws.rs.Consumes)1