Search in sources :

Example 1 with SimplePlacementSet

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet in project hadoop by apache.

the class CapacityScheduler method allocateContainersToNode.

/**
   * We need to make sure when doing allocation, Node should be existed
   * And we will construct a {@link PlacementSet} before proceeding
   */
private void allocateContainersToNode(NodeId nodeId, boolean withNodeHeartbeat) {
    FiCaSchedulerNode node = getNode(nodeId);
    if (null != node) {
        int offswitchCount = 0;
        PlacementSet<FiCaSchedulerNode> ps = new SimplePlacementSet<>(node);
        CSAssignment assignment = allocateContainersToNode(ps, withNodeHeartbeat);
        // scheduling is triggered by node heartbeat
        if (null != assignment && withNodeHeartbeat) {
            if (assignment.getType() == NodeType.OFF_SWITCH) {
                offswitchCount++;
            }
            while (canAllocateMore(assignment, offswitchCount)) {
                // Try to see if it is possible to allocate multiple container for
                // the same node heartbeat
                assignment = allocateContainersToNode(ps, true);
                if (null != assignment && assignment.getType() == NodeType.OFF_SWITCH) {
                    offswitchCount++;
                }
            }
            if (offswitchCount >= offswitchPerHeartbeatLimit) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Assigned maximum number of off-switch containers: " + offswitchCount + ", assignments so far: " + assignment);
                }
            }
        }
    }
}
Also used : FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) SimplePlacementSet(org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet)

Aggregations

FiCaSchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode)1 SimplePlacementSet (org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet)1