JackWangCS commented on a change in pull request #3361:
URL: https://github.com/apache/hadoop/pull/3361#discussion_r700368168
##########
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/AbstractManagedParentQueue.java
##########
@@ -173,50 +168,31 @@ public AutoCreatedLeafQueueConfig getLeafQueueTemplate() {
return queueManagementPolicy;
}
- protected SortedMap<String, String> getConfigurationsWithPrefix
- (SortedMap<String, String> sortedConfigs, String prefix) {
- return sortedConfigs.subMap( prefix, prefix + Character.MAX_VALUE );
- }
-
- protected SortedMap<String, String> sortCSConfigurations() {
- SortedMap<String, String> sortedConfigs = new TreeMap(
- new Comparator<String>() {
- public int compare(String s1, String s2) {
- return s1.compareToIgnoreCase(s2);
- }
+ protected Map<String, String> getCSConfigurationsWithPrefix(String prefix) {
+ Map<String, String> configsWithPrefix = new HashMap<>();
- });
-
- for (final Iterator<Map.Entry<String, String>> iterator =
- csContext.getConfiguration().iterator(); iterator.hasNext(); ) {
- final Map.Entry<String, String> confKeyValuePair = iterator.next();
- sortedConfigs.put(confKeyValuePair.getKey(),
confKeyValuePair.getValue());
+ for (Map.Entry<String, String> confKeyValuePair :
+ csContext.getConfiguration().getPropsWithPrefix(prefix).entrySet()) {
+ configsWithPrefix.put(prefix + confKeyValuePair.getKey(),
confKeyValuePair.getValue());
}
- return sortedConfigs;
+
+ return configsWithPrefix;
}
- protected CapacitySchedulerConfiguration initializeLeafQueueConfigs(String
- configPrefix) {
+ protected CapacitySchedulerConfiguration initializeLeafQueueConfigs(String
configPrefix) {
CapacitySchedulerConfiguration leafQueueConfigs = new
- CapacitySchedulerConfiguration(new Configuration(false), false);
+ CapacitySchedulerConfiguration(csContext.getConf(), false);
Review comment:
Hi @brumi1024 , thanks for your review. For my understanging, the
`AbstractManagedParentQueue#initializeLeafQueueConfigs` is used to only
initialize the leafQueueTemplate when the parent queue is
initialized/re-initialized. And for each time, a newly created leafQueue should
use this `leafQueueTemplate` to get its configuration via adding new
configurations by replacing configurations with `leaf-queue-template`.
But now, [in
`ManagedParentQueue#getLeafQueueConfigs`](https://github.com/apache/hadoop/blob/24af52efaba8308e87d1790ccd915c594cf760cc/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ManagedParentQueue.java#L466),
it creates a new configuration everytime. So we need to reuse
`getLeafQueueTemplate().getLeafQueueConfigs()` directly instead of creating a
new one. I mean we can change this to
```
public CapacitySchedulerConfiguration getLeafQueueConfigs(
CapacitySchedulerConfiguration templateConfig, String leafQueueName) {
CapacitySchedulerConfiguration leafQueueConfigTemplate = templateConfig;
.....
}
```
What do you think of?
--
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]