9uapaw commented on a change in pull request #3475:
URL: https://github.com/apache/hadoop/pull/3475#discussion_r721070781



##########
File path: 
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
##########
@@ -951,73 +951,79 @@ private CSQueue 
getOrCreateQueueFromPlacementContext(ApplicationId
       applicationId, String user, String queueName,
       ApplicationPlacementContext placementContext,
       boolean isRecovery) {
-
     CSQueue queue = getQueue(queueName);
     ApplicationPlacementContext fallbackContext = placementContext;
 
-    if (queue == null) {
-      // Even if placement rules are turned off, we still have the opportunity
-      // to auto create a queue.
-      if (placementContext == null) {
-        fallbackContext = CSQueueUtils.extractQueuePath(queueName);
-      }
+    if (queue != null) {
+      return queue;
+    }
 
-      //we need to make sure there is no empty path parts present
-      String path = fallbackContext.getFullQueuePath();
-      String[] pathParts = path.split("\\.");
-      for (int i = 0; i < pathParts.length; i++) {
-        if ("".equals(pathParts[i])) {
-          LOG.error("Application submitted to invalid path: '{}'", path);
-          return null;
-        }
+    // Even if placement rules are turned off, we still have the opportunity
+    // to auto create a queue.
+    if (placementContext == null) {
+      fallbackContext = CSQueueUtils.extractQueuePath(queueName);
+    }
+
+    //we need to make sure there are no empty path parts present
+    QueuePath path = new QueuePath(fallbackContext.getFullQueuePath());
+    if (path.hasEmptyPart()) {
+      LOG.error("Application submitted to invalid path: '{}'", path);
+      return null;
+    }
+
+    if (!fallbackContext.hasParentQueue()) {
+      return null;
+    }
+
+    try {
+      writeLock.lock();
+      return queueManager.createQueue(fallbackContext);

Review comment:
       Actually I have replaced all references of ApplicationContext  to 
QueuePath in QueueManager. I did not find any usage that would justify an 
overloaded method for this, but I presume it could be handy for PlacementRules 
maybe?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to