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);
}
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);
}
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);
}
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;
}
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;
}
}
Aggregations