|
22 | 22 | import org.apache.hadoop.yarn.exceptions.YarnException; |
23 | 23 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler |
24 | 24 | .SchedulerDynamicEditException; |
| 25 | +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AbstractCSQueue.CapacityConfigType; |
25 | 26 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica |
26 | 27 | .FiCaSchedulerApp; |
27 | | - |
| 28 | +import org.apache.hadoop.yarn.util.resource.Resources; |
28 | 29 | import org.slf4j.Logger; |
29 | 30 | import org.slf4j.LoggerFactory; |
30 | 31 |
|
@@ -150,24 +151,78 @@ private void reinitializeQueueManagementPolicy() throws IOException { |
150 | 151 | } |
151 | 152 | } |
152 | 153 |
|
153 | | - protected AutoCreatedLeafQueueConfig.Builder initializeLeafQueueConfigs() { |
| 154 | + protected AutoCreatedLeafQueueConfig.Builder initializeLeafQueueConfigs() throws IOException { |
154 | 155 |
|
155 | 156 | AutoCreatedLeafQueueConfig.Builder builder = |
156 | 157 | new AutoCreatedLeafQueueConfig.Builder(); |
157 | 158 |
|
158 | 159 | String leafQueueTemplateConfPrefix = getLeafQueueConfigPrefix( |
159 | 160 | csContext.getConfiguration()); |
160 | 161 | //Load template configuration |
161 | | - builder.configuration( |
162 | | - super.initializeLeafQueueConfigs(leafQueueTemplateConfPrefix)); |
| 162 | + CapacitySchedulerConfiguration conf = |
| 163 | + super.initializeLeafQueueConfigs(leafQueueTemplateConfPrefix); |
| 164 | + builder.configuration(conf); |
| 165 | + |
| 166 | + for (String nodeLabel : conf |
| 167 | + .getConfiguredNodeLabels(csContext.getConfiguration() |
| 168 | + .getAutoCreatedQueueTemplateConfPrefix(getQueuePath()))) { |
| 169 | + Resource templateMinResource = conf.getMinimumResourceRequirement( |
| 170 | + nodeLabel, csContext.getConfiguration() |
| 171 | + .getAutoCreatedQueueTemplateConfPrefix(getQueuePath()), |
| 172 | + resourceTypes); |
| 173 | + |
| 174 | + if (this.capacityConfigType.equals(CapacityConfigType.PERCENTAGE) |
| 175 | + && !templateMinResource.equals(Resources.none())) { |
| 176 | + throw new IOException("Managed Parent Queue " + this.getQueuePath() |
| 177 | + + " config type is different from leaf queue template config type"); |
| 178 | + } |
| 179 | + } |
163 | 180 |
|
164 | 181 | //Load template capacities |
165 | 182 | QueueCapacities queueCapacities = new QueueCapacities(false); |
166 | 183 | CSQueueUtils.loadUpdateAndCheckCapacities(csContext.getConfiguration() |
167 | 184 | .getAutoCreatedQueueTemplateConfPrefix(getQueuePath()), |
168 | 185 | csContext.getConfiguration(), queueCapacities, getQueueCapacities()); |
169 | | - builder.capacities(queueCapacities); |
170 | 186 |
|
| 187 | + |
| 188 | + /** |
| 189 | + * Populate leaf queue template (of Parent resources configured in |
| 190 | + * ABSOLUTE_RESOURCE) capacities with actual values for which configured has |
| 191 | + * been defined in ABSOLUTE_RESOURCE format. |
| 192 | + * |
| 193 | + */ |
| 194 | + if (this.capacityConfigType.equals(CapacityConfigType.ABSOLUTE_RESOURCE)) { |
| 195 | + for (String label : queueCapacities.getExistingNodeLabels()) { |
| 196 | + queueCapacities.setCapacity(label, |
| 197 | + this.csContext.getResourceCalculator().divide( |
| 198 | + this.csContext.getClusterResource(), |
| 199 | + this.csContext.getConfiguration().getMinimumResourceRequirement( |
| 200 | + label, |
| 201 | + this.csContext.getConfiguration() |
| 202 | + .getAutoCreatedQueueTemplateConfPrefix(getQueuePath()), |
| 203 | + resourceTypes), |
| 204 | + getQueueResourceQuotas().getConfiguredMinResource(label))); |
| 205 | + |
| 206 | + queueCapacities.setMaximumCapacity(label, |
| 207 | + this.csContext.getResourceCalculator().divide( |
| 208 | + this.csContext.getClusterResource(), |
| 209 | + this.csContext.getConfiguration().getMaximumResourceRequirement( |
| 210 | + label, |
| 211 | + this.csContext.getConfiguration() |
| 212 | + .getAutoCreatedQueueTemplateConfPrefix(getQueuePath()), |
| 213 | + resourceTypes), |
| 214 | + getQueueResourceQuotas().getConfiguredMaxResource(label))); |
| 215 | + |
| 216 | + queueCapacities.setAbsoluteCapacity(label, |
| 217 | + queueCapacities.getCapacity(label) |
| 218 | + * getQueueCapacities().getAbsoluteCapacity(label)); |
| 219 | + |
| 220 | + queueCapacities.setAbsoluteMaximumCapacity(label, |
| 221 | + queueCapacities.getMaximumCapacity(label) |
| 222 | + * getQueueCapacities().getAbsoluteMaximumCapacity(label)); |
| 223 | + } |
| 224 | + } |
| 225 | + builder.capacities(queueCapacities); |
171 | 226 | return builder; |
172 | 227 | } |
173 | 228 |
|
|
0 commit comments