Search in sources :

Example 51 with ReservationDefinition

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

the class TestReservationSystemUtil method createReservationAllocation.

private ReservationAllocation createReservationAllocation(long startTime, long deadline, long step, int[] alloc, ReservationId id, Resource minAlloc) {
    Map<ReservationInterval, Resource> allocations = ReservationSystemTestUtil.generateAllocation(startTime, step, alloc);
    ResourceCalculator rs = mock(ResourceCalculator.class);
    ReservationDefinition definition = ReservationSystemTestUtil.createSimpleReservationDefinition(startTime, deadline, step);
    return new InMemoryReservationAllocation(id, definition, "user", ReservationSystemTestUtil.reservationQ, startTime, startTime + step, allocations, rs, minAlloc, false);
}
Also used : ResourceCalculator(org.apache.hadoop.yarn.util.resource.ResourceCalculator) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Resource(org.apache.hadoop.yarn.api.records.Resource)

Example 52 with ReservationDefinition

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

the class ReservationSystemTestUtil method createSimpleReservationRequest.

public static ReservationSubmissionRequest createSimpleReservationRequest(ReservationId reservationId, int numContainers, long arrival, long deadline, long duration, Priority priority) {
    // create a request with a single atomic ask
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), numContainers, 1, duration);
    ReservationRequests reqs = ReservationRequests.newInstance(Collections.singletonList(r), ReservationRequestInterpreter.R_ALL);
    ReservationDefinition rDef = ReservationDefinition.newInstance(arrival, deadline, reqs, "testClientRMService#reservation", "0", priority);
    ReservationSubmissionRequest request = ReservationSubmissionRequest.newInstance(rDef, reservationQ, reservationId);
    return request;
}
Also used : ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)

Example 53 with ReservationDefinition

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

the class ReservationSystemTestUtil method generateRandomRR.

public static ReservationDefinition generateRandomRR(Random rand, long i) {
    rand.setSeed(i);
    long now = System.currentTimeMillis();
    // start time at random in the next 12 hours
    long arrival = rand.nextInt(12 * 3600 * 1000);
    // deadline at random in the next day
    long deadline = arrival + rand.nextInt(24 * 3600 * 1000);
    // create a request with a single atomic ask
    ReservationDefinition rr = new ReservationDefinitionPBImpl();
    rr.setArrival(now + arrival);
    rr.setDeadline(now + deadline);
    int gang = 1 + rand.nextInt(9);
    int par = (rand.nextInt(1000) + 1) * gang;
    // random duration within 2h
    long dur = rand.nextInt(2 * 3600 * 1000);
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), par, gang, dur);
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setReservationResources(Collections.singletonList(r));
    rand.nextInt(3);
    ReservationRequestInterpreter[] type = ReservationRequestInterpreter.values();
    reqs.setInterpreter(type[rand.nextInt(type.length)]);
    rr.setReservationRequests(reqs);
    return rr;
}
Also used : ReservationRequestsPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl) ReservationRequestInterpreter(org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationDefinitionPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests)

Example 54 with ReservationDefinition

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

the class TestInMemoryPlan method createSimpleReservationDefinition.

private ReservationDefinition createSimpleReservationDefinition(long arrival, long deadline, long duration, Collection<ReservationRequest> resources) {
    // create a request with a single atomic ask
    ReservationDefinition rDef = new ReservationDefinitionPBImpl();
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setReservationResources(new ArrayList<ReservationRequest>(resources));
    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) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationDefinitionPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests)

Example 55 with ReservationDefinition

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

the class TestInMemoryReservationAllocation method testBlocks.

@Test
public void testBlocks() {
    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);
    Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, false, 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]), (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