Search in sources :

Example 6 with ReservationListResponse

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

the class TestClientRMService method testListReservationsByInvalidTimeInterval.

@Test
public void testListReservationsByInvalidTimeInterval() {
    ResourceManager rm = setupResourceManager();
    ClientRMService clientService = rm.getClientRMService();
    Clock clock = new UTCClock();
    long arrival = clock.getTime();
    long duration = 60000;
    long deadline = (long) (arrival + 1.05 * duration);
    ReservationSubmissionRequest sRequest = submitReservationTestHelper(clientService, arrival, deadline, duration);
    // List reservations, search by invalid end time == -1.
    ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, -1, true);
    ReservationListResponse response = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    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 = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertEquals(1, response.getReservationAllocationState().size());
    Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), sRequest.getReservationId().getId());
    rm.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) UTCClock(org.apache.hadoop.yarn.util.UTCClock) Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) 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) Test(org.junit.Test)

Example 7 with ReservationListResponse

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

the class TestClientRMService method testListReservationsByTimeInterval.

@Test
public void testListReservationsByTimeInterval() {
    ResourceManager rm = setupResourceManager();
    ClientRMService clientService = rm.getClientRMService();
    Clock clock = new UTCClock();
    long arrival = clock.getTime();
    long duration = 60000;
    long deadline = (long) (arrival + 1.05 * duration);
    ReservationSubmissionRequest sRequest = submitReservationTestHelper(clientService, arrival, deadline, duration);
    // List reservations, search by a point in time within the reservation
    // range.
    arrival = clock.getTime();
    ReservationId reservationID = sRequest.getReservationId();
    ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", arrival + duration / 2, arrival + duration / 2, true);
    ReservationListResponse response = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertEquals(1, response.getReservationAllocationState().size());
    Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
    // List reservations, search by time within reservation interval.
    request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, Long.MAX_VALUE, true);
    response = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertEquals(1, response.getReservationAllocationState().size());
    Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
    // Verify that the full resource allocations exist.
    Assert.assertTrue(response.getReservationAllocationState().get(0).getResourceAllocationRequests().size() > 0);
    // Verify that the full RDL is returned.
    ReservationRequests reservationRequests = response.getReservationAllocationState().get(0).getReservationDefinition().getReservationRequests();
    Assert.assertTrue(reservationRequests.getInterpreter().toString().equals("R_ALL"));
    Assert.assertTrue(reservationRequests.getReservationResources().get(0).getDuration() == duration);
    rm.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) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) UTCClock(org.apache.hadoop.yarn.util.UTCClock) Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) 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) Test(org.junit.Test)

Example 8 with ReservationListResponse

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

the class ReservationACLsTestBase method verifyListReservationByIdSuccess.

private void verifyListReservationByIdSuccess(String lister, String originalSubmitter, String queueName) throws Exception {
    ReservationId reservationId = createReservation(originalSubmitter);
    submitReservation(originalSubmitter, queueName, reservationId);
    ReservationListResponse adminResponse = listReservationById(lister, reservationId, queueName);
    assert (adminResponse.getReservationAllocationState().size() == 1);
    assert (adminResponse.getReservationAllocationState().get(0).getUser().equals(originalSubmitter));
    deleteReservation(originalSubmitter, reservationId);
}
Also used : ReservationListResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId)

Example 9 with ReservationListResponse

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

the class ReservationACLsTestBase method verifyListReservationSuccess.

private void verifyListReservationSuccess(String lister, String originalSubmitter, String queueName) throws Exception {
    ReservationId reservationId = createReservation(originalSubmitter);
    submitReservation(originalSubmitter, queueName, reservationId);
    ReservationListResponse adminResponse = listReservation(lister, queueName);
    assert (adminResponse.getReservationAllocationState().size() == 1);
    assert (adminResponse.getReservationAllocationState().get(0).getUser().equals(originalSubmitter));
    deleteReservation(originalSubmitter, reservationId);
}
Also used : ReservationListResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId)

Example 10 with ReservationListResponse

use of org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse 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)

Aggregations

ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)14 ReservationListRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest)11 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)10 Clock (org.apache.hadoop.yarn.util.Clock)10 UTCClock (org.apache.hadoop.yarn.util.UTCClock)10 Test (org.junit.Test)10 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)9 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)6 IOException (java.io.IOException)5 AccessControlException (java.security.AccessControlException)5 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)5 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)5 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)5 MiniYARNCluster (org.apache.hadoop.yarn.server.MiniYARNCluster)5 ReservationDeleteRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest)2 ReservationDeleteResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse)2 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 GET (javax.ws.rs.GET)1