Search in sources :

Example 1 with ReservationRequests

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

the class TestYarnClient method testListReservationsByTimeInterval.

@Test
public void testListReservationsByTimeInterval() throws Exception {
    MiniYARNCluster cluster = setupMiniYARNCluster();
    YarnClient client = setupYarnClient(cluster);
    try {
        Clock clock = new UTCClock();
        long arrival = clock.getTime();
        long duration = 60000;
        long deadline = (long) (arrival + 1.05 * duration);
        ReservationSubmissionRequest sRequest = submitReservationTestHelper(client, arrival, deadline, duration);
        // List reservations, search by a point in time within the reservation
        // range.
        arrival = clock.getTime();
        ReservationId reservationID = sRequest.getReservationId();
        ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", arrival + duration / 2, arrival + duration / 2, true);
        ReservationListResponse response = client.listReservations(request);
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getReservationAllocationState().size());
        Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
        // List reservations, search by time within reservation interval.
        request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, Long.MAX_VALUE, true);
        response = client.listReservations(request);
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getReservationAllocationState().size());
        Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
        // Verify that the full resource allocations exist.
        Assert.assertTrue(response.getReservationAllocationState().get(0).getResourceAllocationRequests().size() > 0);
        // Verify that the full RDL is returned.
        ReservationRequests reservationRequests = response.getReservationAllocationState().get(0).getReservationDefinition().getReservationRequests();
        Assert.assertTrue(reservationRequests.getInterpreter().toString().equals("R_ALL"));
        Assert.assertTrue(reservationRequests.getReservationResources().get(0).getDuration() == duration);
    } finally {
        // clean-up
        if (client != null) {
            client.stop();
        }
        cluster.stop();
    }
}
Also used : ReservationListResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster) UTCClock(org.apache.hadoop.yarn.util.UTCClock) Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) Test(org.junit.Test)

Example 2 with ReservationRequests

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

the class RMWebServices method createReservationSubmissionRequest.

private ReservationSubmissionRequest createReservationSubmissionRequest(ReservationSubmissionRequestInfo resContext) throws IOException {
    // defending against a couple of common submission format problems
    if (resContext == null) {
        throw new BadRequestException("Input ReservationSubmissionContext should not be null");
    }
    ReservationDefinitionInfo resInfo = resContext.getReservationDefinition();
    if (resInfo == null) {
        throw new BadRequestException("Input ReservationDefinition should not be null");
    }
    ReservationRequestsInfo resReqsInfo = resInfo.getReservationRequests();
    if (resReqsInfo == null || resReqsInfo.getReservationRequest() == null || resReqsInfo.getReservationRequest().size() == 0) {
        throw new BadRequestException("The ReservationDefinition should" + " contain at least one ReservationRequest");
    }
    ReservationRequestInterpreter[] values = ReservationRequestInterpreter.values();
    ReservationRequestInterpreter resInt = values[resReqsInfo.getReservationRequestsInterpreter()];
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    for (ReservationRequestInfo resReqInfo : resReqsInfo.getReservationRequest()) {
        ResourceInfo rInfo = resReqInfo.getCapability();
        Resource capability = Resource.newInstance(rInfo.getMemorySize(), rInfo.getvCores());
        int numContainers = resReqInfo.getNumContainers();
        int minConcurrency = resReqInfo.getMinConcurrency();
        long duration = resReqInfo.getDuration();
        ReservationRequest rr = ReservationRequest.newInstance(capability, numContainers, minConcurrency, duration);
        list.add(rr);
    }
    ReservationRequests reqs = ReservationRequests.newInstance(list, resInt);
    ReservationDefinition rDef = ReservationDefinition.newInstance(resInfo.getArrival(), resInfo.getDeadline(), reqs, resInfo.getReservationName());
    ReservationId reservationId = ReservationId.parseReservationId(resContext.getReservationId());
    ReservationSubmissionRequest request = ReservationSubmissionRequest.newInstance(rDef, resContext.getQueue(), reservationId);
    return request;
}
Also used : ReservationRequestsInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestsInfo) ResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo) LocalResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LocalResourceInfo) ReservationRequestInterpreter(org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) GetNewReservationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ArrayList(java.util.ArrayList) Resource(org.apache.hadoop.yarn.api.records.Resource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ReservationRequestInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestInfo) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinitionInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationDefinitionInfo) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException)

Example 3 with ReservationRequests

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

the class RMWebServices method createReservationUpdateRequest.

private ReservationUpdateRequest createReservationUpdateRequest(ReservationUpdateRequestInfo resContext) throws IOException {
    // defending against a couple of common submission format problems
    if (resContext == null) {
        throw new BadRequestException("Input ReservationSubmissionContext should not be null");
    }
    ReservationDefinitionInfo resInfo = resContext.getReservationDefinition();
    if (resInfo == null) {
        throw new BadRequestException("Input ReservationDefinition should not be null");
    }
    ReservationRequestsInfo resReqsInfo = resInfo.getReservationRequests();
    if (resReqsInfo == null || resReqsInfo.getReservationRequest() == null || resReqsInfo.getReservationRequest().size() == 0) {
        throw new BadRequestException("The ReservationDefinition should" + " contain at least one ReservationRequest");
    }
    if (resContext.getReservationId() == null) {
        throw new BadRequestException("Update operations must specify an existing ReservaitonId");
    }
    ReservationRequestInterpreter[] values = ReservationRequestInterpreter.values();
    ReservationRequestInterpreter resInt = values[resReqsInfo.getReservationRequestsInterpreter()];
    List<ReservationRequest> list = new ArrayList<ReservationRequest>();
    for (ReservationRequestInfo resReqInfo : resReqsInfo.getReservationRequest()) {
        ResourceInfo rInfo = resReqInfo.getCapability();
        Resource capability = Resource.newInstance(rInfo.getMemorySize(), rInfo.getvCores());
        int numContainers = resReqInfo.getNumContainers();
        int minConcurrency = resReqInfo.getMinConcurrency();
        long duration = resReqInfo.getDuration();
        ReservationRequest rr = ReservationRequest.newInstance(capability, numContainers, minConcurrency, duration);
        list.add(rr);
    }
    ReservationRequests reqs = ReservationRequests.newInstance(list, resInt);
    ReservationDefinition rDef = ReservationDefinition.newInstance(resInfo.getArrival(), resInfo.getDeadline(), reqs, resInfo.getReservationName());
    ReservationUpdateRequest request = ReservationUpdateRequest.newInstance(rDef, ReservationId.parseReservationId(resContext.getReservationId()));
    return request;
}
Also used : ReservationRequestsInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestsInfo) ResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo) LocalResourceInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LocalResourceInfo) ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) ReservationRequestInterpreter(org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) GetNewReservationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ArrayList(java.util.ArrayList) Resource(org.apache.hadoop.yarn.api.records.Resource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) ReservationRequestInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestInfo) ReservationDefinitionInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationDefinitionInfo) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException)

Example 4 with ReservationRequests

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

the class TestClientRMService method testListReservationsByTimeInterval.

@Test
public void testListReservationsByTimeInterval() {
    ResourceManager rm = setupResourceManager();
    ClientRMService clientService = rm.getClientRMService();
    Clock clock = new UTCClock();
    long arrival = clock.getTime();
    long duration = 60000;
    long deadline = (long) (arrival + 1.05 * duration);
    ReservationSubmissionRequest sRequest = submitReservationTestHelper(clientService, arrival, deadline, duration);
    // List reservations, search by a point in time within the reservation
    // range.
    arrival = clock.getTime();
    ReservationId reservationID = sRequest.getReservationId();
    ReservationListRequest request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", arrival + duration / 2, arrival + duration / 2, true);
    ReservationListResponse response = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertEquals(1, response.getReservationAllocationState().size());
    Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
    // List reservations, search by time within reservation interval.
    request = ReservationListRequest.newInstance(ReservationSystemTestUtil.reservationQ, "", 1, Long.MAX_VALUE, true);
    response = null;
    try {
        response = clientService.listReservations(request);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertNotNull(response);
    Assert.assertEquals(1, response.getReservationAllocationState().size());
    Assert.assertEquals(response.getReservationAllocationState().get(0).getReservationId().getId(), reservationID.getId());
    // Verify that the full resource allocations exist.
    Assert.assertTrue(response.getReservationAllocationState().get(0).getResourceAllocationRequests().size() > 0);
    // Verify that the full RDL is returned.
    ReservationRequests reservationRequests = response.getReservationAllocationState().get(0).getReservationDefinition().getReservationRequests();
    Assert.assertTrue(reservationRequests.getInterpreter().toString().equals("R_ALL"));
    Assert.assertTrue(reservationRequests.getReservationResources().get(0).getDuration() == duration);
    rm.stop();
}
Also used : ReservationListResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) UTCClock(org.apache.hadoop.yarn.util.UTCClock) Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) IOException(java.io.IOException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) AccessControlException(java.security.AccessControlException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 5 with ReservationRequests

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

the class ReservationSystemTestUtil method createSimpleReservationDefinition.

public static ReservationDefinition createSimpleReservationDefinition(long arrival, long deadline, long duration, int parallelism) {
    // create a request with a single atomic ask
    ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), parallelism, parallelism, duration);
    ReservationDefinition rDef = new ReservationDefinitionPBImpl();
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    reqs.setReservationResources(Collections.singletonList(r));
    reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    rDef.setReservationRequests(reqs);
    rDef.setArrival(arrival);
    rDef.setDeadline(deadline);
    return rDef;
}
Also used : ReservationRequestsPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationDefinitionPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl) ReservationRequests(org.apache.hadoop.yarn.api.records.ReservationRequests)

Aggregations

ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)22 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)20 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)19 ReservationDefinitionPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl)15 ReservationRequestsPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl)15 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)13 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)10 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)8 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)7 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)6 ReservationRequestInterpreter (org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter)4 PlanningException (org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)4 Resource (org.apache.hadoop.yarn.api.records.Resource)3 GetNewReservationRequest (org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest)2 ReservationListRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest)2 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)2 ReservationUpdateRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest)2 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)2 LocalResourceInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LocalResourceInfo)2