Search in sources :

Example 31 with ReservationId

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

the class TestAlignedPlanner method testAllAccept.

@Test
public void testAllAccept() 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
    step) }, ReservationRequestInterpreter.R_ALL, "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, 10 * step, 11 * step, 20, 1024, 1));
    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 32 with ReservationId

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

the class TestAlignedPlanner method testAnyImpossible.

@Test
public void testAnyImpossible() 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
    3 * step), ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    20, // Concurrency
    20, // Duration
    2 * step) }, ReservationRequestInterpreter.R_ANY, "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 33 with ReservationId

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

the class TestAlignedPlanner method testOrderNoGapImpossible.

@Test
public void testOrderNoGapImpossible() throws PlanningException {
    // Prepare basic plan
    int numJobsInScenario = initializeScenario2();
    // Create reservation
    ReservationDefinition rr1 = createReservationDefinition(// Job arrival time
    10L, // 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
    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 34 with ReservationId

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

the class TestAlignedPlanner method testLoadedDurationIntervals.

@Test
public void testLoadedDurationIntervals() throws PlanningException {
    int numJobsInScenario = initializeScenario3();
    // 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
    80, // Concurrency
    10, // Duration
    step) }, ReservationRequestInterpreter.R_ALL, "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, 10 * step, 11 * step, 20, 1024, 1));
    assertTrue(alloc1.toString(), check(alloc1, 11 * step, 12 * step, 20, 1024, 1));
    assertTrue(alloc1.toString(), check(alloc1, 12 * step, 13 * step, 40, 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 35 with ReservationId

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

the class TestAlignedPlanner method testAllImpossible.

@Test
public void testAllImpossible() 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_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() == 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)

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