/// <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())); }
public override Org.Apache.Hadoop.Yarn.Api.Records.Resource AssignContainer(FSSchedulerNode node) { Org.Apache.Hadoop.Yarn.Api.Records.Resource assigned = Resources.None(); if (Log.IsDebugEnabled()) { Log.Debug("Node " + node.GetNodeName() + " offered to queue: " + GetName()); } if (!AssignContainerPreCheck(node)) { return(assigned); } IComparer <Schedulable> comparator = policy.GetComparator(); writeLock.Lock(); try { runnableApps.Sort(comparator); } finally { writeLock.Unlock(); } // Release write lock here for better performance and avoiding deadlocks. // runnableApps can be in unsorted state because of this section, // but we can accept it in practice since the probability is low. readLock.Lock(); try { foreach (FSAppAttempt sched in runnableApps) { if (SchedulerAppUtils.IsBlacklisted(sched, node, Log)) { continue; } assigned = sched.AssignContainer(node); if (!assigned.Equals(Resources.None())) { break; } } } finally { readLock.Unlock(); } return(assigned); }
/// <summary> /// Reserve a spot for /// <paramref name="container"/> /// on this /// <paramref name="node"/> /// . If /// the container is /// <paramref name="alreadyReserved"/> /// on the node, simply /// update relevant bookeeping. This dispatches ro relevant handlers /// in /// <see cref="FSSchedulerNode"/> /// .. /// </summary> private void Reserve(Priority priority, FSSchedulerNode node, Container container , bool alreadyReserved) { Log.Info("Making reservation: node=" + node.GetNodeName() + " app_id=" + GetApplicationId ()); if (!alreadyReserved) { GetMetrics().ReserveResource(GetUser(), container.GetResource()); RMContainer rmContainer = base.Reserve(node, priority, null, container); node.ReserveResource(this, priority, rmContainer); } else { RMContainer rmContainer = node.GetReservedContainer(); base.Reserve(node, priority, rmContainer, container); node.ReserveResource(this, priority, rmContainer); } }
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()); }