Skip to content

Commit 9e475ae

Browse files
committed
YARN-10983. Follow-up changes for YARN-10904. Contributed by Benjamin Teke
1 parent 9199787 commit 9e475ae

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ protected void setupQueueConfigs(Resource clusterResource) throws
331331

332332
// Collect and set the Node label configuration
333333
this.queueNodeLabelsSettings = new QueueNodeLabelsSettings(configuration, parent,
334-
getQueuePath(), queueContext.getQueueManager().getConfiguredNodeLabelsForAllQueues());
334+
queuePath, queueContext.getQueueManager().getConfiguredNodeLabelsForAllQueues());
335335

336336
// Initialize the queue capacities
337337
setupConfigurableCapacities();
@@ -379,7 +379,7 @@ protected void setupQueueConfigs(Resource clusterResource) throws
379379

380380
// Setup application related limits
381381
this.queueAppLifetimeSettings = new QueueAppLifetimeAndLimitSettings(configuration,
382-
this, getQueuePath());
382+
this, queuePath);
383383
} finally {
384384
writeLock.unlock();
385385
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/QueueAppLifetimeAndLimitSettings.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public class QueueAppLifetimeAndLimitSettings {
3535
private int maxParallelApps;
3636

3737
public QueueAppLifetimeAndLimitSettings(CapacitySchedulerConfiguration configuration,
38-
AbstractCSQueue q, String queuePath) {
38+
AbstractCSQueue q, QueuePath queuePath) {
3939
// Store max parallel apps property
40-
this.maxParallelApps = configuration.getMaxParallelAppsForQueue(queuePath);
40+
this.maxParallelApps = configuration.getMaxParallelAppsForQueue(queuePath.getFullPath());
4141
this.maxApplicationLifetime = getInheritedMaxAppLifetime(q, configuration);
4242
this.defaultApplicationLifetime = setupInheritedDefaultAppLifetime(q, queuePath, configuration,
4343
maxApplicationLifetime);
@@ -48,7 +48,7 @@ private long getInheritedMaxAppLifetime(CSQueue q, CapacitySchedulerConfiguratio
4848
long maxAppLifetime = conf.getMaximumLifetimePerQueue(q.getQueuePath());
4949

5050
// If q is the root queue, then get max app lifetime from conf.
51-
if (parentQ == null) {
51+
if (q.getQueuePathObject().isRoot()) {
5252
return maxAppLifetime;
5353
}
5454

@@ -62,16 +62,16 @@ private long getInheritedMaxAppLifetime(CSQueue q, CapacitySchedulerConfiguratio
6262
}
6363

6464
private long setupInheritedDefaultAppLifetime(CSQueue q,
65-
String queuePath, CapacitySchedulerConfiguration conf, long myMaxAppLifetime) {
65+
QueuePath queuePath, CapacitySchedulerConfiguration conf, long myMaxAppLifetime) {
6666
CSQueue parentQ = q.getParent();
67-
long defaultAppLifetime = conf.getDefaultLifetimePerQueue(queuePath);
67+
long defaultAppLifetime = conf.getDefaultLifetimePerQueue(queuePath.getFullPath());
6868
defaultAppLifetimeWasSpecifiedInConfig =
6969
(defaultAppLifetime >= 0
70-
|| (parentQ != null &&
70+
|| (!queuePath.isRoot() &&
7171
parentQ.getDefaultAppLifetimeWasSpecifiedInConfig()));
7272

7373
// If q is the root queue, then get default app lifetime from conf.
74-
if (parentQ == null) {
74+
if (queuePath.isRoot()) {
7575
return defaultAppLifetime;
7676
}
7777

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/QueueNodeLabelsSettings.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.apache.commons.lang3.StringUtils;
2020
import org.apache.hadoop.util.Sets;
2121
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
22-
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.ROOT;
2322
import java.io.IOException;
2423
import java.util.Set;
2524

@@ -30,14 +29,14 @@
3029
*/
3130
public class QueueNodeLabelsSettings {
3231
private final CSQueue parent;
33-
private final String queuePath;
32+
private final QueuePath queuePath;
3433
private Set<String> accessibleLabels;
3534
private Set<String> configuredNodeLabels;
3635
private String defaultLabelExpression;
3736

3837
public QueueNodeLabelsSettings(CapacitySchedulerConfiguration configuration,
3938
CSQueue parent,
40-
String queuePath,
39+
QueuePath queuePath,
4140
ConfiguredNodeLabels configuredNodeLabels) throws IOException {
4241
this.parent = parent;
4342
this.queuePath = queuePath;
@@ -54,15 +53,16 @@ private void initializeNodeLabels(CapacitySchedulerConfiguration configuration,
5453
}
5554

5655
private void initializeAccessibleLabels(CapacitySchedulerConfiguration configuration) {
57-
this.accessibleLabels = configuration.getAccessibleNodeLabels(queuePath);
56+
this.accessibleLabels = configuration.getAccessibleNodeLabels(queuePath.getFullPath());
5857
// Inherit labels from parent if not set
5958
if (this.accessibleLabels == null && parent != null) {
6059
this.accessibleLabels = parent.getAccessibleNodeLabels();
6160
}
6261
}
6362

6463
private void initializeDefaultLabelExpression(CapacitySchedulerConfiguration configuration) {
65-
this.defaultLabelExpression = configuration.getDefaultNodeLabelExpression(queuePath);
64+
this.defaultLabelExpression = configuration.getDefaultNodeLabelExpression(
65+
queuePath.getFullPath());
6666
// If the accessible labels is not null and the queue has a parent with a
6767
// similar set of labels copy the defaultNodeLabelExpression from the parent
6868
if (this.accessibleLabels != null && parent != null
@@ -75,21 +75,22 @@ private void initializeDefaultLabelExpression(CapacitySchedulerConfiguration con
7575
private void initializeConfiguredNodeLabels(CapacitySchedulerConfiguration configuration,
7676
ConfiguredNodeLabels configuredNodeLabelsParam) {
7777
if (configuredNodeLabelsParam != null) {
78-
if (queuePath.equals(ROOT)) {
78+
if (queuePath.isRoot()) {
7979
this.configuredNodeLabels = configuredNodeLabelsParam.getAllConfiguredLabels();
8080
} else {
81-
this.configuredNodeLabels = configuredNodeLabelsParam.getLabelsByQueue(queuePath);
81+
this.configuredNodeLabels = configuredNodeLabelsParam.getLabelsByQueue(
82+
queuePath.getFullPath());
8283
}
8384
} else {
8485
// Fallback to suboptimal but correct logic
85-
this.configuredNodeLabels = configuration.getConfiguredNodeLabels(queuePath);
86+
this.configuredNodeLabels = configuration.getConfiguredNodeLabels(queuePath.getFullPath());
8687
}
8788
}
8889

8990
private void validateNodeLabels() throws IOException {
9091
// Check if labels of this queue is a subset of parent queue, only do this
9192
// when the queue in question is not root
92-
if (isNotRoot()) {
93+
if (!queuePath.isRoot()) {
9394
if (parent.getAccessibleNodeLabels() != null && !parent
9495
.getAccessibleNodeLabels().contains(RMNodeLabelsManager.ANY)) {
9596
// If parent isn't "*", child shouldn't be "*" too
@@ -109,10 +110,6 @@ private void validateNodeLabels() throws IOException {
109110
}
110111
}
111112

112-
private boolean isNotRoot() {
113-
return parent != null && parent.getParent() != null;
114-
}
115-
116113
public boolean isAccessibleToPartition(String nodePartition) {
117114
// if queue's label is *, it can access any node
118115
if (accessibleLabels != null && accessibleLabels.contains(RMNodeLabelsManager.ANY)) {

0 commit comments

Comments
 (0)