Search in sources :

Example 6 with UTCClock

use of org.apache.hadoop.yarn.util.UTCClock in project hadoop by apache.

the class TestClientRMService method testCreateReservation.

@Test
public void testCreateReservation() {
    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);
    // passes.
    try {
        clientService.submitReservation(sRequest);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    // Submit the reservation with the same reservation id but different
    // reservation definition, and ensure YarnException is thrown.
    arrival = clock.getTime();
    ReservationDefinition rDef = sRequest.getReservationDefinition();
    rDef.setArrival(arrival + duration);
    sRequest.setReservationDefinition(rDef);
    try {
        clientService.submitReservation(sRequest);
        Assert.fail("Reservation submission should fail if a duplicate " + "reservation id is used, but the reservation definition has been " + "updated.");
    } catch (Exception e) {
        Assert.assertTrue(e instanceof YarnException);
    }
    rm.stop();
}
Also used : ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) 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) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 7 with UTCClock

use of org.apache.hadoop.yarn.util.UTCClock 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 8 with UTCClock

use of org.apache.hadoop.yarn.util.UTCClock 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 9 with UTCClock

use of org.apache.hadoop.yarn.util.UTCClock 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 10 with UTCClock

use of org.apache.hadoop.yarn.util.UTCClock in project hadoop by apache.

the class TestReservationSystemWithRMHA method createReservationSubmissionRequest.

private ReservationSubmissionRequest createReservationSubmissionRequest(ReservationId reservationId) {
    Clock clock = new UTCClock();
    long arrival = clock.getTime();
    long duration = 60000;
    long deadline = (long) (arrival + duration + 1500);
    return ReservationSystemTestUtil.createSimpleReservationRequest(reservationId, 4, arrival, deadline, duration);
}
Also used : Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) UTCClock(org.apache.hadoop.yarn.util.UTCClock)

Aggregations

Clock (org.apache.hadoop.yarn.util.Clock)15 UTCClock (org.apache.hadoop.yarn.util.UTCClock)15 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)14 Test (org.junit.Test)14 ReservationListRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest)10 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)10 IOException (java.io.IOException)8 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)8 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)8 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)8 AccessControlException (java.security.AccessControlException)7 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)7 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)7 MiniYARNCluster (org.apache.hadoop.yarn.server.MiniYARNCluster)7 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)4 ReservationDeleteRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest)2 ReservationDeleteResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse)2 ReservationUpdateRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest)2 ReservationUpdateResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse)2 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)2