Пример #1
0
        public static void UpdateQueueStatistics(ResourceCalculator calculator, CSQueue childQueue
                                                 , CSQueue parentQueue, Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource
                                                 , Org.Apache.Hadoop.Yarn.Api.Records.Resource minimumAllocation)
        {
            Org.Apache.Hadoop.Yarn.Api.Records.Resource queueLimit    = Resources.None();
            Org.Apache.Hadoop.Yarn.Api.Records.Resource usedResources = childQueue.GetUsedResources
                                                                            ();
            float absoluteUsedCapacity = 0.0f;
            float usedCapacity         = 0.0f;

            if (Resources.GreaterThan(calculator, clusterResource, clusterResource, Resources
                                      .None()))
            {
                queueLimit = Resources.Multiply(clusterResource, childQueue.GetAbsoluteCapacity()
                                                );
                absoluteUsedCapacity = Resources.Divide(calculator, clusterResource, usedResources
                                                        , clusterResource);
                usedCapacity = Resources.Equals(queueLimit, Resources.None()) ? 0 : Resources.Divide
                                   (calculator, clusterResource, usedResources, queueLimit);
            }
            childQueue.SetUsedCapacity(usedCapacity);
            childQueue.SetAbsoluteUsedCapacity(absoluteUsedCapacity);
            Org.Apache.Hadoop.Yarn.Api.Records.Resource available = Resources.Subtract(queueLimit
                                                                                       , usedResources);
            childQueue.GetMetrics().SetAvailableResourcesToQueue(Resources.Max(calculator, clusterResource
                                                                               , available, Resources.None()));
        }
Пример #2
0
        /// <exception cref="System.IO.IOException"/>
        public AbstractCSQueue(CapacitySchedulerContext cs, string queueName, CSQueue parent
                               , CSQueue old)
        {
            // Track resource usage-by-label like used-resource/pending-resource, etc.
            // Track capacities like used-capcity/abs-used-capacity/capacity/abs-capacity,
            // etc.
            this.labelManager       = cs.GetRMContext().GetNodeLabelManager();
            this.parent             = parent;
            this.queueName          = queueName;
            this.resourceCalculator = cs.GetResourceCalculator();
            // must be called after parent and queueName is set
            this.metrics = old != null?old.GetMetrics() : QueueMetrics.ForQueue(GetQueuePath
                                                                                    (), parent, cs.GetConfiguration().GetEnableUserMetrics(), cs.GetConf());

            this.csContext         = cs;
            this.minimumAllocation = csContext.GetMinimumResourceCapability();
            // initialize ResourceUsage
            queueUsage  = new ResourceUsage();
            queueEntity = new PrivilegedEntity(PrivilegedEntity.EntityType.Queue, GetQueuePath
                                                   ());
            // initialize QueueCapacities
            queueCapacities = new QueueCapacities(parent == null);
        }