use of org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest in project hadoop by apache.
the class TestClientRMService method testUpdateReservation.
@Test
public void testUpdateReservation() {
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);
ReservationDefinition rDef = sRequest.getReservationDefinition();
ReservationRequest rr = rDef.getReservationRequests().getReservationResources().get(0);
ReservationId reservationID = sRequest.getReservationId();
rr.setNumContainers(5);
arrival = clock.getTime();
duration = 30000;
deadline = (long) (arrival + 1.05 * duration);
rr.setDuration(duration);
rDef.setArrival(arrival);
rDef.setDeadline(deadline);
ReservationUpdateRequest uRequest = ReservationUpdateRequest.newInstance(rDef, reservationID);
ReservationUpdateResponse uResponse = null;
try {
uResponse = clientService.updateReservation(uRequest);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(uResponse);
System.out.println("Update reservation response: " + uResponse);
rm.stop();
}
use of org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest in project hadoop by apache.
the class TestReservationInputValidator method testUpdateReservationInvalidPlan.
@Test
public void testUpdateReservationInvalidPlan() {
ReservationUpdateRequest request = createSimpleReservationUpdateRequest(1, 1, 1, 5, 4);
when(rSystem.getPlan(PLAN_NAME)).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.endsWith(" is not associated with any valid plan. Please try again with a valid reservation."));
LOG.info(message);
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest in project hadoop by apache.
the class TestReservationInputValidator method testUpdateReservationInvalidRR.
@Test
public void testUpdateReservationInvalidRR() {
ReservationUpdateRequest request = createSimpleReservationUpdateRequest(0, 0, 1, 5, 3);
Plan plan = null;
try {
plan = rrValidator.validateReservationUpdateRequest(rSystem, request);
Assert.fail();
} catch (YarnException e) {
Assert.assertNull(plan);
String message = e.getMessage();
Assert.assertTrue(message.startsWith("No resources have been specified to reserve"));
LOG.info(message);
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest 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);
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest in project hadoop by apache.
the class TestReservationInputValidator method testUpdateReservationEmptyRR.
@Test
public void testUpdateReservationEmptyRR() {
ReservationUpdateRequest request = createSimpleReservationUpdateRequest(1, 0, 1, 5, 3);
Plan plan = null;
try {
plan = rrValidator.validateReservationUpdateRequest(rSystem, request);
Assert.fail();
} catch (YarnException e) {
Assert.assertNull(plan);
String message = e.getMessage();
Assert.assertTrue(message.startsWith("No resources have been specified to reserve"));
LOG.info(message);
}
}
Aggregations