-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YARN-10965. Simplify logic in QueueHandler
- Loading branch information
Showing
27 changed files
with
1,348 additions
and
722 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 30 additions & 40 deletions
70
...op/yarn/server/resourcemanager/scheduler/capacity/AbsoluteResourceCapacityCalculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,55 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity; | ||
|
||
import org.apache.hadoop.yarn.api.records.Resource; | ||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.QueueCapacityType; | ||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.ResourceUnitCapacityType; | ||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.QueueCapacityVectorEntry; | ||
|
||
public class AbsoluteResourceCapacityCalculator extends AbstractQueueCapacityCalculator { | ||
|
||
@Override | ||
protected float calculateMinimumResource( | ||
QueueHierarchyUpdateContext updateContext, CSQueue childQueue, String label, | ||
public float calculateMinimumResource( | ||
QueueCapacityUpdateContext updateContext, CSQueue childQueue, String label, | ||
QueueCapacityVectorEntry capacityVectorEntry) { | ||
String resourceName = capacityVectorEntry.getResourceName(); | ||
ResourceVector ratio = updateContext.getNormalizedMinResourceRatio( | ||
childQueue.getParent().getQueuePath(), label); | ||
ResourceVector ratio = updateContext.getQueueBranchContext(childQueue.getParent().getQueuePath()) | ||
.getNormalizedResourceRatios().getOrDefault(label, ResourceVector.of(1)); | ||
|
||
return ratio.getValue(resourceName) * capacityVectorEntry.getResourceValue(); | ||
} | ||
|
||
@Override | ||
protected float calculateMaximumResource( | ||
QueueHierarchyUpdateContext updateContext, CSQueue childQueue, String label, | ||
public float calculateMaximumResource( | ||
QueueCapacityUpdateContext updateContext, CSQueue childQueue, String label, | ||
QueueCapacityVectorEntry capacityVectorEntry) { | ||
return capacityVectorEntry.getResourceValue(); | ||
} | ||
|
||
@Override | ||
protected QueueCapacityType getCapacityType() { | ||
return QueueCapacityType.ABSOLUTE; | ||
} | ||
|
||
@Override | ||
public void setup(CSQueue queue, String label) { | ||
Resource minResource = Resource.newInstance(0, 0); | ||
|
||
for (String resourceName : getResourceNames(queue, label)) { | ||
long resource = (long) queue.getConfiguredCapacityVector( | ||
label).getResource(resourceName).getResourceValue(); | ||
minResource.setResourceValue(resourceName, minResource.getResourceValue( | ||
resourceName) + resource); | ||
} | ||
|
||
queue.getQueueResourceQuotas().setConfiguredMinResource(label, minResource); | ||
public void updateCapacitiesAfterCalculation( | ||
QueueCapacityUpdateContext updateContext, CSQueue queue, String label) { | ||
setQueueCapacities(updateContext.getUpdatedClusterResource(label), queue, label); | ||
} | ||
|
||
@Override | ||
public void setMetrics(QueueHierarchyUpdateContext updateContext, | ||
CSQueue queue, String label) { | ||
float sumCapacity = 0f; | ||
float sumAbsoluteCapacity = 0f; | ||
|
||
for (String resourceName : getResourceNames(queue, label)) { | ||
sumCapacity += queue.getConfiguredCapacityVector(label).getResource( | ||
resourceName).getResourceValue() / queue.getParent() | ||
.getQueueResourceQuotas().getEffectiveMinResource(label) | ||
.getResourceValue(resourceName); | ||
sumAbsoluteCapacity += updateContext.getAbsoluteMinCapacity( | ||
queue.getQueuePath(), label).getValue(resourceName); | ||
} | ||
|
||
queue.getQueueCapacities().setCapacity(label, sumCapacity); | ||
queue.getQueueCapacities().setAbsoluteCapacity(label, sumAbsoluteCapacity); | ||
public ResourceUnitCapacityType getCapacityType() { | ||
return ResourceUnitCapacityType.ABSOLUTE; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.