コード例 #1
0
        /// <summary>
        /// Checks to see whether applications are runnable now by iterating
        /// through each one of them and check if the queue and user have slack
        /// if we know how many apps can be runnable, there is no need to iterate
        /// through all apps, maxRunnableApps is used to break out of the iteration
        /// </summary>
        private void UpdateAppsRunnability(IList <IList <FSAppAttempt> > appsNowMaybeRunnable
                                           , int maxRunnableApps)
        {
            // Scan through and check whether this means that any apps are now runnable
            IEnumerator <FSAppAttempt> iter = new MaxRunningAppsEnforcer.MultiListStartTimeIterator
                                                  (appsNowMaybeRunnable);
            FSAppAttempt         prev = null;
            IList <FSAppAttempt> noLongerPendingApps = new AList <FSAppAttempt>();

            while (iter.HasNext())
            {
                FSAppAttempt next = iter.Next();
                if (next == prev)
                {
                    continue;
                }
                if (CanAppBeRunnable(((FSLeafQueue)next.GetQueue()), next.GetUser()))
                {
                    TrackRunnableApp(next);
                    FSAppAttempt appSched = next;
                    ((FSLeafQueue)next.GetQueue()).AddApp(appSched, true);
                    noLongerPendingApps.AddItem(appSched);
                    if (noLongerPendingApps.Count >= maxRunnableApps)
                    {
                        break;
                    }
                }
                prev = next;
            }
            // We remove the apps from their pending lists afterwards so that we don't
            // pull them out from under the iterator.  If they are not in these lists
            // in the first place, there is a bug.
            foreach (FSAppAttempt appSched_1 in noLongerPendingApps)
            {
                if (!((FSLeafQueue)appSched_1.GetQueue()).RemoveNonRunnableApp(appSched_1))
                {
                    Log.Error("Can't make app runnable that does not already exist in queue" + " as non-runnable: "
                              + appSched_1 + ". This should never happen.");
                }
                if (!usersNonRunnableApps.Remove(appSched_1.GetUser(), appSched_1))
                {
                    Log.Error("Waiting app " + appSched_1 + " expected to be in " + "usersNonRunnableApps, but was not. This should never happen."
                              );
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Tracks the given new runnable app for purposes of maintaining max running
        /// app limits.
        /// </summary>
        public virtual void TrackRunnableApp(FSAppAttempt app)
        {
            string      user  = app.GetUser();
            FSLeafQueue queue = ((FSLeafQueue)app.GetQueue());
            // Increment running counts for all parent queues
            FSParentQueue parent = queue.GetParent();

            while (parent != null)
            {
                parent.IncrementRunnableApps();
                parent = parent.GetParent();
            }
            int userNumRunnable = usersNumRunnableApps[user];

            usersNumRunnableApps[user] = (userNumRunnable == null ? 0 : userNumRunnable) + 1;
        }
コード例 #3
0
        /// <summary>
        /// Updates the relevant tracking variables after a runnable app with the given
        /// queue and user has been removed.
        /// </summary>
        public virtual void UntrackRunnableApp(FSAppAttempt app)
        {
            // Update usersRunnableApps
            string user = app.GetUser();
            int    newUserNumRunning = usersNumRunnableApps[user] - 1;

            if (newUserNumRunning == 0)
            {
                Sharpen.Collections.Remove(usersNumRunnableApps, user);
            }
            else
            {
                usersNumRunnableApps[user] = newUserNumRunning;
            }
            // Update runnable app bookkeeping for queues
            FSLeafQueue   queue  = ((FSLeafQueue)app.GetQueue());
            FSParentQueue parent = queue.GetParent();

            while (parent != null)
            {
                parent.DecrementRunnableApps();
                parent = parent.GetParent();
            }
        }
コード例 #4
0
 private void RemoveApp(FSAppAttempt app)
 {
     ((FSLeafQueue)app.GetQueue()).RemoveApp(app);
     maxAppsEnforcer.UntrackRunnableApp(app);
     maxAppsEnforcer.UpdateRunnabilityOnAppRemoval(app, ((FSLeafQueue)app.GetQueue()));
 }