Search in sources :

Example 1 with ResourceCommitRequest

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest in project hadoop by apache.

the class CapacityScheduler method tryCommit.

@Override
public void tryCommit(Resource cluster, ResourceCommitRequest r) {
    ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request = (ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode>) r;
    ApplicationAttemptId attemptId = null;
    // We need to update unconfirmed allocated resource of application when
    // any container allocated.
    boolean updateUnconfirmedAllocatedResource = request.getContainersToAllocate() != null && !request.getContainersToAllocate().isEmpty();
    // find the application to accept and apply the ResourceCommitRequest
    if (request.anythingAllocatedOrReserved()) {
        ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> c = request.getFirstAllocatedOrReservedContainer();
        attemptId = c.getAllocatedOrReservedContainer().getSchedulerApplicationAttempt().getApplicationAttemptId();
    } else {
        if (!request.getContainersToRelease().isEmpty()) {
            attemptId = request.getContainersToRelease().get(0).getSchedulerApplicationAttempt().getApplicationAttemptId();
        }
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Try to commit allocation proposal=" + request);
    }
    if (attemptId != null) {
        FiCaSchedulerApp app = getApplicationAttempt(attemptId);
        if (app != null) {
            if (app.accept(cluster, request)) {
                app.apply(cluster, request);
                LOG.info("Allocation proposal accepted");
            } else {
                LOG.info("Failed to accept allocation proposal");
            }
            // Update unconfirmed allocated resource.
            if (updateUnconfirmedAllocatedResource) {
                app.decUnconfirmedRes(request.getTotalAllocatedResource());
            }
        }
    }
}
Also used : FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) ResourceCommitRequest(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest) FiCaSchedulerApp(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId)

Example 2 with ResourceCommitRequest

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest in project hadoop by apache.

the class TestParentQueue method applyAllocationToQueue.

private void applyAllocationToQueue(Resource clusterResource, int allocatedMem, CSQueue queue) {
    // Call accept & apply for queue
    ResourceCommitRequest request = mock(ResourceCommitRequest.class);
    when(request.anythingAllocatedOrReserved()).thenReturn(true);
    ContainerAllocationProposal allocation = mock(ContainerAllocationProposal.class);
    when(request.getTotalReleasedResource()).thenReturn(Resources.none());
    when(request.getFirstAllocatedOrReservedContainer()).thenReturn(allocation);
    SchedulerContainer scontainer = mock(SchedulerContainer.class);
    when(allocation.getAllocatedOrReservedContainer()).thenReturn(scontainer);
    when(allocation.getAllocatedOrReservedResource()).thenReturn(Resources.createResource(allocatedMem));
    when(scontainer.getNodePartition()).thenReturn("");
    if (queue.accept(clusterResource, request)) {
        queue.apply(clusterResource, request);
    }
}
Also used : ContainerAllocationProposal(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal) ResourceCommitRequest(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest) SchedulerContainer(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer)

Example 3 with ResourceCommitRequest

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest in project hadoop by apache.

the class CapacityScheduler method createResourceCommitRequest.

@VisibleForTesting
public ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> createResourceCommitRequest(CSAssignment csAssignment) {
    ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> allocated = null;
    ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> reserved = null;
    List<SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>> released = null;
    if (Resources.greaterThan(calculator, getClusterResource(), csAssignment.getResource(), Resources.none())) {
        // Allocated something
        List<AssignmentInformation.AssignmentDetails> allocations = csAssignment.getAssignmentInformation().getAllocationDetails();
        if (!allocations.isEmpty()) {
            RMContainer rmContainer = allocations.get(0).rmContainer;
            allocated = new ContainerAllocationProposal<>(getSchedulerContainer(rmContainer, true), getSchedulerContainersToRelease(csAssignment), getSchedulerContainer(csAssignment.getFulfilledReservedContainer(), false), csAssignment.getType(), csAssignment.getRequestLocalityType(), csAssignment.getSchedulingMode() != null ? csAssignment.getSchedulingMode() : SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, csAssignment.getResource());
        }
        // Reserved something
        List<AssignmentInformation.AssignmentDetails> reservation = csAssignment.getAssignmentInformation().getReservationDetails();
        if (!reservation.isEmpty()) {
            RMContainer rmContainer = reservation.get(0).rmContainer;
            reserved = new ContainerAllocationProposal<>(getSchedulerContainer(rmContainer, false), getSchedulerContainersToRelease(csAssignment), getSchedulerContainer(csAssignment.getFulfilledReservedContainer(), false), csAssignment.getType(), csAssignment.getRequestLocalityType(), csAssignment.getSchedulingMode() != null ? csAssignment.getSchedulingMode() : SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, csAssignment.getResource());
        }
    }
    // kill all to-release containers in the request.
    if (null == allocated && null == reserved) {
        released = getSchedulerContainersToRelease(csAssignment);
    }
    if (null != allocated || null != reserved || (null != released && !released.isEmpty())) {
        List<ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>> allocationsList = null;
        if (allocated != null) {
            allocationsList = new ArrayList<>();
            allocationsList.add(allocated);
        }
        List<ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>> reservationsList = null;
        if (reserved != null) {
            reservationsList = new ArrayList<>();
            reservationsList.add(reserved);
        }
        return new ResourceCommitRequest<>(allocationsList, reservationsList, released);
    }
    return null;
}
Also used : FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) ResourceCommitRequest(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) SchedulerContainer(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer) ContainerAllocationProposal(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal) FiCaSchedulerApp(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ResourceCommitRequest (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest)3 ContainerAllocationProposal (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal)2 SchedulerContainer (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer)2 FiCaSchedulerApp (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp)2 FiCaSchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)1