9uapaw commented on a change in pull request #3470:
URL: https://github.com/apache/hadoop/pull/3470#discussion_r809136920
##########
File path:
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueCapacityHandler.java
##########
@@ -70,61 +70,133 @@ public
CapacitySchedulerQueueCapacityHandler(RMNodeLabelsManager labelsManager)
}
/**
- * Updates the resource and metrics values for a queue, its siblings and
descendants.
+ * Updates the resource and metrics values of all children under a specific
queue.
* These values are calculated at runtime.
*
* @param clusterResource resource of the cluster
- * @param queue queue to update
+ * @param queue parent queue whose children will be updated
* @return update context that contains information about the update phase
*/
- public QueueCapacityUpdateContext update(Resource clusterResource, CSQueue
queue) {
+ public QueueCapacityUpdateContext updateChildren(Resource clusterResource,
CSQueue queue) {
ResourceLimits resourceLimits = new ResourceLimits(clusterResource);
QueueCapacityUpdateContext updateContext =
new QueueCapacityUpdateContext(clusterResource, labelsManager);
- if (queue.getQueuePath().equals(ROOT)) {
- updateRoot(queue, updateContext, resourceLimits);
- updateChildren(queue, updateContext, resourceLimits);
- } else {
- updateChildren(queue.getParent(), updateContext, resourceLimits);
- }
-
+ update(queue, updateContext, resourceLimits);
return updateContext;
}
- private void updateRoot(
- CSQueue queue, QueueCapacityUpdateContext updateContext, ResourceLimits
resourceLimits) {
- RootCalculationDriver rootCalculationDriver = new
RootCalculationDriver(queue, updateContext,
+ /**
+ * Updates the resource and metrics value of the root queue. Root queue
always has percentage
+ * capacity type and is assigned the cluster resource as its minimum and
maximum effective
+ * resource.
+ * @param rootQueue root queue
+ * @param clusterResource cluster resource
+ */
+ public void updateRoot(CSQueue rootQueue, Resource clusterResource) {
+ ResourceLimits resourceLimits = new ResourceLimits(clusterResource);
+ QueueCapacityUpdateContext updateContext =
+ new QueueCapacityUpdateContext(clusterResource, labelsManager);
+
+ RootCalculationDriver rootCalculationDriver = new
RootCalculationDriver(rootQueue, updateContext,
rootCalculator, definedResources);
rootCalculationDriver.calculateResources();
-
queue.refreshAfterResourceCalculation(updateContext.getUpdatedClusterResource(),
resourceLimits);
+
rootQueue.refreshAfterResourceCalculation(updateContext.getUpdatedClusterResource(),
resourceLimits);
}
- private void updateChildren(
- CSQueue parent, QueueCapacityUpdateContext updateContext,
- ResourceLimits resourceLimits) {
- if (parent == null || CollectionUtils.isEmpty(parent.getChildQueues())) {
+ private void update(
+ CSQueue queue, QueueCapacityUpdateContext updateContext, ResourceLimits
resourceLimits) {
+ if (queue == null || CollectionUtils.isEmpty(queue.getChildQueues())) {
return;
}
ResourceCalculationDriver resourceCalculationDriver = new
ResourceCalculationDriver(
- parent, updateContext, calculators, definedResources);
+ queue, updateContext, calculators, definedResources);
resourceCalculationDriver.calculateResources();
updateChildrenAfterCalculation(resourceCalculationDriver, resourceLimits);
}
private void updateChildrenAfterCalculation(
ResourceCalculationDriver resourceCalculationDriver, ResourceLimits
resourceLimits) {
- for (CSQueue childQueue :
resourceCalculationDriver.getParent().getChildQueues()) {
- resourceCalculationDriver.setCurrentChild(childQueue);
- resourceCalculationDriver.updateChildCapacities();
- ResourceLimits childLimit = ((ParentQueue)
resourceCalculationDriver.getParent()).getResourceLimitsOfChild(
- childQueue,
resourceCalculationDriver.getUpdateContext().getUpdatedClusterResource(),
resourceLimits, NO_LABEL, false);
+ ParentQueue parentQueue = (ParentQueue)
resourceCalculationDriver.getQueue();
+ for (CSQueue childQueue : parentQueue.getChildQueues()) {
+ updateChildCapacities(resourceCalculationDriver, childQueue);
+
+ ResourceLimits childLimit =
parentQueue.getResourceLimitsOfChild(childQueue,
+
resourceCalculationDriver.getUpdateContext().getUpdatedClusterResource(),
+ resourceLimits, NO_LABEL, false);
childQueue.refreshAfterResourceCalculation(resourceCalculationDriver.getUpdateContext()
.getUpdatedClusterResource(), childLimit);
- updateChildren(childQueue, resourceCalculationDriver.getUpdateContext(),
childLimit);
+
+ update(childQueue, resourceCalculationDriver.getUpdateContext(),
childLimit);
+ }
+ }
+
+ /**
+ * Updates the capacity values of the currently evaluated child.
+ * @param childQueue child queue on which the capacities are set
+ */
+ private void updateChildCapacities(ResourceCalculationDriver
resourceCalculationDriver, CSQueue childQueue) {
Review comment:
It is the same here as well: we named the parent queue on which the
handler was invoked as queue, then passing an other queue as parameter is
ambiguous. This child is relative to the queue, which is stored in the driver.
Since we always do calculations in batch under a specific parent, we need to
distinguish the difference between the children we are actually using in the
calculators and their common parent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]