use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestRMWebServicesReservation method testEmptyQueueRequestListReservation.
@Test
public void testEmptyQueueRequestListReservation() throws Exception {
rm.start();
setupCluster(100);
ReservationId id1 = getReservationIdTestHelper(1);
ReservationId id2 = getReservationIdTestHelper(2);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, clock.getTime(), "res_1", id1);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, clock.getTime(), "res_2", id2);
WebResource resource = constructWebResource(LIST_RESERVATION_PATH);
testListReservationHelper(resource, Status.BAD_REQUEST);
rm.stop();
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestRMWebServicesReservation method testSameTimeIntervalRequestListReservation.
@Test
public void testSameTimeIntervalRequestListReservation() throws Exception {
rm.start();
setupCluster(100);
long time = clock.getTime() + MINIMUM_RESOURCE_DURATION;
ReservationId id1 = getReservationIdTestHelper(1);
ReservationId id2 = getReservationIdTestHelper(2);
// If authentication is not enabled then id1 and id2 will be null
if (!this.isAuthenticationEnabled() && id1 == null && id2 == null) {
return;
}
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, time, "res_1", id1);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, time + MINIMUM_RESOURCE_DURATION, "res_2", id2);
String timeParam = Long.toString(time + MINIMUM_RESOURCE_DURATION / 2);
WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("start-time", timeParam).queryParam("end-time", timeParam).queryParam("include-resource-allocations", "true").queryParam("queue", DEFAULT_QUEUE);
JSONObject json = testListReservationHelper(resource);
if (!this.isAuthenticationEnabled() && json == null) {
return;
}
JSONObject reservations = json.getJSONObject("reservations");
testRDLHelper(reservations);
String reservationName = reservations.getJSONObject("reservation-definition").getString("reservation-name");
assertEquals(reservationName, "res_1");
rm.stop();
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestRMWebServicesReservation method testSubmitDifferentReservationWithSameId.
@Test
public void testSubmitDifferentReservationWithSameId() throws Exception {
rm.start();
setupCluster(100);
ReservationId rid = getReservationIdTestHelper(1);
long currentTimestamp = clock.getTime() + MINIMUM_RESOURCE_DURATION;
ClientResponse response = reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, currentTimestamp, "res1", rid);
// Make sure that the first submission is successful
if (this.isAuthenticationEnabled()) {
assertTrue(isHttpSuccessResponse(response));
}
// Change the reservation definition.
response = reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, currentTimestamp + MINIMUM_RESOURCE_DURATION, "res1", rid);
// Make sure that the second submission is unsuccessful
if (this.isAuthenticationEnabled()) {
assertTrue(!isHttpSuccessResponse(response));
verifyReservationCount(1);
}
rm.stop();
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestRMWebServicesReservation method testEmptyEndTimeRequestListReservation.
@Test
public void testEmptyEndTimeRequestListReservation() throws Exception {
rm.start();
setupCluster(100);
long time = clock.getTime() + MINIMUM_RESOURCE_DURATION;
ReservationId id1 = getReservationIdTestHelper(1);
ReservationId id2 = getReservationIdTestHelper(2);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, time, "res_1", id1);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, time + MINIMUM_RESOURCE_DURATION, "res_2", id2);
WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("start-time", new Long((long) (time + MINIMUM_RESOURCE_DURATION * 1.3)).toString()).queryParam("include-resource-allocations", "true").queryParam("queue", DEFAULT_QUEUE);
JSONObject json = testListReservationHelper(resource);
if (!this.isAuthenticationEnabled() && json == null) {
return;
}
JSONObject reservations = json.getJSONObject("reservations");
testRDLHelper(reservations);
String reservationName = reservations.getJSONObject("reservation-definition").getString("reservation-name");
assertEquals(reservationName, "res_2");
rm.stop();
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class RMStateStoreTestBase method validateStoredReservation.
private void validateStoredReservation(RMStateStoreHelper stateStoreHelper, TestDispatcher dispatcher, RMContext rmContext, ReservationId r1, String planName, ReservationAllocation allocation, ReservationAllocationStateProto allocationStateProto) throws Exception {
RMStateStore store = stateStoreHelper.getRMStateStore();
when(rmContext.getStateStore()).thenReturn(store);
store.setRMDispatcher(dispatcher);
RMState state = store.loadState();
Map<String, Map<ReservationId, ReservationAllocationStateProto>> reservationState = state.getReservationState();
Assert.assertNotNull(reservationState);
Map<ReservationId, ReservationAllocationStateProto> reservations = reservationState.get(planName);
Assert.assertNotNull(reservations);
ReservationAllocationStateProto storedReservationAllocation = reservations.get(r1);
Assert.assertNotNull(storedReservationAllocation);
assertAllocationStateEqual(allocationStateProto, storedReservationAllocation);
assertAllocationStateEqual(allocation, storedReservationAllocation);
}
Aggregations