Search in sources :

Example 1 with CSAssignment

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSAssignment in project hadoop by apache.

the class AbstractContainerAllocator method getCSAssignmentFromAllocateResult.

protected CSAssignment getCSAssignmentFromAllocateResult(Resource clusterResource, ContainerAllocation result, RMContainer rmContainer, FiCaSchedulerNode node) {
    // Handle skipped
    CSAssignment.SkippedType skipped = (result.getAllocationState() == AllocationState.APP_SKIPPED) ? CSAssignment.SkippedType.OTHER : CSAssignment.SkippedType.NONE;
    CSAssignment assignment = new CSAssignment(skipped);
    assignment.setApplication(application);
    // Handle excess reservation
    assignment.setExcessReservation(result.getContainerToBeUnreserved());
    assignment.setRequestLocalityType(result.requestLocalityType);
    // If we allocated something
    if (Resources.greaterThan(rc, clusterResource, result.getResourceToBeAllocated(), Resources.none())) {
        Resource allocatedResource = result.getResourceToBeAllocated();
        RMContainer updatedContainer = result.getUpdatedContainer();
        assignment.setResource(allocatedResource);
        assignment.setType(result.getContainerNodeType());
        if (result.getAllocationState() == AllocationState.RESERVED) {
            // This is a reserved container
            LOG.info("Reserved container " + " application=" + application.getApplicationId() + " resource=" + allocatedResource + " queue=" + this.toString() + " cluster=" + clusterResource);
            assignment.getAssignmentInformation().addReservationDetails(updatedContainer, application.getCSLeafQueue().getQueuePath());
            assignment.getAssignmentInformation().incrReservations();
            Resources.addTo(assignment.getAssignmentInformation().getReserved(), allocatedResource);
            if (rmContainer != null) {
                ActivitiesLogger.APP.recordAppActivityWithAllocation(activitiesManager, node, application, updatedContainer, ActivityState.RE_RESERVED);
                ActivitiesLogger.APP.finishSkippedAppAllocationRecording(activitiesManager, application.getApplicationId(), ActivityState.SKIPPED, ActivityDiagnosticConstant.EMPTY);
            } else {
                ActivitiesLogger.APP.recordAppActivityWithAllocation(activitiesManager, node, application, updatedContainer, ActivityState.RESERVED);
                ActivitiesLogger.APP.finishAllocatedAppAllocationRecording(activitiesManager, application.getApplicationId(), updatedContainer.getContainerId(), ActivityState.RESERVED, ActivityDiagnosticConstant.EMPTY);
            }
        } else if (result.getAllocationState() == AllocationState.ALLOCATED) {
            // This is a new container
            // Inform the ordering policy
            LOG.info("assignedContainer" + " application attempt=" + application.getApplicationAttemptId() + " container=" + updatedContainer.getContainerId() + " queue=" + this + " clusterResource=" + clusterResource + " type=" + assignment.getType());
            assignment.getAssignmentInformation().addAllocationDetails(updatedContainer, application.getCSLeafQueue().getQueuePath());
            assignment.getAssignmentInformation().incrAllocations();
            Resources.addTo(assignment.getAssignmentInformation().getAllocated(), allocatedResource);
            if (rmContainer != null) {
                assignment.setFulfilledReservation(true);
                assignment.setFulfilledReservedContainer(rmContainer);
            }
            ActivitiesLogger.APP.recordAppActivityWithAllocation(activitiesManager, node, application, updatedContainer, ActivityState.ALLOCATED);
            ActivitiesLogger.APP.finishAllocatedAppAllocationRecording(activitiesManager, application.getApplicationId(), updatedContainer.getContainerId(), ActivityState.ACCEPTED, ActivityDiagnosticConstant.EMPTY);
            // Update unformed resource
            application.incUnconfirmedRes(allocatedResource);
        }
        assignment.setContainersToKill(result.getToKillContainers());
    } else {
        if (result.getAllocationState() == AllocationState.QUEUE_SKIPPED) {
            assignment.setSkippedType(CSAssignment.SkippedType.QUEUE_LIMIT);
        }
    }
    return assignment;
}
Also used : Resource(org.apache.hadoop.yarn.api.records.Resource) CSAssignment(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSAssignment) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

Aggregations

Resource (org.apache.hadoop.yarn.api.records.Resource)1 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)1 CSAssignment (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSAssignment)1