Search in sources :

Example 1 with ContainerAllocationProposal

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal 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 2 with ContainerAllocationProposal

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal 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

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