diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java index a10f44898b0..bef8f4ba344 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java @@ -102,6 +102,7 @@ private RMActiveServiceContext activeServiceContext; private String proxyHostAndPort = null; + private Set exclusiveEnforcedPartitions; /** * Default constructor. To be used in conjunction with setter methods for @@ -683,18 +684,22 @@ public void incrTokenSequenceNo() { } public Set getExclusiveEnforcedPartitions() { - Set exclusiveEnforcedPartitions = new HashSet<>(); - Configuration conf = getYarnConfiguration(); - if (conf == null) { - return new HashSet<>(); - } - String[] configuredPartitions = conf.getStrings( - YarnConfiguration.EXCLUSIVE_ENFORCED_PARTITIONS); - if (configuredPartitions != null) { - for (String partition : configuredPartitions) { - exclusiveEnforcedPartitions.add(partition); + if (this.exclusiveEnforcedPartitions == null) { + Set ret = new HashSet<>(); + Configuration conf = getYarnConfiguration(); + if (conf == null) { + this.exclusiveEnforcedPartitions = new HashSet<>(); + return new HashSet<>(); + } + String[] configuredPartitions = conf.getStrings( + YarnConfiguration.EXCLUSIVE_ENFORCED_PARTITIONS); + if (configuredPartitions != null) { + for (String partition : configuredPartitions) { + ret.add(partition); + } } + this.exclusiveEnforcedPartitions = ret; } - return exclusiveEnforcedPartitions; + return this.exclusiveEnforcedPartitions; } }