Search in sources :

Example 1 with ReservationRequest

use of org.apache.hadoop.yarn.api.records.ReservationRequest 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 2 with ReservationRequest

use of org.apache.hadoop.yarn.api.records.ReservationRequest 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 3 with ReservationRequest

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

the class TestInMemoryPlan method generateAllocation.

private Map<ReservationInterval, ReservationRequest> generateAllocation(int startTime, int[] alloc, boolean isStep) {
    Map<ReservationInterval, ReservationRequest> req = new HashMap<ReservationInterval, ReservationRequest>();
    int numContainers = 0;
    for (int i = 0; i < alloc.length; i++) {
        if (isStep) {
            numContainers = alloc[i] + i;
        } else {
            numContainers = alloc[i];
        }
        ReservationRequest rr = ReservationRequest.newInstance(Resource.newInstance(1024, 1), (numContainers));
        req.put(new ReservationInterval(startTime + i, startTime + i + 1), rr);
    }
    return req;
}
Also used : HashMap(java.util.HashMap) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest)

Example 4 with ReservationRequest

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

the class TestClientRMService method testUpdateReservation.

@Test
public void testUpdateReservation() {
    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);
    ReservationDefinition rDef = sRequest.getReservationDefinition();
    ReservationRequest rr = rDef.getReservationRequests().getReservationResources().get(0);
    ReservationId reservationID = sRequest.getReservationId();
    rr.setNumContainers(5);
    arrival = clock.getTime();
    duration = 30000;
    deadline = (long) (arrival + 1.05 * duration);
    rr.setDuration(duration);
    rDef.setArrival(arrival);
    rDef.setDeadline(deadline);
    ReservationUpdateRequest uRequest = ReservationUpdateRequest.newInstance(rDef, reservationID);
    ReservationUpdateResponse uResponse = null;
    try {
        uResponse = clientService.updateReservation(uRequest);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(uResponse);
    System.out.println("Update reservation response: " + uResponse);
    rm.stop();
}
Also used : ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) GetNewReservationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest) ReservationUpdateResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse) 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 5 with ReservationRequest

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

the class TestGreedyReservationAgent method testOrder.

@Test
public void testOrder() throws PlanningException {
    prepareBasicPlan();
    // create a completely utilized segment around time 30
    int[] f = { 100, 100 };
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(30 * step, 30 * step + f.length * step, f.length * step);
    assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", 30 * step, 30 * step + f.length * step, ReservationSystemTestUtil.generateAllocation(30 * step, step, f), res, minAlloc), false));
    // create a chain of 4 RR, mixing gang and non-gang
    ReservationDefinition rr = new ReservationDefinitionPBImpl();
    rr.setArrival(0 * step);
    rr.setDeadline(70 * step);
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setInterpreter(ReservationRequestInterpreter.R_ORDER);
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 10, 1, 10 * step);
    ReservationRequest r2 = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 10, 10, 20 * step);
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    list.add(r);
    list.add(r2);
    list.add(r);
    list.add(r2);
    reqs.setReservationResources(list);
    rr.setReservationRequests(reqs);
    // submit to agent
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr);
    // validate
    assertTrue("Agent-based allocation failed", reservationID != null);
    assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 4);
    ReservationAllocation cs = plan.getReservationById(reservationID);
    if (allocateLeft) {
        assertTrue(cs.toString(), check(cs, 0 * step, 10 * step, 20, 1024, 1));
        assertTrue(cs.toString(), check(cs, 10 * step, 30 * step, 10, 1024, 1));
        assertTrue(cs.toString(), check(cs, 32 * step, 42 * step, 20, 1024, 1));
        assertTrue(cs.toString(), check(cs, 42 * step, 62 * step, 10, 1024, 1));
    } else {
        assertTrue(cs.toString(), check(cs, 0 * step, 10 * step, 20, 1024, 1));
        assertTrue(cs.toString(), check(cs, 10 * step, 30 * step, 10, 1024, 1));
        assertTrue(cs.toString(), check(cs, 40 * step, 50 * step, 20, 1024, 1));
        assertTrue(cs.toString(), check(cs, 50 * step, 70 * step, 10, 1024, 1));
    }
    System.out.println("--------AFTER ORDER ALLOCATION (queue: " + reservationID + ")----------");
    System.out.println(plan.toString());
    System.out.println(plan.toCumulativeString());
}
Also used : ReservationRequestsPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl) InMemoryReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) 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) ArrayList(java.util.ArrayList) InMemoryReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation) ReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation) Test(org.junit.Test)

Aggregations

ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)29 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)23 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)20 ReservationDefinitionPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl)15 ReservationRequestsPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl)15 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)8 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)7 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)6 Resource (org.apache.hadoop.yarn.api.records.Resource)6 PlanningException (org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)5 ReservationUpdateRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest)4 ReservationRequestInterpreter (org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter)4 GetNewReservationRequest (org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest)3 HashMap (java.util.HashMap)2 ReservationUpdateResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse)2 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)2 LocalResourceInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LocalResourceInfo)2