YARN-9791. Queue Mutation API does not allow to remove a config. Contributed by Prabhu Joseph.
This commit is contained in:
parent
18d74fe41c
commit
751b5a1ac8
@ -280,12 +280,14 @@ private void updateQueue(QueueConfigInfo updateInfo,
|
|||||||
String keyPrefix = CapacitySchedulerConfiguration.PREFIX
|
String keyPrefix = CapacitySchedulerConfiguration.PREFIX
|
||||||
+ queuePath + CapacitySchedulerConfiguration.DOT;
|
+ queuePath + CapacitySchedulerConfiguration.DOT;
|
||||||
for (Map.Entry<String, String> kv : updateInfo.getParams().entrySet()) {
|
for (Map.Entry<String, String> kv : updateInfo.getParams().entrySet()) {
|
||||||
if (kv.getValue() == null) {
|
String keyValue = kv.getValue();
|
||||||
|
if (keyValue == null || keyValue.isEmpty()) {
|
||||||
|
keyValue = null;
|
||||||
proposedConf.unset(keyPrefix + kv.getKey());
|
proposedConf.unset(keyPrefix + kv.getKey());
|
||||||
} else {
|
} else {
|
||||||
proposedConf.set(keyPrefix + kv.getKey(), kv.getValue());
|
proposedConf.set(keyPrefix + kv.getKey(), keyValue);
|
||||||
}
|
}
|
||||||
confUpdate.put(keyPrefix + kv.getKey(), kv.getValue());
|
confUpdate.put(keyPrefix + kv.getKey(), keyValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,43 @@ public void testInMemoryBackedProvider() throws Exception {
|
|||||||
"yarn.scheduler.capacity.root.a.badKey"));
|
"yarn.scheduler.capacity.root.a.badKey"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveQueueConfig() throws Exception {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
conf.set(YarnConfiguration.SCHEDULER_CONFIGURATION_STORE_CLASS,
|
||||||
|
YarnConfiguration.MEMORY_CONFIGURATION_STORE);
|
||||||
|
confProvider.init(conf);
|
||||||
|
|
||||||
|
SchedConfUpdateInfo updateInfo = new SchedConfUpdateInfo();
|
||||||
|
Map<String, String> updateMap = new HashMap<>();
|
||||||
|
updateMap.put("testkey1", "testval1");
|
||||||
|
updateMap.put("testkey2", "testval2");
|
||||||
|
QueueConfigInfo queueConfigInfo = new
|
||||||
|
QueueConfigInfo("root.a", updateMap);
|
||||||
|
updateInfo.getUpdateQueueInfo().add(queueConfigInfo);
|
||||||
|
|
||||||
|
confProvider.logAndApplyMutation(TEST_USER, updateInfo);
|
||||||
|
confProvider.confirmPendingMutation(true);
|
||||||
|
assertEquals("testval1", confProvider.loadConfiguration(conf)
|
||||||
|
.get("yarn.scheduler.capacity.root.a.testkey1"));
|
||||||
|
assertEquals("testval2", confProvider.loadConfiguration(conf)
|
||||||
|
.get("yarn.scheduler.capacity.root.a.testkey2"));
|
||||||
|
|
||||||
|
// Unset testkey1.
|
||||||
|
updateInfo = new SchedConfUpdateInfo();
|
||||||
|
updateMap.put("testkey1", "");
|
||||||
|
queueConfigInfo = new QueueConfigInfo("root.a", updateMap);
|
||||||
|
updateInfo.getUpdateQueueInfo().add(queueConfigInfo);
|
||||||
|
|
||||||
|
confProvider.logAndApplyMutation(TEST_USER, updateInfo);
|
||||||
|
confProvider.confirmPendingMutation(true);
|
||||||
|
assertNull("Failed to remove config",
|
||||||
|
confProvider.loadConfiguration(conf)
|
||||||
|
.get("yarn.scheduler.capacity.root.a.testkey1"));
|
||||||
|
assertEquals("testval2", confProvider.loadConfiguration(conf)
|
||||||
|
.get("yarn.scheduler.capacity.root.a.testkey2"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHDFSBackedProvider() throws Exception {
|
public void testHDFSBackedProvider() throws Exception {
|
||||||
File testSchedulerConfigurationDir = new File(
|
File testSchedulerConfigurationDir = new File(
|
||||||
|
Loading…
Reference in New Issue
Block a user