Search in sources :

Example 86 with ReservationId

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

the class TestReservationInputValidator method testDeleteReservationInvalidPlan.

@Test
public void testDeleteReservationInvalidPlan() {
    ReservationDeleteRequest request = new ReservationDeleteRequestPBImpl();
    ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
    request.setReservationId(reservationID);
    when(rSystem.getPlan(PLAN_NAME)).thenReturn(null);
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationDeleteRequest(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);
    }
}
Also used : ReservationDeleteRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationDeleteRequestPBImpl) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDeleteRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 87 with ReservationId

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

the class TestReservationInputValidator method testDeleteReservationDoesnotExist.

@Test
public void testDeleteReservationDoesnotExist() {
    ReservationDeleteRequest request = new ReservationDeleteRequestPBImpl();
    ReservationId rId = ReservationSystemTestUtil.getNewReservationId();
    request.setReservationId(rId);
    when(rSystem.getQueueForReservation(rId)).thenReturn(null);
    Plan plan = null;
    try {
        plan = rrValidator.validateReservationDeleteRequest(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);
    }
}
Also used : ReservationDeleteRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationDeleteRequestPBImpl) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDeleteRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 88 with ReservationId

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

the class TestRMWebServicesReservation method testInvalidStartTimeRequestListReservation.

@Test
public void testInvalidStartTimeRequestListReservation() 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", "-1").queryParam("end-time", new Long((long) (time + MINIMUM_RESOURCE_DURATION * 0.9)).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);
    // only res_1 should fall into the time interval given in the request json.
    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 89 with ReservationId

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

the class TestRMWebServicesReservation method testIncludeResourceAllocations.

@Test
public void testIncludeResourceAllocations() 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("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);
    assertTrue(reservations.has("resource-allocations"));
    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 90 with ReservationId

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

the class TestRMWebServicesReservation method testExcludeResourceAllocations.

@Test
public void testExcludeResourceAllocations() 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("include-resource-allocations", "false").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);
    assertTrue(!reservations.has("resource-allocations"));
    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