Exemplo n.º 1
0
        /// <summary>
        /// Whether this app has containers requests that could be satisfied on the
        /// given node, if the node had full space.
        /// </summary>
        public virtual bool HasContainerForNode(Priority prio, FSSchedulerNode node)
        {
            ResourceRequest anyRequest  = GetResourceRequest(prio, ResourceRequest.Any);
            ResourceRequest rackRequest = GetResourceRequest(prio, node.GetRackName());
            ResourceRequest nodeRequest = GetResourceRequest(prio, node.GetNodeName());

            return(anyRequest != null && anyRequest.GetNumContainers() > 0 && (anyRequest.GetRelaxLocality
                                                                                   () || (rackRequest != null && rackRequest.GetNumContainers() > 0)) && (rackRequest
                                                                                                                                                          == null || rackRequest.GetRelaxLocality() || (nodeRequest != null && nodeRequest
                                                                                                                                                                                                        .GetNumContainers() > 0)) && Resources.LessThanOrEqual(ResourceCalculator, null,
                                                                                                                                                                                                                                                               anyRequest.GetCapability(), node.GetRMNode().GetTotalCapability()));
        }
Exemplo n.º 2
0
        private Org.Apache.Hadoop.Yarn.Api.Records.Resource AssignContainer(FSSchedulerNode
                                                                            node, bool reserved)
        {
            if (Log.IsDebugEnabled())
            {
                Log.Debug("Node offered to app: " + GetName() + " reserved: " + reserved);
            }
            ICollection <Priority> prioritiesToTry = (reserved) ? Arrays.AsList(node.GetReservedContainer
                                                                                    ().GetReservedPriority()) : GetPriorities();

            // For each priority, see if we can schedule a node local, rack local
            // or off-switch request. Rack of off-switch requests may be delayed
            // (not scheduled) in order to promote better locality.
            lock (this)
            {
                foreach (Priority priority in prioritiesToTry)
                {
                    if (GetTotalRequiredResources(priority) <= 0 || !HasContainerForNode(priority, node
                                                                                         ))
                    {
                        continue;
                    }
                    AddSchedulingOpportunity(priority);
                    // Check the AM resource usage for the leaf queue
                    if (GetLiveContainers().Count == 0 && !GetUnmanagedAM())
                    {
                        if (!((FSLeafQueue)GetQueue()).CanRunAppAM(GetAMResource()))
                        {
                            return(Resources.None());
                        }
                    }
                    ResourceRequest rackLocalRequest = GetResourceRequest(priority, node.GetRackName(
                                                                              ));
                    ResourceRequest localRequest = GetResourceRequest(priority, node.GetNodeName());
                    if (localRequest != null && !localRequest.GetRelaxLocality())
                    {
                        Log.Warn("Relax locality off is not supported on local request: " + localRequest);
                    }
                    NodeType allowedLocality;
                    if (scheduler.IsContinuousSchedulingEnabled())
                    {
                        allowedLocality = GetAllowedLocalityLevelByTime(priority, scheduler.GetNodeLocalityDelayMs
                                                                            (), scheduler.GetRackLocalityDelayMs(), scheduler.GetClock().GetTime());
                    }
                    else
                    {
                        allowedLocality = GetAllowedLocalityLevel(priority, scheduler.GetNumClusterNodes(
                                                                      ), scheduler.GetNodeLocalityThreshold(), scheduler.GetRackLocalityThreshold());
                    }
                    if (rackLocalRequest != null && rackLocalRequest.GetNumContainers() != 0 && localRequest
                        != null && localRequest.GetNumContainers() != 0)
                    {
                        return(AssignContainer(node, localRequest, NodeType.NodeLocal, reserved));
                    }
                    if (rackLocalRequest != null && !rackLocalRequest.GetRelaxLocality())
                    {
                        continue;
                    }
                    if (rackLocalRequest != null && rackLocalRequest.GetNumContainers() != 0 && (allowedLocality
                                                                                                 .Equals(NodeType.RackLocal) || allowedLocality.Equals(NodeType.OffSwitch)))
                    {
                        return(AssignContainer(node, rackLocalRequest, NodeType.RackLocal, reserved));
                    }
                    ResourceRequest offSwitchRequest = GetResourceRequest(priority, ResourceRequest.Any
                                                                          );
                    if (offSwitchRequest != null && !offSwitchRequest.GetRelaxLocality())
                    {
                        continue;
                    }
                    if (offSwitchRequest != null && offSwitchRequest.GetNumContainers() != 0)
                    {
                        if (!HasNodeOrRackLocalRequests(priority) || allowedLocality.Equals(NodeType.OffSwitch
                                                                                            ))
                        {
                            return(AssignContainer(node, offSwitchRequest, NodeType.OffSwitch, reserved));
                        }
                    }
                }
            }
            return(Resources.None());
        }