use of org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest in project hadoop by apache.
the class TestReservationSystemWithRMHA method testFailoverAndSubmitReservation.
@Test
public void testFailoverAndSubmitReservation() throws Exception {
startRMs();
addNodeCapacityToPlan(rm1, 102400, 100);
// Do the failover
explicitFailover();
addNodeCapacityToPlan(rm2, 102400, 100);
ClientRMService clientService = rm2.getClientRMService();
ReservationId reservationID = getNewReservation(clientService).getReservationId();
// create a reservation
ReservationSubmissionRequest request = createReservationSubmissionRequest(reservationID);
ReservationSubmissionResponse response = null;
try {
response = clientService.submitReservation(request);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(response);
Assert.assertNotNull(reservationID);
LOG.info("Submit reservation response: " + reservationID);
ReservationDefinition reservationDefinition = request.getReservationDefinition();
// check if reservation is submitted successfully
Plan plan = rm2.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
validateReservation(plan, reservationID, reservationDefinition);
}
use of org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest in project hadoop by apache.
the class TestReservationSystemWithRMHA method testSubmitReservationFailoverAndDelete.
@Test
public void testSubmitReservationFailoverAndDelete() throws Exception {
startRMs();
addNodeCapacityToPlan(rm1, 102400, 100);
ClientRMService clientService = rm1.getClientRMService();
ReservationId reservationID = getNewReservation(clientService).getReservationId();
// create a reservation
ReservationSubmissionRequest request = createReservationSubmissionRequest(reservationID);
ReservationSubmissionResponse response = null;
try {
response = clientService.submitReservation(request);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(response);
Assert.assertNotNull(reservationID);
LOG.info("Submit reservation response: " + reservationID);
ReservationDefinition reservationDefinition = request.getReservationDefinition();
// Do the failover
explicitFailover();
addNodeCapacityToPlan(rm2, 102400, 100);
// check if reservation exists after failover
Plan plan = rm2.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
validateReservation(plan, reservationID, reservationDefinition);
// delete the reservation
ReservationDeleteRequest deleteRequest = ReservationDeleteRequest.newInstance(reservationID);
ReservationDeleteResponse deleteResponse = null;
clientService = rm2.getClientRMService();
try {
deleteResponse = clientService.deleteReservation(deleteRequest);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(deleteResponse);
Assert.assertNull(plan.getReservationById(reservationID));
}
use of org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest in project hadoop by apache.
the class TestReservationSystemWithRMHA method testSubmitUpdateReservationFailoverAndDelete.
@Test
public void testSubmitUpdateReservationFailoverAndDelete() throws Exception {
startRMs();
addNodeCapacityToPlan(rm1, 102400, 100);
ClientRMService clientService = rm1.getClientRMService();
ReservationId reservationID = getNewReservation(clientService).getReservationId();
// create a reservation
ReservationSubmissionRequest request = createReservationSubmissionRequest(reservationID);
ReservationSubmissionResponse response = null;
try {
response = clientService.submitReservation(request);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(response);
Assert.assertNotNull(reservationID);
LOG.info("Submit reservation response: " + reservationID);
ReservationDefinition reservationDefinition = request.getReservationDefinition();
// check if reservation is submitted successfully
Plan plan = rm1.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
validateReservation(plan, reservationID, reservationDefinition);
// update the reservation
long newDeadline = reservationDefinition.getDeadline() + 100;
reservationDefinition.setDeadline(newDeadline);
ReservationUpdateRequest updateRequest = ReservationUpdateRequest.newInstance(reservationDefinition, reservationID);
ReservationUpdateResponse updateResponse = null;
try {
updateResponse = clientService.updateReservation(updateRequest);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(updateResponse);
validateReservation(plan, reservationID, reservationDefinition);
// Do the failover
explicitFailover();
addNodeCapacityToPlan(rm2, 102400, 100);
// check if reservation exists after failover
plan = rm2.getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ);
validateReservation(plan, reservationID, reservationDefinition);
// delete the reservation
ReservationDeleteRequest deleteRequest = ReservationDeleteRequest.newInstance(reservationID);
ReservationDeleteResponse deleteResponse = null;
clientService = rm2.getClientRMService();
try {
deleteResponse = clientService.deleteReservation(deleteRequest);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(deleteResponse);
Assert.assertNull(plan.getReservationById(reservationID));
}
use of org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest in project hadoop by apache.
the class TestReservationInputValidator method testSubmitReservationNoDefinition.
@Test
public void testSubmitReservationNoDefinition() {
ReservationSubmissionRequest request = new ReservationSubmissionRequestPBImpl();
request.setQueue(PLAN_NAME);
Plan plan = null;
try {
plan = rrValidator.validateReservationSubmissionRequest(rSystem, request, ReservationSystemTestUtil.getNewReservationId());
Assert.fail();
} catch (YarnException e) {
Assert.assertNull(plan);
String message = e.getMessage();
Assert.assertTrue(message.equals("Missing reservation definition. Please try again by specifying a reservation definition."));
LOG.info(message);
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest in project hadoop by apache.
the class ReservationSystemTestUtil method createSimpleReservationRequest.
public static ReservationSubmissionRequest createSimpleReservationRequest(ReservationId reservationId, int numContainers, long arrival, long deadline, long duration, Priority priority) {
// create a request with a single atomic ask
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), numContainers, 1, duration);
ReservationRequests reqs = ReservationRequests.newInstance(Collections.singletonList(r), ReservationRequestInterpreter.R_ALL);
ReservationDefinition rDef = ReservationDefinition.newInstance(arrival, deadline, reqs, "testClientRMService#reservation", "0", priority);
ReservationSubmissionRequest request = ReservationSubmissionRequest.newInstance(rDef, reservationQ, reservationId);
return request;
}
Aggregations