Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YARN-11533. CapacityScheduler CapacityConfigType changed in legacy queue allocation mode #5852

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -518,21 +518,27 @@ protected void updateCapacityConfigType() {

CapacityConfigType localType = CapacityConfigType.NONE;

// TODO: revisit this later
// AbstractCSQueue.CapacityConfigType has only None, Percentage and Absolute mode
final Set<QueueCapacityVector.ResourceUnitCapacityType> definedCapacityTypes =
getConfiguredCapacityVector(label).getDefinedCapacityTypes();
if (definedCapacityTypes.size() == 1) {
QueueCapacityVector.ResourceUnitCapacityType next = definedCapacityTypes.iterator().next();
if (Objects.requireNonNull(next) == PERCENTAGE) {
localType = CapacityConfigType.PERCENTAGE;
} else if (next == QueueCapacityVector.ResourceUnitCapacityType.ABSOLUTE) {
localType = CapacityConfigType.ABSOLUTE_RESOURCE;
} else if (next == WEIGHT) {
if (queueContext.getConfiguration().isLegacyQueueMode()) {
localType = checkConfigTypeIsAbsoluteResource(
getQueuePath(), label) ? CapacityConfigType.ABSOLUTE_RESOURCE
: CapacityConfigType.PERCENTAGE;
} else {
// TODO: revisit this later
// AbstractCSQueue.CapacityConfigType has only None, Percentage and Absolute mode
final Set<QueueCapacityVector.ResourceUnitCapacityType> definedCapacityTypes =
getConfiguredCapacityVector(label).getDefinedCapacityTypes();
if (definedCapacityTypes.size() == 1) {
QueueCapacityVector.ResourceUnitCapacityType next = definedCapacityTypes.iterator().next();
if (Objects.requireNonNull(next) == PERCENTAGE) {
localType = CapacityConfigType.PERCENTAGE;
} else if (next == QueueCapacityVector.ResourceUnitCapacityType.ABSOLUTE) {
localType = CapacityConfigType.ABSOLUTE_RESOURCE;
} else if (next == WEIGHT) {
localType = CapacityConfigType.PERCENTAGE;
}
} else { // Mixed type
localType = CapacityConfigType.PERCENTAGE;
}
} else { // Mixed type
localType = CapacityConfigType.PERCENTAGE;
}

if (this.capacityConfigType.equals(CapacityConfigType.NONE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,35 @@ public class CapacitySchedulerInfoHelper {
private CapacitySchedulerInfoHelper() {}

public static String getMode(CSQueue queue) {
final Set<QueueCapacityVector.ResourceUnitCapacityType> definedCapacityTypes =
queue.getConfiguredCapacityVector(NO_LABEL).getDefinedCapacityTypes();
if (definedCapacityTypes.size() == 1) {
QueueCapacityVector.ResourceUnitCapacityType next = definedCapacityTypes.iterator().next();
if (Objects.requireNonNull(next) == PERCENTAGE) {
return "percentage";
} else if (next == QueueCapacityVector.ResourceUnitCapacityType.ABSOLUTE) {
if (((AbstractCSQueue) queue).getQueueContext().getConfiguration().isLegacyQueueMode()) {
if (queue.getCapacityConfigType() ==
AbstractCSQueue.CapacityConfigType.ABSOLUTE_RESOURCE) {
return "absolute";
} else if (next == QueueCapacityVector.ResourceUnitCapacityType.WEIGHT) {
return "weight";
} else if (queue.getCapacityConfigType() ==
AbstractCSQueue.CapacityConfigType.PERCENTAGE) {
float weight = queue.getQueueCapacities().getWeight();
if (weight == -1) {
//-1 indicates we are not in weight mode
return "percentage";
} else {
return "weight";
}
}
} else {
final Set<QueueCapacityVector.ResourceUnitCapacityType> definedCapacityTypes =
queue.getConfiguredCapacityVector(NO_LABEL).getDefinedCapacityTypes();
if (definedCapacityTypes.size() == 1) {
QueueCapacityVector.ResourceUnitCapacityType next = definedCapacityTypes.iterator().next();
if (Objects.requireNonNull(next) == PERCENTAGE) {
return "percentage";
} else if (next == QueueCapacityVector.ResourceUnitCapacityType.ABSOLUTE) {
return "absolute";
} else if (next == QueueCapacityVector.ResourceUnitCapacityType.WEIGHT) {
return "weight";
}
} else if (definedCapacityTypes.size() > 1) {
return "mixed";
}
} else if (definedCapacityTypes.size() > 1) {
return "mixed";
}

return "unknown";
Expand Down