private CSAssignment AssignContainersToChildQueues(Org.Apache.Hadoop.Yarn.Api.Records.Resource cluster, FiCaSchedulerNode node, ResourceLimits limits) { lock (this) { CSAssignment assignment = new CSAssignment(Resources.CreateResource(0, 0), NodeType .NodeLocal); PrintChildQueues(); // Try to assign to most 'under-served' sub-queue for (IEnumerator <CSQueue> iter = childQueues.GetEnumerator(); iter.HasNext();) { CSQueue childQueue = iter.Next(); if (Log.IsDebugEnabled()) { Log.Debug("Trying to assign to queue: " + childQueue.GetQueuePath() + " stats: " + childQueue); } // Get ResourceLimits of child queue before assign containers ResourceLimits childLimits = GetResourceLimitsOfChild(childQueue, cluster, limits ); assignment = childQueue.AssignContainers(cluster, node, childLimits); if (Log.IsDebugEnabled()) { Log.Debug("Assigned to queue: " + childQueue.GetQueuePath() + " stats: " + childQueue + " --> " + assignment.GetResource() + ", " + assignment.GetType()); } // If we do assign, remove the queue and re-insert in-order to re-sort if (Resources.GreaterThan(resourceCalculator, cluster, assignment.GetResource(), Resources.None())) { // Remove and re-insert to sort iter.Remove(); Log.Info("Re-sorting assigned queue: " + childQueue.GetQueuePath() + " stats: " + childQueue); childQueues.AddItem(childQueue); if (Log.IsDebugEnabled()) { PrintChildQueues(); } break; } } return(assignment); } }
public override CSAssignment AssignContainers(Resource clusterResource, FiCaSchedulerNode node, ResourceLimits resourceLimits) { lock (this) { CSAssignment assignment = new CSAssignment(Resources.CreateResource(0, 0), NodeType .NodeLocal); ICollection <string> nodeLabels = node.GetLabels(); // if our queue cannot access this node, just return if (!SchedulerUtils.CheckQueueAccessToNode(accessibleLabels, nodeLabels)) { return(assignment); } while (CanAssign(clusterResource, node)) { if (Log.IsDebugEnabled()) { Log.Debug("Trying to assign containers to child-queue of " + GetQueueName()); } // Are we over maximum-capacity for this queue? // This will also consider parent's limits and also continuous reservation // looking if (!base.CanAssignToThisQueue(clusterResource, nodeLabels, resourceLimits, minimumAllocation , Resources.CreateResource(GetMetrics().GetReservedMB(), GetMetrics().GetReservedVirtualCores ()))) { break; } // Schedule CSAssignment assignedToChild = AssignContainersToChildQueues(clusterResource, node , resourceLimits); assignment.SetType(assignedToChild.GetType()); // Done if no child-queue assigned anything if (Resources.GreaterThan(resourceCalculator, clusterResource, assignedToChild.GetResource (), Resources.None())) { // Track resource utilization for the parent-queue base.AllocateResource(clusterResource, assignedToChild.GetResource(), nodeLabels); // Track resource utilization in this pass of the scheduler Resources.AddTo(assignment.GetResource(), assignedToChild.GetResource()); Log.Info("assignedContainer" + " queue=" + GetQueueName() + " usedCapacity=" + GetUsedCapacity () + " absoluteUsedCapacity=" + GetAbsoluteUsedCapacity() + " used=" + queueUsage .GetUsed() + " cluster=" + clusterResource); } else { break; } if (Log.IsDebugEnabled()) { Log.Debug("ParentQ=" + GetQueueName() + " assignedSoFarInThisIteration=" + assignment .GetResource() + " usedCapacity=" + GetUsedCapacity() + " absoluteUsedCapacity=" + GetAbsoluteUsedCapacity()); } // Do not assign more than one container if this isn't the root queue // or if we've already assigned an off-switch container if (!rootQueue || assignment.GetType() == NodeType.OffSwitch) { if (Log.IsDebugEnabled()) { if (rootQueue && assignment.GetType() == NodeType.OffSwitch) { Log.Debug("Not assigning more than one off-switch container," + " assignments so far: " + assignment); } } break; } } return(assignment); } }