Search in sources :

Example 91 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestRMWebServicesReservation method testQueueOnlyRequestListReservation.

@Test
public void testQueueOnlyRequestListReservation() 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).queryParam("queue", DEFAULT_QUEUE);
    JSONObject json = testListReservationHelper(resource);
    if (!this.isAuthenticationEnabled() && json == null) {
        return;
    }
    assertEquals(json.getJSONArray("reservations").length(), 2);
    testRDLHelper(json.getJSONArray("reservations").getJSONObject(0));
    testRDLHelper(json.getJSONArray("reservations").getJSONObject(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 92 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestRMWebServicesReservation method testDeleteReservation.

@Test
public void testDeleteReservation() throws JSONException, Exception {
    rm.start();
    for (int i = 0; i < 100; i++) {
        MockNM amNodeManager = rm.registerNode("127.0.0." + i + ":1234", 100 * 1024);
        amNodeManager.nodeHeartbeat(true);
    }
    ReservationId rid = getReservationIdTestHelper(1);
    reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, rid);
    testDeleteReservationHelper("reservation/delete", rid, MediaType.APPLICATION_JSON);
    rm.stop();
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) MockNM(org.apache.hadoop.yarn.server.resourcemanager.MockNM) Test(org.junit.Test)

Example 93 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestRMWebServicesReservation method testInvalidReservationIdRequestListReservation.

@Test
public void testInvalidReservationIdRequestListReservation() throws Exception {
    rm.start();
    setupCluster(100);
    ReservationId id1 = getReservationIdTestHelper(1);
    reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, clock.getTime(), "res_1", id1);
    WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("queue", DEFAULT_QUEUE);
    if (id1 != null) {
        resource = resource.queryParam("reservation-id", "invalid" + id1.toString());
    }
    JSONObject response = testListReservationHelper(resource, Status.NOT_FOUND);
    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 94 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestRMWebServicesReservation method testSubmitReservation.

@Test
public void testSubmitReservation() throws Exception {
    rm.start();
    setupCluster(100);
    ReservationId rid = getReservationIdTestHelper(1);
    ClientResponse response = reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, rid);
    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 95 with ReservationId

use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.

the class TestRMWebServicesReservation method testReservationIdRequestListReservation.

@Test
public void testReservationIdRequestListReservation() 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_1", id1);
    reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, clock.getTime(), "res_2", id2);
    WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("include-resource-allocations", "true").queryParam("queue", DEFAULT_QUEUE);
    if (id1 != null) {
        resource = resource.queryParam("reservation-id", id1.toString());
    }
    JSONObject json = testListReservationHelper(resource);
    if (!this.isAuthenticationEnabled() && json == null) {
        return;
    }
    JSONObject reservations = json.getJSONObject("reservations");
    testRDLHelper(reservations);
    String reservationId = reservations.getString("reservation-id");
    assertEquals(id1.toString(), reservationId);
    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)

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