use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestClientRMService method testListReservationsByTimeInterval.
@Test
public void testListReservationsByTimeInterval() {
ResourceManager rm = setupResourceManager();
ClientRMService clientService = rm.getClientRMService();
Clock clock = new UTCClock();
long arrival = clock.getTime();
long duration = 60000;
long deadline = (long) (arrival + 1.05 * duration);
ReservationSubmissionRequest sRequest = submitReservationTestHelper(clientService, arrival, deadline, duration);
// List reservations, search by a point in time within the reservation
// range.
arrival = clock.getTime();
ReservationId reservationID = sRequest.getReservationId();
ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", arrival + duration / 2, arrival + duration / 2, true);
ReservationListResponse response = null;
try {
response = clientService.listReservations(request);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(response);
Assert.assertEquals(1, response.getReservationAllocationState().size());
Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
// List reservations, search by time within reservation interval.
request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, Long.MAX_VALUE, true);
response = null;
try {
response = clientService.listReservations(request);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(response);
Assert.assertEquals(1, response.getReservationAllocationState().size());
Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
// Verify that the full resource allocations exist.
Assert.assertTrue(response.getReservationAllocationState().get(0).getResourceAllocationRequests().size() > 0);
// Verify that the full RDL is returned.
ReservationRequests reservationRequests = response.getReservationAllocationState().get(0).getReservationDefinition().getReservationRequests();
Assert.assertTrue(reservationRequests.getInterpreter().toString().equals("R_ALL"));
Assert.assertTrue(reservationRequests.getReservationResources().get(0).getDuration() == duration);
rm.stop();
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class ReservationACLsTestBase method verifyDeleteReservationSuccess.
private void verifyDeleteReservationSuccess(String killer, String originalSubmitter, String queueName) throws Exception {
ReservationId reservationId = createReservation(originalSubmitter);
submitReservation(originalSubmitter, queueName, reservationId);
deleteReservation(killer, reservationId);
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class ReservationACLsTestBase method verifyListReservationByIdSuccess.
private void verifyListReservationByIdSuccess(String lister, String originalSubmitter, String queueName) throws Exception {
ReservationId reservationId = createReservation(originalSubmitter);
submitReservation(originalSubmitter, queueName, reservationId);
ReservationListResponse adminResponse = listReservationById(lister, reservationId, queueName);
assert (adminResponse.getReservationAllocationState().size() == 1);
assert (adminResponse.getReservationAllocationState().get(0).getUser().equals(originalSubmitter));
deleteReservation(originalSubmitter, reservationId);
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class ReservationACLsTestBase method verifyListReservationSuccess.
private void verifyListReservationSuccess(String lister, String originalSubmitter, String queueName) throws Exception {
ReservationId reservationId = createReservation(originalSubmitter);
submitReservation(originalSubmitter, queueName, reservationId);
ReservationListResponse adminResponse = listReservation(lister, queueName);
assert (adminResponse.getReservationAllocationState().size() == 1);
assert (adminResponse.getReservationAllocationState().get(0).getUser().equals(originalSubmitter));
deleteReservation(originalSubmitter, reservationId);
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestGreedyReservationAgent method testOrder.
@Test
public void testOrder() throws PlanningException {
prepareBasicPlan();
// create a completely utilized segment around time 30
int[] f = { 100, 100 };
ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(30 * step, 30 * step + f.length * step, f.length * step);
assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", 30 * step, 30 * step + f.length * step, ReservationSystemTestUtil.generateAllocation(30 * step, step, f), res, minAlloc), false));
// create a chain of 4 RR, mixing gang and non-gang
ReservationDefinition rr = new ReservationDefinitionPBImpl();
rr.setArrival(0 * step);
rr.setDeadline(70 * step);
ReservationRequests reqs = new ReservationRequestsPBImpl();
reqs.setInterpreter(ReservationRequestInterpreter.R_ORDER);
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 10, 1, 10 * step);
ReservationRequest r2 = ReservationRequest.newInstance(Resource.newInstance(1024, 1), 10, 10, 20 * step);
List<ReservationRequest> list = new ArrayList<ReservationRequest>();
list.add(r);
list.add(r2);
list.add(r);
list.add(r2);
reqs.setReservationResources(list);
rr.setReservationRequests(reqs);
// submit to agent
ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
agent.createReservation(reservationID, "u1", plan, rr);
// validate
assertTrue("Agent-based allocation failed", reservationID != null);
assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 4);
ReservationAllocation cs = plan.getReservationById(reservationID);
if (allocateLeft) {
assertTrue(cs.toString(), check(cs, 0 * step, 10 * step, 20, 1024, 1));
assertTrue(cs.toString(), check(cs, 10 * step, 30 * step, 10, 1024, 1));
assertTrue(cs.toString(), check(cs, 32 * step, 42 * step, 20, 1024, 1));
assertTrue(cs.toString(), check(cs, 42 * step, 62 * step, 10, 1024, 1));
} else {
assertTrue(cs.toString(), check(cs, 0 * step, 10 * step, 20, 1024, 1));
assertTrue(cs.toString(), check(cs, 10 * step, 30 * step, 10, 1024, 1));
assertTrue(cs.toString(), check(cs, 40 * step, 50 * step, 20, 1024, 1));
assertTrue(cs.toString(), check(cs, 50 * step, 70 * step, 10, 1024, 1));
}
System.out.println("--------AFTER ORDER ALLOCATION (queue: " + reservationID + ")----------");
System.out.println(plan.toString());
System.out.println(plan.toCumulativeString());
}
Aggregations