Search in sources :

Example 61 with ReservationDefinition

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

the class TestAlignedPlanner method testCostFunction.

@Test
public void testCostFunction() throws PlanningException {
    // Create large memory reservation
    ReservationDefinition rr7Mem1Core = createReservationDefinition(// Job arrival time
    10 * step, // Job deadline
    11 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(7 * 1024, 1), // Num containers
    1, // Concurrency
    1, // Duration
    step) }, ReservationRequestInterpreter.R_ALL, "u1");
    // Create reservation
    ReservationDefinition rr6Mem6Cores = createReservationDefinition(// Job arrival time
    10 * step, // Job deadline
    11 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(6 * 1024, 6), // Num containers
    1, // Concurrency
    1, // Duration
    step) }, ReservationRequestInterpreter.R_ALL, "u2");
    // Create reservation
    ReservationDefinition rr = createReservationDefinition(// Job arrival time
    10 * step, // Job deadline
    12 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    1, // Concurrency
    1, // Duration
    step) }, ReservationRequestInterpreter.R_ALL, "u3");
    // Create reservation IDs
    ReservationId reservationID1 = ReservationSystemTestUtil.getNewReservationId();
    ReservationId reservationID2 = ReservationSystemTestUtil.getNewReservationId();
    ReservationId reservationID3 = ReservationSystemTestUtil.getNewReservationId();
    // Add all
    agent.createReservation(reservationID1, "u1", plan, rr7Mem1Core);
    agent.createReservation(reservationID2, "u2", plan, rr6Mem6Cores);
    agent.createReservation(reservationID3, "u3", plan, rr);
    // Get reservation
    ReservationAllocation alloc3 = plan.getReservationById(reservationID3);
    assertTrue(alloc3.toString(), check(alloc3, 10 * step, 11 * step, 0, 1024, 1));
    assertTrue(alloc3.toString(), check(alloc3, 11 * step, 12 * step, 1, 1024, 1));
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) InMemoryReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation) ReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation) Test(org.junit.Test)

Example 62 with ReservationDefinition

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

the class TestAlignedPlanner method testUpdate.

@Test
public void testUpdate() throws PlanningException {
    // Create flexible reservation
    ReservationDefinition rrFlex = createReservationDefinition(// Job arrival time
    10 * step, // Job deadline
    14 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    100, // Concurrency
    1, // Duration
    2 * step) }, ReservationRequestInterpreter.R_ALL, "u1");
    // Create blocking reservation
    ReservationDefinition rrBlock = createReservationDefinition(// Job arrival time
    10 * step, // Job deadline
    11 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    100, // Concurrency
    100, // Duration
    step) }, ReservationRequestInterpreter.R_ALL, "u1");
    // Create reservation IDs
    ReservationId flexReservationID = ReservationSystemTestUtil.getNewReservationId();
    ReservationId blockReservationID = ReservationSystemTestUtil.getNewReservationId();
    // Add block, add flex, remove block, update flex
    agent.createReservation(blockReservationID, "uBlock", plan, rrBlock);
    agent.createReservation(flexReservationID, "uFlex", plan, rrFlex);
    agent.deleteReservation(blockReservationID, "uBlock", plan);
    agent.updateReservation(flexReservationID, "uFlex", plan, rrFlex);
    // CHECK: allocation was accepted
    assertTrue("Agent-based allocation failed", flexReservationID != null);
    assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 1);
    // Get reservation
    ReservationAllocation alloc1 = plan.getReservationById(flexReservationID);
    // Verify allocation
    assertTrue(alloc1.toString(), check(alloc1, 10 * step, 14 * step, 50, 1024, 1));
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) InMemoryReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation) ReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation) Test(org.junit.Test)

Example 63 with ReservationDefinition

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

the class TestAlignedPlanner method testOrderNoGapImpossible2.

@Test
public void testOrderNoGapImpossible2() throws PlanningException {
    // Prepare basic plan
    int numJobsInScenario = initializeScenario2();
    // Create reservation
    ReservationDefinition rr1 = createReservationDefinition(// Job arrival time
    10 * step, // Job deadline
    13 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    20, // Concurrency
    20, // Duration
    step), ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    10, // Concurrency
    10, // Duration
    step) }, ReservationRequestInterpreter.R_ORDER_NO_GAP, "u1");
    // Add reservation
    try {
        ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
        agent.createReservation(reservationID, "u1", plan, rr1);
        fail();
    } catch (PlanningException e) {
    // Expected failure
    }
    // CHECK: allocation was not accepted
    assertTrue("Agent-based allocation should have failed", plan.getAllReservations().size() == numJobsInScenario);
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) PlanningException(org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException) Test(org.junit.Test)

Example 64 with ReservationDefinition

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

the class TestAlignedPlanner method testAnyAccept.

@Test
public void testAnyAccept() throws PlanningException {
    // Prepare basic plan
    int numJobsInScenario = initializeScenario2();
    // Create reservation
    ReservationDefinition rr1 = createReservationDefinition(// Job arrival time
    10 * step, // Job deadline
    15 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    20, // Concurrency
    20, // Duration
    step), ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    20, // Concurrency
    20, // Duration
    2 * step) }, ReservationRequestInterpreter.R_ANY, "u1");
    // Add reservation
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr1);
    // CHECK: allocation was accepted
    assertTrue("Agent-based allocation failed", reservationID != null);
    assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == numJobsInScenario + 1);
    // Get reservation
    ReservationAllocation alloc1 = plan.getReservationById(reservationID);
    // Verify allocation
    assertTrue(alloc1.toString(), check(alloc1, 14 * step, 15 * step, 20, 1024, 1));
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) InMemoryReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation) ReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation) Test(org.junit.Test)

Example 65 with ReservationDefinition

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

the class TestReservationInputValidator method createSimpleReservationUpdateRequest.

private ReservationUpdateRequest createSimpleReservationUpdateRequest(int numRequests, int numContainers, long arrival, long deadline, long duration) {
    // create a request with a single atomic ask
    ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
    ReservationDefinition rDef = new ReservationDefinitionPBImpl();
    rDef.setArrival(arrival);
    rDef.setDeadline(deadline);
    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.setReservationDefinition(rDef);
    request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
    return request;
}
Also used : ReservationUpdateRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationUpdateRequestPBImpl) ReservationRequestsPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl) ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) 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)

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