Esempio n. 1
0
        /// <summary>
        /// The specified queue is preemptable if system-wide preemption is turned on
        /// unless any queue in the <em>qPath</em> hierarchy has explicitly turned
        /// preemption off.
        /// </summary>
        /// <remarks>
        /// The specified queue is preemptable if system-wide preemption is turned on
        /// unless any queue in the <em>qPath</em> hierarchy has explicitly turned
        /// preemption off.
        /// NOTE: Preemptability is inherited from a queue's parent.
        /// </remarks>
        /// <returns>true if queue has preemption disabled, false otherwise</returns>
        private bool IsQueueHierarchyPreemptionDisabled(CSQueue q)
        {
            CapacitySchedulerConfiguration csConf = csContext.GetConfiguration();
            bool systemWidePreemption             = csConf.GetBoolean(YarnConfiguration.RmSchedulerEnableMonitors
                                                                      , YarnConfiguration.DefaultRmSchedulerEnableMonitors);
            CSQueue parentQ = q.GetParent();

            // If the system-wide preemption switch is turned off, all of the queues in
            // the qPath hierarchy have preemption disabled, so return true.
            if (!systemWidePreemption)
            {
                return(true);
            }
            // If q is the root queue and the system-wide preemption switch is turned
            // on, then q does not have preemption disabled (default=false, below)
            // unless the preemption_disabled property is explicitly set.
            if (parentQ == null)
            {
                return(csConf.GetPreemptionDisabled(q.GetQueuePath(), false));
            }
            // If this is not the root queue, inherit the default value for the
            // preemption_disabled property from the parent. Preemptability will be
            // inherited from the parent's hierarchy unless explicitly overridden at
            // this level.
            return(csConf.GetPreemptionDisabled(q.GetQueuePath(), parentQ.GetPreemptionDisabled
                                                    ()));
        }
Esempio n. 2
0
        internal CapacitySchedulerQueueInfo(CSQueue q)
        {
            queuePath    = q.GetQueuePath();
            capacity     = q.GetCapacity() * 100;
            usedCapacity = q.GetUsedCapacity() * 100;
            maxCapacity  = q.GetMaximumCapacity();
            if (maxCapacity < Epsilon || maxCapacity > 1f)
            {
                maxCapacity = 1f;
            }
            maxCapacity         *= 100;
            absoluteCapacity     = Cap(q.GetAbsoluteCapacity(), 0f, 1f) * 100;
            absoluteMaxCapacity  = Cap(q.GetAbsoluteMaximumCapacity(), 0f, 1f) * 100;
            absoluteUsedCapacity = Cap(q.GetAbsoluteUsedCapacity(), 0f, 1f) * 100;
            numApplications      = q.GetNumApplications();
            queueName            = q.GetQueueName();
            state         = q.GetState();
            resourcesUsed = new ResourceInfo(q.GetUsedResources());
            if (q is PlanQueue && !((PlanQueue)q).ShowReservationsAsQueues())
            {
                hideReservationQueues = true;
            }
            // add labels
            ICollection <string> labelSet = q.GetAccessibleNodeLabels();

            if (labelSet != null)
            {
                Sharpen.Collections.AddAll(nodeLabels, labelSet);
                nodeLabels.Sort();
            }
        }
Esempio n. 3
0
 /// <exception cref="System.IO.IOException"/>
 public override void Reinitialize(CSQueue newlyParsedQueue, Resource clusterResource
                                   )
 {
     lock (this)
     {
         // Sanity check
         if (!(newlyParsedQueue is Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Capacity.PlanQueue
               ) || !newlyParsedQueue.GetQueuePath().Equals(GetQueuePath()))
         {
             throw new IOException("Trying to reinitialize " + GetQueuePath() + " from " + newlyParsedQueue
                                   .GetQueuePath());
         }
         Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Capacity.PlanQueue newlyParsedParentQueue
             = (Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Capacity.PlanQueue)newlyParsedQueue;
         if (newlyParsedParentQueue.GetChildQueues().Count > 0)
         {
             throw new IOException("Reservable Queue should not have sub-queues in the" + "configuration"
                                   );
         }
         // Set new configs
         SetupQueueConfigs(clusterResource);
         UpdateQuotas(newlyParsedParentQueue.userLimit, newlyParsedParentQueue.userLimitFactor
                      , newlyParsedParentQueue.maxAppsForReservation, newlyParsedParentQueue.maxAppsPerUserForReservation
                      );
         // run reinitialize on each existing queue, to trigger absolute cap
         // recomputations
         foreach (CSQueue res in this.GetChildQueues())
         {
             res.Reinitialize(res, clusterResource);
         }
         showReservationsAsQueues = newlyParsedParentQueue.showReservationsAsQueues;
     }
 }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
 /// <exception cref="System.IO.IOException"/>
 public override void Reinitialize(CSQueue newlyParsedQueue, Resource clusterResource
                                   )
 {
     lock (this)
     {
         // Sanity check
         if (!(newlyParsedQueue is Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Capacity.ParentQueue
               ) || !newlyParsedQueue.GetQueuePath().Equals(GetQueuePath()))
         {
             throw new IOException("Trying to reinitialize " + GetQueuePath() + " from " + newlyParsedQueue
                                   .GetQueuePath());
         }
         Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Capacity.ParentQueue newlyParsedParentQueue
             = (Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Capacity.ParentQueue
                )newlyParsedQueue;
         // Set new configs
         SetupQueueConfigs(clusterResource);
         // Re-configure existing child queues and add new ones
         // The CS has already checked to ensure all existing child queues are present!
         IDictionary <string, CSQueue> currentChildQueues = GetQueues(childQueues);
         IDictionary <string, CSQueue> newChildQueues     = GetQueues(newlyParsedParentQueue.childQueues
                                                                      );
         foreach (KeyValuePair <string, CSQueue> e in newChildQueues)
         {
             string  newChildQueueName = e.Key;
             CSQueue newChildQueue     = e.Value;
             CSQueue childQueue        = currentChildQueues[newChildQueueName];
             // Check if the child-queue already exists
             if (childQueue != null)
             {
                 // Re-init existing child queues
                 childQueue.Reinitialize(newChildQueue, clusterResource);
                 Log.Info(GetQueueName() + ": re-configured queue: " + childQueue);
             }
             else
             {
                 // New child queue, do not re-init
                 // Set parent to 'this'
                 newChildQueue.SetParent(this);
                 // Save in list of current child queues
                 currentChildQueues[newChildQueueName] = newChildQueue;
                 Log.Info(GetQueueName() + ": added new child queue: " + newChildQueue);
             }
         }
         // Re-sort all queues
         childQueues.Clear();
         Sharpen.Collections.AddAll(childQueues, currentChildQueues.Values);
     }
 }
Esempio n. 6
0
 public override void CompletedContainer(Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                         clusterResource, FiCaSchedulerApp application, FiCaSchedulerNode node, RMContainer
                                         rmContainer, ContainerStatus containerStatus, RMContainerEventType @event, CSQueue
                                         completedChildQueue, bool sortQueues)
 {
     if (application != null)
     {
         // Careful! Locking order is important!
         // Book keeping
         lock (this)
         {
             base.ReleaseResource(clusterResource, rmContainer.GetContainer().GetResource(), node
                                  .GetLabels());
             Log.Info("completedContainer" + " queue=" + GetQueueName() + " usedCapacity=" + GetUsedCapacity
                          () + " absoluteUsedCapacity=" + GetAbsoluteUsedCapacity() + " used=" + queueUsage
                      .GetUsed() + " cluster=" + clusterResource);
             // Note that this is using an iterator on the childQueues so this can't
             // be called if already within an iterator for the childQueues. Like
             // from assignContainersToChildQueues.
             if (sortQueues)
             {
                 // reinsert the updated queue
                 for (IEnumerator <CSQueue> iter = childQueues.GetEnumerator(); iter.HasNext();)
                 {
                     CSQueue csqueue = iter.Next();
                     if (csqueue.Equals(completedChildQueue))
                     {
                         iter.Remove();
                         Log.Info("Re-sorting completed queue: " + csqueue.GetQueuePath() + " stats: " + csqueue
                                  );
                         childQueues.AddItem(csqueue);
                         break;
                     }
                 }
             }
         }
         // Inform the parent
         if (parent != null)
         {
             // complete my parent
             parent.CompletedContainer(clusterResource, application, node, rmContainer, null,
                                       @event, this, sortQueues);
         }
     }
 }
Esempio n. 7
0
 /// <exception cref="System.IO.IOException"/>
 public override void Reinitialize(CSQueue newlyParsedQueue, Resource clusterResource
                                   )
 {
     lock (this)
     {
         // Sanity check
         if (!(newlyParsedQueue is Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Capacity.ReservationQueue
               ) || !newlyParsedQueue.GetQueuePath().Equals(GetQueuePath()))
         {
             throw new IOException("Trying to reinitialize " + GetQueuePath() + " from " + newlyParsedQueue
                                   .GetQueuePath());
         }
         base.Reinitialize(newlyParsedQueue, clusterResource);
         CSQueueUtils.UpdateQueueStatistics(parent.schedulerContext.GetResourceCalculator(
                                                ), newlyParsedQueue, parent, parent.schedulerContext.GetClusterResource(), parent
                                            .schedulerContext.GetMinimumResourceCapability());
         UpdateQuotas(parent.GetUserLimitForReservation(), parent.GetUserLimitFactor(), parent
                      .GetMaxApplicationsForReservations(), parent.GetMaxApplicationsPerUserForReservation
                          ());
     }
 }