Search in sources :

Example 11 with ReservationRequest

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

the class TestGreedyReservationAgent method testSharingPolicyFeedback.

@SuppressWarnings("javadoc")
@Test
public void testSharingPolicyFeedback() throws PlanningException {
    prepareBasicPlan();
    // let's constraint the instantaneous allocation and see the
    // policy kicking in during planning
    float instConstraint = 40;
    float avgConstraint = 40;
    ReservationSchedulerConfiguration conf = ReservationSystemTestUtil.createConf(plan.getQueueName(), 100000, instConstraint, avgConstraint);
    plan.getSharingPolicy().init(plan.getQueueName(), conf);
    // create a request with a single atomic ask
    ReservationDefinition rr = new ReservationDefinitionPBImpl();
    rr.setArrival(5 * step);
    rr.setDeadline(100 * step);
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 20, 20, 10 * step);
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setReservationResources(Collections.singletonList(r));
    rr.setReservationRequests(reqs);
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u3", plan, rr);
    ReservationId reservationID2 = ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID2, "u3", plan, rr);
    ReservationDefinition rr3 = new ReservationDefinitionPBImpl();
    rr3.setArrival(5 * step);
    rr3.setDeadline(100 * step);
    ReservationRequest r3 = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 45, 45, 10 * step);
    ReservationRequests reqs3 = new ReservationRequestsPBImpl();
    reqs3.setReservationResources(Collections.singletonList(r3));
    rr3.setReservationRequests(reqs3);
    ReservationId reservationID3 = ReservationSystemTestUtil.getNewReservationId();
    try {
        // RR3 is simply too big to fit
        agent.createReservation(reservationID3, "u3", plan, rr3);
        fail();
    } catch (PlanningException pe) {
    // expected
    }
    assertTrue("Agent-based allocation failed", reservationID != null);
    assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 4);
    ReservationAllocation cs = plan.getReservationById(reservationID);
    ReservationAllocation cs2 = plan.getReservationById(reservationID2);
    ReservationAllocation cs3 = plan.getReservationById(reservationID3);
    assertNotNull(cs);
    assertNotNull(cs2);
    assertNull(cs3);
    System.out.println("--------AFTER SIMPLE ALLOCATION (queue: " + reservationID + ")----------");
    System.out.println(plan.toString());
    System.out.println(plan.toCumulativeString());
    if (allocateLeft) {
        for (long i = 5 * step; i < 15 * step; i++) {
            assertTrue("Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
        }
        for (long i = 15 * step; i < 25 * step; i++) {
            // RR2 is pushed out by the presence of RR
            assertTrue("Agent-based allocation unexpected", Resources.equals(cs2.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
        }
    } else {
        for (long i = 90 * step; i < 100 * step; i++) {
            assertTrue("Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
        }
        for (long i = 80 * step; i < 90 * step; i++) {
            assertTrue("Agent-based allocation unexpected", Resources.equals(cs2.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
        }
    }
}
Also used : ReservationRequestsPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl) 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) PlanningException(org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException) InMemoryReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation) ReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation) ReservationSchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSchedulerConfiguration) Test(org.junit.Test)

Example 12 with ReservationRequest

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

the class TestGreedyReservationAgent method testAny.

@Test
public void testAny() throws PlanningException {
    prepareBasicPlan();
    // create an ANY request, with an impossible step (last in list, first
    // considered),
    // and two satisfiable ones. We expect the second one to be returned.
    ReservationDefinition rr = new ReservationDefinitionPBImpl();
    rr.setArrival(100 * step);
    rr.setDeadline(120 * step);
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setInterpreter(ReservationRequestInterpreter.R_ANY);
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 5, 5, 10 * step);
    ReservationRequest r2 = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 10, 5, 10 * step);
    ReservationRequest r3 = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 110, 110, 10 * step);
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    list.add(r);
    list.add(r2);
    list.add(r3);
    reqs.setReservationResources(list);
    rr.setReservationRequests(reqs);
    // submit to agent
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    boolean res = agent.createReservation(reservationID, "u1", plan, rr);
    // validate results, we expect the second one to be accepted
    assertTrue("Agent-based allocation failed", res);
    assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 3);
    ReservationAllocation cs = plan.getReservationById(reservationID);
    if (allocateLeft) {
        assertTrue(cs.toString(), check(cs, 100 * step, 110 * step, 5, 1024, 1));
    } else {
        assertTrue(cs.toString(), check(cs, 110 * step, 120 * step, 20, 1024, 1));
    }
    System.out.println("--------AFTER ANY 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) 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)

Example 13 with ReservationRequest

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

the class TestReservationInputValidator method createSimpleReservationSubmissionRequest.

private ReservationSubmissionRequest createSimpleReservationSubmissionRequest(int numRequests, int numContainers, long arrival, long deadline, long duration, String recurrence) {
    // create a request with a single atomic ask
    ReservationSubmissionRequest request = new ReservationSubmissionRequestPBImpl();
    ReservationDefinition rDef = new ReservationDefinitionPBImpl();
    rDef.setArrival(arrival);
    rDef.setDeadline(deadline);
    rDef.setRecurrenceExpression(recurrence);
    if (numRequests > 0) {
        ReservationRequests reqs = new ReservationRequestsPBImpl();
        rDef.setReservationRequests(reqs);
        if (numContainers > 0) {
            ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), numContainers, 1, duration);
            reqs.setReservationResources(Collections.singletonList(r));
            reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
        }
    }
    request.setQueue(PLAN_NAME);
    request.setReservationDefinition(rDef);
    return request;
}
Also used : ReservationRequestsPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl) ReservationSubmissionRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationSubmissionRequestPBImpl) 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) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)

Example 14 with ReservationRequest

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

the class RMWebServices method createReservationSubmissionRequest.

private ReservationSubmissionRequest createReservationSubmissionRequest(ReservationSubmissionRequestInfo resContext) throws IOException {
    // defending against a couple of common submission format problems
    if (resContext == null) {
        throw new BadRequestException("Input ReservationSubmissionContext should not be null");
    }
    ReservationDefinitionInfo resInfo = resContext.getReservationDefinition();
    if (resInfo == null) {
        throw new BadRequestException("Input ReservationDefinition should not be null");
    }
    ReservationRequestsInfo resReqsInfo = resInfo.getReservationRequests();
    if (resReqsInfo == null || resReqsInfo.getReservationRequest() == null || resReqsInfo.getReservationRequest().size() == 0) {
        throw new BadRequestException("The ReservationDefinition should" + " contain at least one ReservationRequest");
    }
    ReservationRequestInterpreter[] values = ReservationRequestInterpreter.values();
    ReservationRequestInterpreter resInt = values[resReqsInfo.getReservationRequestsInterpreter()];
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    for (ReservationRequestInfo resReqInfo : resReqsInfo.getReservationRequest()) {
        ResourceInfo rInfo = resReqInfo.getCapability();
        Resource capability = Resource.newInstance(rInfo.getMemorySize(), rInfo.getvCores());
        int numContainers = resReqInfo.getNumContainers();
        int minConcurrency = resReqInfo.getMinConcurrency();
        long duration = resReqInfo.getDuration();
        ReservationRequest rr = ReservationRequest.newInstance(capability, numContainers, minConcurrency, duration);
        list.add(rr);
    }
    ReservationRequests reqs = ReservationRequests.newInstance(list, resInt);
    ReservationDefinition rDef = ReservationDefinition.newInstance(resInfo.getArrival(), resInfo.getDeadline(), reqs, resInfo.getReservationName());
    ReservationId reservationId = ReservationId.parseReservationId(resContext.getReservationId());
    ReservationSubmissionRequest request = ReservationSubmissionRequest.newInstance(rDef, resContext.getQueue(), reservationId);
    return request;
}
Also used : ReservationRequestsInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestsInfo) ResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo) LocalResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LocalResourceInfo) ReservationRequestInterpreter(org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) GetNewReservationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ArrayList(java.util.ArrayList) Resource(org.apache.hadoop.yarn.api.records.Resource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ReservationRequestInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestInfo) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinitionInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationDefinitionInfo) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException)

Example 15 with ReservationRequest

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

the class RMWebServices method createReservationUpdateRequest.

private ReservationUpdateRequest createReservationUpdateRequest(ReservationUpdateRequestInfo resContext) throws IOException {
    // defending against a couple of common submission format problems
    if (resContext == null) {
        throw new BadRequestException("Input ReservationSubmissionContext should not be null");
    }
    ReservationDefinitionInfo resInfo = resContext.getReservationDefinition();
    if (resInfo == null) {
        throw new BadRequestException("Input ReservationDefinition should not be null");
    }
    ReservationRequestsInfo resReqsInfo = resInfo.getReservationRequests();
    if (resReqsInfo == null || resReqsInfo.getReservationRequest() == null || resReqsInfo.getReservationRequest().size() == 0) {
        throw new BadRequestException("The ReservationDefinition should" + " contain at least one ReservationRequest");
    }
    if (resContext.getReservationId() == null) {
        throw new BadRequestException("Update operations must specify an existing ReservaitonId");
    }
    ReservationRequestInterpreter[] values = ReservationRequestInterpreter.values();
    ReservationRequestInterpreter resInt = values[resReqsInfo.getReservationRequestsInterpreter()];
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    for (ReservationRequestInfo resReqInfo : resReqsInfo.getReservationRequest()) {
        ResourceInfo rInfo = resReqInfo.getCapability();
        Resource capability = Resource.newInstance(rInfo.getMemorySize(), rInfo.getvCores());
        int numContainers = resReqInfo.getNumContainers();
        int minConcurrency = resReqInfo.getMinConcurrency();
        long duration = resReqInfo.getDuration();
        ReservationRequest rr = ReservationRequest.newInstance(capability, numContainers, minConcurrency, duration);
        list.add(rr);
    }
    ReservationRequests reqs = ReservationRequests.newInstance(list, resInt);
    ReservationDefinition rDef = ReservationDefinition.newInstance(resInfo.getArrival(), resInfo.getDeadline(), reqs, resInfo.getReservationName());
    ReservationUpdateRequest request = ReservationUpdateRequest.newInstance(rDef, ReservationId.parseReservationId(resContext.getReservationId()));
    return request;
}
Also used : ReservationRequestsInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestsInfo) ResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo) LocalResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LocalResourceInfo) ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) ReservationRequestInterpreter(org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) GetNewReservationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ArrayList(java.util.ArrayList) Resource(org.apache.hadoop.yarn.api.records.Resource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) ReservationRequestInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestInfo) ReservationDefinitionInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationDefinitionInfo) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException)

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