Search in sources :

Example 6 with ReservationRequest

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

the class TestGreedyReservationAgent method testSingleSliding.

@Test
public void testSingleSliding() throws PlanningException {
    prepareBasicPlan();
    // create a single request for which we need subsequent (tight) packing.
    ReservationDefinition rr = new ReservationDefinitionPBImpl();
    rr.setArrival(100 * step);
    rr.setDeadline(120 * step);
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 200, 10, 10 * step);
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    list.add(r);
    reqs.setReservationResources(list);
    rr.setReservationRequests(reqs);
    // submit to agent
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr);
    // validate results, we expect the second one to be accepted
    assertTrue("Agent-based allocation failed", reservationID != null);
    assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 3);
    ReservationAllocation cs = plan.getReservationById(reservationID);
    assertTrue(cs.toString(), check(cs, 100 * step, 120 * step, 100, 1024, 1));
    System.out.println("--------AFTER packed 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 7 with ReservationRequest

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

the class TestGreedyReservationAgent method testAll.

@Test
public void testAll() throws PlanningException {
    prepareBasicPlan();
    // create an ALL request
    ReservationDefinition rr = new ReservationDefinitionPBImpl();
    rr.setArrival(100 * step);
    rr.setDeadline(120 * step);
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 5, 5, 10 * step);
    ReservationRequest r2 = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 10, 10, 20 * step);
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    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 results, we expect the second one to be accepted
    assertTrue("Agent-based allocation failed", reservationID != null);
    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, 25, 1024, 1));
        assertTrue(cs.toString(), check(cs, 110 * step, 120 * step, 20, 1024, 1));
    } else {
        assertTrue(cs.toString(), check(cs, 100 * step, 110 * step, 20, 1024, 1));
        assertTrue(cs.toString(), check(cs, 110 * step, 120 * step, 25, 1024, 1));
    }
    System.out.println("--------AFTER ALL 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 8 with ReservationRequest

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

the class TestGreedyReservationAgent method testOrderNoGapImpossible.

@Test
public void testOrderNoGapImpossible() throws PlanningException {
    prepareBasicPlan();
    // create a completely utilized segment at time 30
    int[] f = { 100, 100 };
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(30, 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(0L);
    rr.setDeadline(70L);
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setInterpreter(ReservationRequestInterpreter.R_ORDER_NO_GAP);
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 10, 1, 10);
    ReservationRequest r2 = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 10, 10, 20);
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    list.add(r);
    list.add(r2);
    list.add(r);
    list.add(r2);
    reqs.setReservationResources(list);
    rr.setReservationRequests(reqs);
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    boolean result = false;
    try {
        // submit to agent
        result = agent.createReservation(reservationID, "u1", plan, rr);
        fail();
    } catch (PlanningException p) {
    // expected
    }
    // validate
    assertFalse("Agent-based allocation should have failed", result);
    assertTrue("Agent-based allocation should have failed", plan.getAllReservations().size() == 3);
    System.out.println("--------AFTER ORDER_NO_GAP IMPOSSIBLE 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) PlanningException(org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException) Test(org.junit.Test)

Example 9 with ReservationRequest

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

the class TestGreedyReservationAgent method testSimple.

@SuppressWarnings("javadoc")
@Test
public void testSimple() throws PlanningException {
    prepareBasicPlan();
    // create a request with a single atomic ask
    ReservationDefinition rr = new ReservationDefinitionPBImpl();
    rr.setArrival(5 * step);
    rr.setDeadline(20 * step);
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 10, 5, 10 * step);
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setReservationResources(Collections.singletonList(r));
    rr.setReservationRequests(reqs);
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr);
    assertTrue("Agent-based allocation failed", reservationID != null);
    assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 3);
    ReservationAllocation cs = plan.getReservationById(reservationID);
    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 * 10, 2 * 10)));
        }
    } else {
        for (long i = 10 * step; i < 20 * step; i++) {
            assertTrue("Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 10, 2 * 10)));
        }
    }
}
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) InMemoryReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation) ReservationAllocation(org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation) Test(org.junit.Test)

Example 10 with ReservationRequest

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

the class TestAlignedPlanner method testFromCluster.

@Test
public void testFromCluster() throws PlanningException {
    // int numJobsInScenario = initializeScenario3();
    List<ReservationDefinition> list = new ArrayList<ReservationDefinition>();
    // Create reservation
    list.add(createReservationDefinition(// Job arrival time
    1425716392178L, // Job deadline
    1425722262791L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    7, // Concurrency
    1, // Duration
    587000) }, ReservationRequestInterpreter.R_ALL, "u1"));
    list.add(createReservationDefinition(// Job arrival time
    1425716406178L, // Job deadline
    1425721255841L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    6, // Concurrency
    1, // Duration
    485000) }, ReservationRequestInterpreter.R_ALL, "u2"));
    list.add(createReservationDefinition(// Job arrival time
    1425716399178L, // Job deadline
    1425723780138L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    6, // Concurrency
    1, // Duration
    738000) }, ReservationRequestInterpreter.R_ALL, "u3"));
    list.add(createReservationDefinition(// Job arrival time
    1425716437178L, // Job deadline
    1425722968378L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    7, // Concurrency
    1, // Duration
    653000) }, ReservationRequestInterpreter.R_ALL, "u4"));
    list.add(createReservationDefinition(// Job arrival time
    1425716406178L, // Job deadline
    1425721926090L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    6, // Concurrency
    1, // Duration
    552000) }, ReservationRequestInterpreter.R_ALL, "u5"));
    list.add(createReservationDefinition(// Job arrival time
    1425716379178L, // Job deadline
    1425722238553L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    6, // Concurrency
    1, // Duration
    586000) }, ReservationRequestInterpreter.R_ALL, "u6"));
    list.add(createReservationDefinition(// Job arrival time
    1425716407178L, // Job deadline
    1425722908317L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    7, // Concurrency
    1, // Duration
    650000) }, ReservationRequestInterpreter.R_ALL, "u7"));
    list.add(createReservationDefinition(// Job arrival time
    1425716452178L, // Job deadline
    1425722841562L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    6, // Concurrency
    1, // Duration
    639000) }, ReservationRequestInterpreter.R_ALL, "u8"));
    list.add(createReservationDefinition(// Job arrival time
    1425716384178L, // Job deadline
    1425721766129L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    7, // Concurrency
    1, // Duration
    538000) }, ReservationRequestInterpreter.R_ALL, "u9"));
    list.add(createReservationDefinition(// Job arrival time
    1425716437178L, // Job deadline
    1425722507886L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    5, // Concurrency
    1, // Duration
    607000) }, ReservationRequestInterpreter.R_ALL, "u10"));
    // Add reservation
    int i = 1;
    for (ReservationDefinition rr : list) {
        ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
        agent.createReservation(reservationID, "u" + Integer.toString(i), plan, rr);
        ++i;
    }
    // CHECK: allocation was accepted
    assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == list.size());
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ArrayList(java.util.ArrayList) 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