YARN-10944. AbstractCSQueue: Eliminate code duplication in overloaded versions of setMaxCapacity. Contributed by Andras Gyori
This commit is contained in:
parent
1f157f802d
commit
0463498adc
@ -74,6 +74,7 @@
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
|
import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NO_LABEL;
|
||||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.DOT;
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.DOT;
|
||||||
|
|
||||||
public abstract class AbstractCSQueue implements CSQueue {
|
public abstract class AbstractCSQueue implements CSQueue {
|
||||||
@ -279,33 +280,23 @@ public boolean hasAccess(QueueACL acl, UserGroupInformation user) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set maximum capacity - used only for testing.
|
* Set maximum capacity for empty node label.
|
||||||
* @param maximumCapacity new max capacity
|
* @param maximumCapacity new max capacity
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void setMaxCapacity(float maximumCapacity) {
|
void setMaxCapacity(float maximumCapacity) {
|
||||||
writeLock.lock();
|
internalSetMaximumCapacity(maximumCapacity, NO_LABEL);
|
||||||
try {
|
|
||||||
// Sanity check
|
|
||||||
CSQueueUtils.checkMaxCapacity(this.queuePath,
|
|
||||||
queueCapacities.getCapacity(), maximumCapacity);
|
|
||||||
float absMaxCapacity = CSQueueUtils.computeAbsoluteMaximumCapacity(
|
|
||||||
maximumCapacity, parent);
|
|
||||||
CSQueueUtils.checkAbsoluteCapacity(this.queuePath,
|
|
||||||
queueCapacities.getAbsoluteCapacity(), absMaxCapacity);
|
|
||||||
|
|
||||||
queueCapacities.setMaximumCapacity(maximumCapacity);
|
|
||||||
queueCapacities.setAbsoluteMaximumCapacity(absMaxCapacity);
|
|
||||||
} finally {
|
|
||||||
writeLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set maximum capacity
|
* Set maximum capacity.
|
||||||
* @param maximumCapacity new max capacity
|
* @param maximumCapacity new max capacity
|
||||||
*/
|
*/
|
||||||
void setMaxCapacity(String nodeLabel, float maximumCapacity) {
|
void setMaxCapacity(String nodeLabel, float maximumCapacity) {
|
||||||
|
internalSetMaximumCapacity(maximumCapacity, nodeLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalSetMaximumCapacity(float maximumCapacity, String nodeLabel) {
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try {
|
try {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
@ -323,7 +314,6 @@ void setMaxCapacity(String nodeLabel, float maximumCapacity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultNodeLabelExpression() {
|
public String getDefaultNodeLabelExpression() {
|
||||||
return this.queueNodeLabelsSettings.getDefaultLabelExpression();
|
return this.queueNodeLabelsSettings.getDefaultLabelExpression();
|
||||||
@ -917,7 +907,7 @@ boolean canAssignToThisQueue(Resource clusterResource,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String ensurePartition(String partition) {
|
private static String ensurePartition(String partition) {
|
||||||
return Optional.ofNullable(partition).orElse(RMNodeLabelsManager.NO_LABEL);
|
return Optional.ofNullable(partition).orElse(NO_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
@ -1016,8 +1006,8 @@ public Set<String> getNodeLabelsForQueue() {
|
|||||||
|
|
||||||
// Add NO_LABEL also to this list as NO_LABEL also can be granted with
|
// Add NO_LABEL also to this list as NO_LABEL also can be granted with
|
||||||
// resource in many general cases.
|
// resource in many general cases.
|
||||||
if (!nodeLabels.contains(RMNodeLabelsManager.NO_LABEL)) {
|
if (!nodeLabels.contains(NO_LABEL)) {
|
||||||
nodeLabels.add(RMNodeLabelsManager.NO_LABEL);
|
nodeLabels.add(NO_LABEL);
|
||||||
}
|
}
|
||||||
return nodeLabels;
|
return nodeLabels;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user