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(); } }
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())); }
private ResourceLimits GetResourceLimitsOfChild(CSQueue child, Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource, ResourceLimits parentLimits) { // Set resource-limit of a given child, child.limit = // min(my.limit - my.used + child.used, child.max) // Parent available resource = parent-limit - parent-used-resource Org.Apache.Hadoop.Yarn.Api.Records.Resource parentMaxAvailableResource = Resources .Subtract(parentLimits.GetLimit(), GetUsedResources()); // Child's limit = parent-available-resource + child-used Org.Apache.Hadoop.Yarn.Api.Records.Resource childLimit = Resources.Add(parentMaxAvailableResource , child.GetUsedResources()); // Get child's max resource Org.Apache.Hadoop.Yarn.Api.Records.Resource childConfiguredMaxResource = Resources .MultiplyAndNormalizeDown(resourceCalculator, labelManager.GetResourceByLabel(RMNodeLabelsManager .NoLabel, clusterResource), child.GetAbsoluteMaximumCapacity(), minimumAllocation ); // Child's limit should be capped by child configured max resource childLimit = Resources.Min(resourceCalculator, clusterResource, childLimit, childConfiguredMaxResource ); // Normalize before return childLimit = Resources.RoundDown(resourceCalculator, childLimit, minimumAllocation ); return(new ResourceLimits(childLimit)); }