Search in sources :

Example 11 with ReservationDefinition

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

the class ReservationSystemTestUtil method createSimpleReservationDefinition.

public static ReservationDefinition createSimpleReservationDefinition(long arrival, long deadline, long duration, int parallelism) {
    // create a request with a single atomic ask
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), parallelism, parallelism, duration);
    ReservationDefinition rDef = new ReservationDefinitionPBImpl();
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setReservationResources(Collections.singletonList(r));
    reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    rDef.setReservationRequests(reqs);
    rDef.setArrival(arrival);
    rDef.setDeadline(deadline);
    return rDef;
}
Also used : ReservationRequestsPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationDefinitionPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests)

Example 12 with ReservationDefinition

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

the class TestInMemoryPlan method createReservationAllocation.

private ReservationAllocation createReservationAllocation(ReservationId reservationID, int start, int[] alloc, boolean isStep) {
    Map<ReservationInterval, ReservationRequest> allocations = generateAllocation(start, alloc, isStep);
    ReservationDefinition rDef = createSimpleReservationDefinition(start, start + alloc.length, alloc.length, allocations.values());
    Map<ReservationInterval, Resource> allocs = ReservationSystemUtil.toResources(allocations);
    return new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length, allocs, resCalc, minAlloc);
}
Also used : ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Resource(org.apache.hadoop.yarn.api.records.Resource)

Example 13 with ReservationDefinition

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

the class TestInMemoryReservationAllocation method testSkyline.

@Test
public void testSkyline() {
    ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong());
    int[] alloc = { 0, 5, 10, 10, 5, 0 };
    int start = 100;
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length);
    Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, true, false);
    ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc);
    doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc);
    Assert.assertFalse(rAllocation.containsGangs());
    for (int i = 0; i < alloc.length; i++) {
        Assert.assertEquals(Resource.newInstance(1024 * (alloc[i] + i), (alloc[i] + i)), rAllocation.getResourcesAtTime(start + i));
    }
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Resource(org.apache.hadoop.yarn.api.records.Resource) Test(org.junit.Test)

Example 14 with ReservationDefinition

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

the class TestInMemoryReservationAllocation method testZeroAlloaction.

@Test
public void testZeroAlloaction() {
    ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong());
    int[] alloc = {};
    long start = 0;
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length);
    Map<ReservationInterval, Resource> allocations = new HashMap<ReservationInterval, Resource>();
    ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc);
    doAssertions(rAllocation, reservationID, rDef, allocations, (int) start, alloc);
    Assert.assertFalse(rAllocation.containsGangs());
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) HashMap(java.util.HashMap) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Resource(org.apache.hadoop.yarn.api.records.Resource) Test(org.junit.Test)

Example 15 with ReservationDefinition

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

the class TestInMemoryReservationAllocation method testGangAlloaction.

@Test
public void testGangAlloaction() {
    ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong());
    int[] alloc = { 10, 10, 10, 10, 10, 10 };
    int start = 100;
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length);
    boolean isGang = true;
    Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, false, isGang);
    ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc, isGang);
    doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc);
    Assert.assertTrue(rAllocation.containsGangs());
    for (int i = 0; i < alloc.length; i++) {
        Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])), rAllocation.getResourcesAtTime(start + i));
    }
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Resource(org.apache.hadoop.yarn.api.records.Resource) Test(org.junit.Test)

Aggregations

ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)70 Test (org.junit.Test)52 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)40 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)23 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)19 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)19 Resource (org.apache.hadoop.yarn.api.records.Resource)17 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)16 ReservationDefinitionPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl)15 ReservationRequestsPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl)15 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)14 ArrayList (java.util.ArrayList)12 PlanningException (org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)12 ReservationUpdateRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest)7 ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)6 Plan (org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan)5 Clock (org.apache.hadoop.yarn.util.Clock)5 ReservationUpdateResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse)4 IOException (java.io.IOException)3 GetNewReservationRequest (org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest)3