Search in sources :

Example 81 with ReservationId

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

the class TestAlignedPlanner method testImpossibleDuration.

@Test
public void testImpossibleDuration() throws PlanningException {
    // 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
    10 * step) }, ReservationRequestInterpreter.R_ALL, "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() == 0);
}
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 82 with ReservationId

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

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

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

use of org.apache.hadoop.yarn.api.records.ReservationId 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)

Aggregations

ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)120 Test (org.junit.Test)85 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)40 PlanningException (org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)27 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)19 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)17 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)16 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)16 WebResource (com.sun.jersey.api.client.WebResource)14 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)14 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)13 JSONObject (org.codehaus.jettison.json.JSONObject)13 ArrayList (java.util.ArrayList)11 ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)11 IOException (java.io.IOException)10 Resource (org.apache.hadoop.yarn.api.records.Resource)10 ReservationDefinitionPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl)10 ReservationRequestsPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl)10 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)9 ReservationAllocationStateProto (org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto)9