use of org.apache.hadoop.yarn.api.records.ReservationDefinition 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));
}
use of org.apache.hadoop.yarn.api.records.ReservationDefinition 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));
}
use of org.apache.hadoop.yarn.api.records.ReservationDefinition 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.api.records.ReservationDefinition 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));
}
use of org.apache.hadoop.yarn.api.records.ReservationDefinition in project hadoop by apache.
the class TestReservationInputValidator method createSimpleReservationUpdateRequest.
private ReservationUpdateRequest createSimpleReservationUpdateRequest(int numRequests, int numContainers, long arrival, long deadline, long duration) {
// create a request with a single atomic ask
ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
ReservationDefinition rDef = new ReservationDefinitionPBImpl();
rDef.setArrival(arrival);
rDef.setDeadline(deadline);
if (numRequests > 0) {
ReservationRequests reqs = new ReservationRequestsPBImpl();
rDef.setReservationRequests(reqs);
if (numContainers > 0) {
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), numContainers, 1, duration);
reqs.setReservationResources(Collections.singletonList(r));
reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
}
}
request.setReservationDefinition(rDef);
request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
return request;
}
Aggregations