示例#1
0
 public virtual void UpdateAllocationConfiguration(AllocationConfiguration queueConf
                                                   )
 {
     // Create leaf queues and the parent queues in a leaf's ancestry if they do not exist
     foreach (string name in queueConf.GetConfiguredQueues()[FSQueueType.Leaf])
     {
         if (RemoveEmptyIncompatibleQueues(name, FSQueueType.Leaf))
         {
             GetLeafQueue(name, true);
         }
     }
     // At this point all leaves and 'parents with at least one child' would have been created.
     // Now create parents with no configured leaf.
     foreach (string name_1 in queueConf.GetConfiguredQueues()[FSQueueType.Parent])
     {
         if (RemoveEmptyIncompatibleQueues(name_1, FSQueueType.Parent))
         {
             GetParentQueue(name_1, true);
         }
     }
     foreach (FSQueue queue in queues.Values)
     {
         // Update queue metrics
         FSQueueMetrics queueMetrics = queue.GetMetrics();
         queueMetrics.SetMinShare(queue.GetMinShare());
         queueMetrics.SetMaxShare(queue.GetMaxShare());
         // Set scheduling policies
         try
         {
             SchedulingPolicy policy = queueConf.GetSchedulingPolicy(queue.GetName());
             policy.Initialize(scheduler.GetClusterResource());
             queue.SetPolicy(policy);
         }
         catch (AllocationConfigurationException ex)
         {
             Log.Warn("Cannot apply configured scheduling policy to queue " + queue.GetName(),
                      ex);
         }
     }
     // Update steady fair shares for all queues
     rootQueue.RecomputeSteadyShares();
     // Update the fair share preemption timeouts and preemption for all queues
     // recursively
     rootQueue.UpdatePreemptionVariables();
 }
示例#2
0
        /// <summary>
        /// Creates a leaf or parent queue based on what is specified in 'queueType'
        /// and places it in the tree.
        /// </summary>
        /// <remarks>
        /// Creates a leaf or parent queue based on what is specified in 'queueType'
        /// and places it in the tree. Creates any parents that don't already exist.
        /// </remarks>
        /// <returns>
        /// the created queue, if successful. null if not allowed (one of the parent
        /// queues in the queue name is already a leaf queue)
        /// </returns>
        private FSQueue CreateQueue(string name, FSQueueType queueType)
        {
            IList <string> newQueueNames = new AList <string>();

            newQueueNames.AddItem(name);
            int           sepIndex = name.Length;
            FSParentQueue parent   = null;

            // Move up the queue tree until we reach one that exists.
            while (sepIndex != -1)
            {
                sepIndex = name.LastIndexOf('.', sepIndex - 1);
                FSQueue queue;
                string  curName = null;
                curName = Sharpen.Runtime.Substring(name, 0, sepIndex);
                queue   = queues[curName];
                if (queue == null)
                {
                    newQueueNames.AddItem(curName);
                }
                else
                {
                    if (queue is FSParentQueue)
                    {
                        parent = (FSParentQueue)queue;
                        break;
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            // At this point, parent refers to the deepest existing parent of the
            // queue to create.
            // Now that we know everything worked out, make all the queues
            // and add them to the map.
            AllocationConfiguration queueConf = scheduler.GetAllocationConfiguration();
            FSLeafQueue             leafQueue = null;

            for (int i = newQueueNames.Count - 1; i >= 0; i--)
            {
                string queueName = newQueueNames[i];
                if (i == 0 && queueType != FSQueueType.Parent)
                {
                    leafQueue = new FSLeafQueue(name, scheduler, parent);
                    try
                    {
                        leafQueue.SetPolicy(queueConf.GetDefaultSchedulingPolicy());
                    }
                    catch (AllocationConfigurationException ex)
                    {
                        Log.Warn("Failed to set default scheduling policy " + queueConf.GetDefaultSchedulingPolicy
                                     () + " on new leaf queue.", ex);
                    }
                    parent.AddChildQueue(leafQueue);
                    queues[leafQueue.GetName()] = leafQueue;
                    leafQueues.AddItem(leafQueue);
                    leafQueue.UpdatePreemptionVariables();
                    return(leafQueue);
                }
                else
                {
                    FSParentQueue newParent = new FSParentQueue(queueName, scheduler, parent);
                    try
                    {
                        newParent.SetPolicy(queueConf.GetDefaultSchedulingPolicy());
                    }
                    catch (AllocationConfigurationException ex)
                    {
                        Log.Warn("Failed to set default scheduling policy " + queueConf.GetDefaultSchedulingPolicy
                                     () + " on new parent queue.", ex);
                    }
                    parent.AddChildQueue(newParent);
                    queues[newParent.GetName()] = newParent;
                    newParent.UpdatePreemptionVariables();
                    parent = newParent;
                }
            }
            return(parent);
        }