hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abm...@apache.org
Subject [hadoop] branch trunk updated: YARN-9791. Queue Mutation API does not allow to remove a config. Contributed by Prabhu Joseph.
Date Sun, 01 Sep 2019 17:11:08 GMT
This is an automated email from the ASF dual-hosted git repository.

abmodi pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 751b5a1  YARN-9791. Queue Mutation API does not allow to remove a config. Contributed
by Prabhu Joseph.
751b5a1 is described below

commit 751b5a1ac871734c46cb934d100a5367f1dbf791
Author: Abhishek Modi <abmodi@apache.org>
AuthorDate: Sun Sep 1 22:40:40 2019 +0530

    YARN-9791. Queue Mutation API does not allow to remove a config. Contributed by Prabhu
Joseph.
---
 .../conf/MutableCSConfigurationProvider.java       |  8 +++--
 .../conf/TestMutableCSConfigurationProvider.java   | 37 ++++++++++++++++++++++
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/MutableCSConfigurationProvider.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/MutableCSConfigurationProvider.java
index 6a13d2d..0677bd8 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/MutableCSConfigurationProvider.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/MutableCSConfigurationProvider.java
@@ -280,12 +280,14 @@ public class MutableCSConfigurationProvider implements CSConfigurationProvider,
       String keyPrefix = CapacitySchedulerConfiguration.PREFIX
           + queuePath + CapacitySchedulerConfiguration.DOT;
       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());
         } 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);
       }
     }
   }
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java
index 81bc7a7..64fc80c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java
@@ -107,6 +107,43 @@ public class TestMutableCSConfigurationProvider {
   }
 
   @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
   public void testHDFSBackedProvider() throws Exception {
     File testSchedulerConfigurationDir = new File(
         TestMutableCSConfigurationProvider.class.getResource("").getPath()


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message