This is an automated email from the ASF dual-hosted git repository.

sunilg 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 28f730b  YARN-10109. Allow stop and convert from leaf to parent queue 
in a single Mutation API call. Contributed by Prabhu Joseph
28f730b is described below

commit 28f730b317b23038bf9bd0775dd2cdb96518b13b
Author: Sunil G <[email protected]>
AuthorDate: Sun Feb 9 21:14:53 2020 +0530

    YARN-10109. Allow stop and convert from leaf to parent queue in a single 
Mutation API call. Contributed by Prabhu Joseph
---
 .../capacity/CapacitySchedulerConfigValidator.java | 21 ++++++++------
 .../TestRMWebServicesConfigurationMutation.java    | 33 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 9 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/CapacitySchedulerConfigValidator.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/CapacitySchedulerConfigValidator.java
index 525ea43..3957c5f 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/CapacitySchedulerConfigValidator.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/CapacitySchedulerConfigValidator.java
@@ -122,18 +122,20 @@ public final class CapacitySchedulerConfigValidator {
         String queueName = e.getKey();
         CSQueue oldQueue = e.getValue();
         CSQueue newQueue = newQueues.get(queueName);
-        if (null == newQueue) {
-          // old queue doesn't exist in the new XML
-          String configPrefix = newConf.getQueuePrefix(
-                  oldQueue.getQueuePath());
-          QueueState newQueueState = null;
+        String configPrefix = newConf.getQueuePrefix(
+            oldQueue.getQueuePath());
+        String state = newConf.get(configPrefix + "state");
+        QueueState newQueueState = null;
+        if (state != null) {
           try {
-            newQueueState = QueueState.valueOf(
-                    newConf.get(configPrefix + "state"));
+            newQueueState = QueueState.valueOf(state);
           } catch (Exception ex) {
             LOG.warn("Not a valid queue state for queue "
-                    + oldQueue.getQueuePath());
+                + oldQueue.getQueuePath());
           }
+        }
+        if (null == newQueue) {
+          // old queue doesn't exist in the new XML
           if (oldQueue.getState() == QueueState.STOPPED ||
                   newQueueState == QueueState.STOPPED) {
             LOG.info("Deleting Queue " + queueName + ", as it is not"
@@ -169,7 +171,8 @@ public final class CapacitySchedulerConfigValidator {
                           + " is set to true");
         } else if (oldQueue instanceof LeafQueue
                 && newQueue instanceof ParentQueue) {
-          if (oldQueue.getState() == QueueState.STOPPED) {
+          if (oldQueue.getState() == QueueState.STOPPED ||
+              newQueueState == QueueState.STOPPED) {
             LOG.info("Converting the leaf queue: " + oldQueue.getQueuePath()
                     + " to parent queue.");
           } else{
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesConfigurationMutation.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesConfigurationMutation.java
index b92fbfb..4bb50ea 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesConfigurationMutation.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesConfigurationMutation.java
@@ -491,6 +491,39 @@ public class TestRMWebServicesConfigurationMutation 
extends JerseyTestBase {
   }
 
   @Test
+  public void testStopWithConvertLeafToParentQueue() throws Exception {
+    WebResource r = resource();
+    ClientResponse response;
+
+    // Set state of queues to STOPPED.
+    SchedConfUpdateInfo updateInfo = new SchedConfUpdateInfo();
+    Map<String, String> stoppedParam = new HashMap<>();
+    stoppedParam.put(CapacitySchedulerConfiguration.STATE,
+        QueueState.STOPPED.toString());
+    QueueConfigInfo stoppedInfo = new QueueConfigInfo("root.b",
+        stoppedParam);
+    updateInfo.getUpdateQueueInfo().add(stoppedInfo);
+
+    Map<String, String> b1Capacity = new HashMap<>();
+    b1Capacity.put(CapacitySchedulerConfiguration.CAPACITY, "100");
+    QueueConfigInfo b1 = new QueueConfigInfo("root.b.b1", b1Capacity);
+    updateInfo.getAddQueueInfo().add(b1);
+
+    response = r.path("ws").path("v1").path("cluster")
+        .path("scheduler-conf").queryParam("user.name", userName)
+        .accept(MediaType.APPLICATION_JSON)
+        .entity(YarnWebServiceUtils.toJson(updateInfo,
+            SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
+        .put(ClientResponse.class);
+
+    assertEquals(Status.OK.getStatusCode(), response.getStatus());
+    CapacitySchedulerConfiguration newCSConf =
+        ((CapacityScheduler) rm.getResourceScheduler()).getConfiguration();
+    assertEquals(1, newCSConf.getQueues("root.b").length);
+    assertEquals("b1", newCSConf.getQueues("root.b")[0]);
+  }
+
+  @Test
   public void testRemoveParentQueue() throws Exception {
     WebResource r = resource();
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to