Search in sources :

Example 41 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestReservationSystemUtil method testConvertAllocationsToReservationInfoNoAllocations.

@Test
public void testConvertAllocationsToReservationInfoNoAllocations() {
    long startTime = new Date().getTime();
    long step = 10000;
    int[] alloc = { 10, 10, 10 };
    ReservationId id = ReservationSystemTestUtil.getNewReservationId();
    ReservationAllocation allocation = createReservationAllocation(startTime, startTime + 10 * step, step, alloc, id, createResource(4000, 2));
    List<ReservationAllocationState> infoList = ReservationSystemUtil.convertAllocationsToReservationInfo(Collections.singleton(allocation), false);
    Assert.assertEquals(infoList.size(), 1);
    Assert.assertEquals(infoList.get(0).getReservationId().toString(), id.toString());
    Assert.assertTrue(infoList.get(0).getResourceAllocationRequests().isEmpty());
}
Also used : ReservationAllocationState(org.apache.hadoop.yarn.api.records.ReservationAllocationState) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) Date(java.util.Date) Test(org.junit.Test)

Example 42 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestReservationSystemUtil method testConvertAllocationsToReservationInfo.

@Test
public void testConvertAllocationsToReservationInfo() {
    long startTime = new Date().getTime();
    long step = 10000;
    int[] alloc = { 10, 10, 10 };
    ReservationId id = ReservationSystemTestUtil.getNewReservationId();
    ReservationAllocation allocation = createReservationAllocation(startTime, startTime + 10 * step, step, alloc, id, createResource(4000, 2));
    List<ReservationAllocationState> infoList = ReservationSystemUtil.convertAllocationsToReservationInfo(Collections.singleton(allocation), true);
    Assert.assertEquals(infoList.size(), 1);
    Assert.assertEquals(infoList.get(0).getReservationId().toString(), id.toString());
    Assert.assertFalse(infoList.get(0).getResourceAllocationRequests().isEmpty());
}
Also used : ReservationAllocationState(org.apache.hadoop.yarn.api.records.ReservationAllocationState) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) Date(java.util.Date) Test(org.junit.Test)

Example 43 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestReservationSystemUtil method testConvertAllocationsToReservationInfoEmptyAllocations.

@Test
public void testConvertAllocationsToReservationInfoEmptyAllocations() {
    long startTime = new Date().getTime();
    long step = 10000;
    int[] alloc = {};
    ReservationId id = ReservationSystemTestUtil.getNewReservationId();
    ReservationAllocation allocation = createReservationAllocation(startTime, startTime + 10 * step, step, alloc, id, createResource(4000, 2));
    List<ReservationAllocationState> infoList = ReservationSystemUtil.convertAllocationsToReservationInfo(Collections.singleton(allocation), false);
    Assert.assertEquals(infoList.size(), 1);
    Assert.assertEquals(infoList.get(0).getReservationId().toString(), id.toString());
    Assert.assertTrue(infoList.get(0).getResourceAllocationRequests().isEmpty());
}
Also used : ReservationAllocationState(org.apache.hadoop.yarn.api.records.ReservationAllocationState) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) Date(java.util.Date) Test(org.junit.Test)

Example 44 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestYarnClient method testListReservationsByReservationId.

@Test
public void testListReservationsByReservationId() 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();
        ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, reservationID.toString(), -1, -1, false);
        ReservationListResponse response = client.listReservations(request);
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getReservationAllocationState().size());
        Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
        Assert.assertEquals(response.getReservationAllocationState().get(0).getResourceAllocationRequests().size(), 0);
    } 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) 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 45 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestYarnClient method testListReservationsByTimeInterval.

@Test
public void testListReservationsByTimeInterval() 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 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 = client.listReservations(request);
        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 = client.listReservations(request);
        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);
    } 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) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) 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

ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)120 Test (org.junit.Test)85 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)40 PlanningException (org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)27 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)19 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)17 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)16 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)16 WebResource (com.sun.jersey.api.client.WebResource)14 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)14 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)13 JSONObject (org.codehaus.jettison.json.JSONObject)13 ArrayList (java.util.ArrayList)11 ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)11 IOException (java.io.IOException)10 Resource (org.apache.hadoop.yarn.api.records.Resource)10 ReservationDefinitionPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl)10 ReservationRequestsPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl)10 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)9 ReservationAllocationStateProto (org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto)9