use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestAlignedPlanner method testFromCluster.
@Test
public void testFromCluster() throws PlanningException {
// int numJobsInScenario = initializeScenario3();
List<ReservationDefinition> list = new ArrayList<ReservationDefinition>();
// Create reservation
list.add(createReservationDefinition(// Job arrival time
1425716392178L, // Job deadline
1425722262791L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
7, // Concurrency
1, // Duration
587000) }, ReservationRequestInterpreter.R_ALL, "u1"));
list.add(createReservationDefinition(// Job arrival time
1425716406178L, // Job deadline
1425721255841L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
6, // Concurrency
1, // Duration
485000) }, ReservationRequestInterpreter.R_ALL, "u2"));
list.add(createReservationDefinition(// Job arrival time
1425716399178L, // Job deadline
1425723780138L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
6, // Concurrency
1, // Duration
738000) }, ReservationRequestInterpreter.R_ALL, "u3"));
list.add(createReservationDefinition(// Job arrival time
1425716437178L, // Job deadline
1425722968378L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
7, // Concurrency
1, // Duration
653000) }, ReservationRequestInterpreter.R_ALL, "u4"));
list.add(createReservationDefinition(// Job arrival time
1425716406178L, // Job deadline
1425721926090L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
6, // Concurrency
1, // Duration
552000) }, ReservationRequestInterpreter.R_ALL, "u5"));
list.add(createReservationDefinition(// Job arrival time
1425716379178L, // Job deadline
1425722238553L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
6, // Concurrency
1, // Duration
586000) }, ReservationRequestInterpreter.R_ALL, "u6"));
list.add(createReservationDefinition(// Job arrival time
1425716407178L, // Job deadline
1425722908317L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
7, // Concurrency
1, // Duration
650000) }, ReservationRequestInterpreter.R_ALL, "u7"));
list.add(createReservationDefinition(// Job arrival time
1425716452178L, // Job deadline
1425722841562L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
6, // Concurrency
1, // Duration
639000) }, ReservationRequestInterpreter.R_ALL, "u8"));
list.add(createReservationDefinition(// Job arrival time
1425716384178L, // Job deadline
1425721766129L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
7, // Concurrency
1, // Duration
538000) }, ReservationRequestInterpreter.R_ALL, "u9"));
list.add(createReservationDefinition(// Job arrival time
1425716437178L, // Job deadline
1425722507886L, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
5, // Concurrency
1, // Duration
607000) }, ReservationRequestInterpreter.R_ALL, "u10"));
// Add reservation
int i = 1;
for (ReservationDefinition rr : list) {
ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
agent.createReservation(reservationID, "u" + Integer.toString(i), plan, rr);
++i;
}
// CHECK: allocation was accepted
assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == list.size());
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestAlignedPlanner method testSingleReservationAccept.
@Test
public void testSingleReservationAccept() throws PlanningException {
// Prepare basic plan
int numJobsInScenario = initializeScenario1();
// Create reservation
ReservationDefinition rr1 = createReservationDefinition(// Job arrival time
5 * step, // Job deadline
20 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(2048, 2), // Num containers
10, // Concurrency
5, // Duration
10 * step) }, ReservationRequestInterpreter.R_ORDER, "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, 20 * step, 10, 2048, 2));
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestGreedyReservationAgent method testSharingPolicyFeedback.
@SuppressWarnings("javadoc")
@Test
public void testSharingPolicyFeedback() throws PlanningException {
prepareBasicPlan();
// let's constraint the instantaneous allocation and see the
// policy kicking in during planning
float instConstraint = 40;
float avgConstraint = 40;
ReservationSchedulerConfiguration conf = ReservationSystemTestUtil.createConf(plan.getQueueName(), 100000, instConstraint, avgConstraint);
plan.getSharingPolicy().init(plan.getQueueName(), conf);
// create a request with a single atomic ask
ReservationDefinition rr = new ReservationDefinitionPBImpl();
rr.setArrival(5 * step);
rr.setDeadline(100 * step);
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 20, 20, 10 * step);
ReservationRequests reqs = new ReservationRequestsPBImpl();
reqs.setReservationResources(Collections.singletonList(r));
rr.setReservationRequests(reqs);
ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
agent.createReservation(reservationID, "u3", plan, rr);
ReservationId reservationID2 = ReservationSystemTestUtil.getNewReservationId();
agent.createReservation(reservationID2, "u3", plan, rr);
ReservationDefinition rr3 = new ReservationDefinitionPBImpl();
rr3.setArrival(5 * step);
rr3.setDeadline(100 * step);
ReservationRequest r3 = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 45, 45, 10 * step);
ReservationRequests reqs3 = new ReservationRequestsPBImpl();
reqs3.setReservationResources(Collections.singletonList(r3));
rr3.setReservationRequests(reqs3);
ReservationId reservationID3 = ReservationSystemTestUtil.getNewReservationId();
try {
// RR3 is simply too big to fit
agent.createReservation(reservationID3, "u3", plan, rr3);
fail();
} catch (PlanningException pe) {
// expected
}
assertTrue("Agent-based allocation failed", reservationID != null);
assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 4);
ReservationAllocation cs = plan.getReservationById(reservationID);
ReservationAllocation cs2 = plan.getReservationById(reservationID2);
ReservationAllocation cs3 = plan.getReservationById(reservationID3);
assertNotNull(cs);
assertNotNull(cs2);
assertNull(cs3);
System.out.println("--------AFTER SIMPLE ALLOCATION (queue: " + reservationID + ")----------");
System.out.println(plan.toString());
System.out.println(plan.toCumulativeString());
if (allocateLeft) {
for (long i = 5 * step; i < 15 * step; i++) {
assertTrue("Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
}
for (long i = 15 * step; i < 25 * step; i++) {
// RR2 is pushed out by the presence of RR
assertTrue("Agent-based allocation unexpected", Resources.equals(cs2.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
}
} else {
for (long i = 90 * step; i < 100 * step; i++) {
assertTrue("Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
}
for (long i = 80 * step; i < 90 * step; i++) {
assertTrue("Agent-based allocation unexpected", Resources.equals(cs2.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
}
}
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestGreedyReservationAgent method testAny.
@Test
public void testAny() throws PlanningException {
prepareBasicPlan();
// create an ANY request, with an impossible step (last in list, first
// considered),
// and two satisfiable ones. We expect the second one to be returned.
ReservationDefinition rr = new ReservationDefinitionPBImpl();
rr.setArrival(100 * step);
rr.setDeadline(120 * step);
ReservationRequests reqs = new ReservationRequestsPBImpl();
reqs.setInterpreter(ReservationRequestInterpreter.R_ANY);
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 5, 5, 10 * step);
ReservationRequest r2 = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 10, 5, 10 * step);
ReservationRequest r3 = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 110, 110, 10 * step);
List<ReservationRequest> list = new ArrayList<ReservationRequest>();
list.add(r);
list.add(r2);
list.add(r3);
reqs.setReservationResources(list);
rr.setReservationRequests(reqs);
// submit to agent
ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
boolean res = agent.createReservation(reservationID, "u1", plan, rr);
// validate results, we expect the second one to be accepted
assertTrue("Agent-based allocation failed", res);
assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 3);
ReservationAllocation cs = plan.getReservationById(reservationID);
if (allocateLeft) {
assertTrue(cs.toString(), check(cs, 100 * step, 110 * step, 5, 1024, 1));
} else {
assertTrue(cs.toString(), check(cs, 110 * step, 120 * step, 20, 1024, 1));
}
System.out.println("--------AFTER ANY ALLOCATION (queue: " + reservationID + ")----------");
System.out.println(plan.toString());
System.out.println(plan.toCumulativeString());
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestReservationInputValidator method testUpdateReservationDoesnotExist.
@Test
public void testUpdateReservationDoesnotExist() {
ReservationUpdateRequest request = createSimpleReservationUpdateRequest(1, 1, 1, 5, 4);
ReservationId rId = request.getReservationId();
when(rSystem.getQueueForReservation(rId)).thenReturn(null);
Plan plan = null;
try {
plan = rrValidator.validateReservationUpdateRequest(rSystem, request);
Assert.fail();
} catch (YarnException e) {
Assert.assertNull(plan);
String message = e.getMessage();
Assert.assertTrue(message.equals(MessageFormat.format("The specified reservation with ID: {0} is unknown. Please try again with a valid reservation.", rId)));
LOG.info(message);
}
}
Aggregations