Search in sources :

Example 31 with PlanningException

use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException in project hadoop by apache.

the class TestInMemoryPlan method testGetReservationsWithNoInput.

@Test
public void testGetReservationsWithNoInput() {
    Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L, resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    int[] alloc = { 10, 10, 10, 10, 10, 10 };
    int start = 100;
    ReservationAllocation rAllocation = createReservationAllocation(reservationID, start, alloc);
    Assert.assertNull(plan.getReservationById(reservationID));
    try {
        plan.addReservation(rAllocation, false);
    } catch (PlanningException e) {
        Assert.fail(e.getMessage());
    }
    // Verify that getReservations defaults to getting all reservations if no
    // reservationID, time interval, and user is provided,
    Set<ReservationAllocation> rAllocations = plan.getReservations(null, null, "");
    Assert.assertTrue(rAllocations.size() == 1);
    Assert.assertTrue(rAllocation.compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) PlanningException(org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException) Test(org.junit.Test)

Example 32 with PlanningException

use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException 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 33 with PlanningException

use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException 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 34 with PlanningException

use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException in project hadoop by apache.

the class RLESparseResourceAllocation method negate.

private static NavigableMap<Long, Resource> negate(RLEOperator operator, NavigableMap<Long, Resource> a) throws PlanningException {
    TreeMap<Long, Resource> out = new TreeMap<Long, Resource>();
    for (Entry<Long, Resource> e : a.entrySet()) {
        Resource val = Resources.negate(e.getValue());
        // test for negative value and throws
        if (operator == RLEOperator.subtractTestNonNegative && (Resources.fitsIn(val, ZERO_RESOURCE) && !Resources.equals(val, ZERO_RESOURCE))) {
            throw new PlanningException("RLESparseResourceAllocation: merge failed as the " + "resulting RLESparseResourceAllocation would be negative");
        }
        out.put(e.getKey(), val);
    }
    return out;
}
Also used : Resource(org.apache.hadoop.yarn.api.records.Resource) PlanningException(org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException) TreeMap(java.util.TreeMap)

Example 35 with PlanningException

use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException in project hadoop by apache.

the class RLESparseResourceAllocation method combineValue.

private static Resource combineValue(RLEOperator op, ResourceCalculator resCalc, Resource clusterResource, Entry<Long, Resource> eA, Entry<Long, Resource> eB) throws PlanningException {
    // deal with nulls
    if (eA == null || eA.getValue() == null) {
        if (eB == null || eB.getValue() == null) {
            return null;
        }
        if (op == RLEOperator.subtract) {
            return Resources.negate(eB.getValue());
        } else {
            return eB.getValue();
        }
    }
    if (eB == null || eB.getValue() == null) {
        return eA.getValue();
    }
    Resource a = eA.getValue();
    Resource b = eB.getValue();
    switch(op) {
        case add:
            return Resources.add(a, b);
        case subtract:
            return Resources.subtract(a, b);
        case subtractTestNonNegative:
            if (!Resources.fitsIn(b, a)) {
                throw new PlanningException("RLESparseResourceAllocation: merge failed as the " + "resulting RLESparseResourceAllocation would be negative");
            } else {
                return Resources.subtract(a, b);
            }
        case min:
            return Resources.min(resCalc, clusterResource, a, b);
        case max:
            return Resources.max(resCalc, clusterResource, a, b);
        default:
            return null;
    }
}
Also used : Resource(org.apache.hadoop.yarn.api.records.Resource) PlanningException(org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)

Aggregations

PlanningException (org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)35 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)27 Test (org.junit.Test)24 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)12 Resource (org.apache.hadoop.yarn.api.records.Resource)8 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)5 ArrayList (java.util.ArrayList)4 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)4 ReservationDefinitionPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl)4 ReservationRequestsPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl)4 TreeMap (java.util.TreeMap)3 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)3 Plan (org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan)3 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)3 RLESparseResourceAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.RLESparseResourceAllocation)2 ReservationInterval (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationInterval)2 ReservationSchedulerConfiguration (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSchedulerConfiguration)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1