Search in sources :

Example 96 with ReservationId

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();
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) WebResource(com.sun.jersey.api.client.WebResource) Test(org.junit.Test)

Example 97 with ReservationId

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();
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) WebResource(com.sun.jersey.api.client.WebResource) Test(org.junit.Test)

Example 98 with ReservationId

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();
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) Test(org.junit.Test)

Example 99 with ReservationId

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();
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) WebResource(com.sun.jersey.api.client.WebResource) Test(org.junit.Test)

Example 100 with ReservationId

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);
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) RMState(org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState) Map(java.util.Map) HashMap(java.util.HashMap) ReservationAllocationStateProto(org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto)

Aggregations

ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)120 Test (org.junit.Test)85 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)40 PlanningException (org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)27 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)19 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)17 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)16 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)16 WebResource (com.sun.jersey.api.client.WebResource)14 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)14 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)13 JSONObject (org.codehaus.jettison.json.JSONObject)13 ArrayList (java.util.ArrayList)11 ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)11 IOException (java.io.IOException)10 Resource (org.apache.hadoop.yarn.api.records.Resource)10 ReservationDefinitionPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl)10 ReservationRequestsPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl)10 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)9 ReservationAllocationStateProto (org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto)9