Ejemplo n.º 1
0
        /// <summary>
        /// Checks whether making the application runnable would exceed any
        /// maxRunningApps limits.
        /// </summary>
        public virtual bool CanAppBeRunnable(FSQueue queue, string user)
        {
            AllocationConfiguration allocConf = scheduler.GetAllocationConfiguration();
            int userNumRunnable = usersNumRunnableApps[user];

            if (userNumRunnable == null)
            {
                userNumRunnable = 0;
            }
            if (userNumRunnable >= allocConf.GetUserMaxApps(user))
            {
                return(false);
            }
            // Check queue and all parent queues
            while (queue != null)
            {
                int queueMaxApps = allocConf.GetQueueMaxApps(queue.GetName());
                if (queue.GetNumRunnableApps() >= queueMaxApps)
                {
                    return(false);
                }
                queue = queue.GetParent();
            }
            return(true);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns true if there are no applications, running or not, in the given
 /// queue or any of its descendents.
 /// </summary>
 protected internal virtual bool IsEmpty(FSQueue queue)
 {
     if (queue is FSLeafQueue)
     {
         FSLeafQueue leafQueue = (FSLeafQueue)queue;
         return(queue.GetNumRunnableApps() == 0 && leafQueue.GetNumNonRunnableApps() == 0);
     }
     else
     {
         foreach (FSQueue child in queue.GetChildQueues())
         {
             if (!IsEmpty(child))
             {
                 return(false);
             }
         }
         return(true);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Traverses the queue hierarchy under the given queue to gather all lists
 /// of non-runnable applications.
 /// </summary>
 private void GatherPossiblyRunnableAppLists(FSQueue queue, IList <IList <FSAppAttempt
                                                                          > > appLists)
 {
     if (queue.GetNumRunnableApps() < scheduler.GetAllocationConfiguration().GetQueueMaxApps
             (queue.GetName()))
     {
         if (queue is FSLeafQueue)
         {
             appLists.AddItem(((FSLeafQueue)queue).GetCopyOfNonRunnableAppSchedulables());
         }
         else
         {
             foreach (FSQueue child in queue.GetChildQueues())
             {
                 GatherPossiblyRunnableAppLists(child, appLists);
             }
         }
     }
 }