protected Set<String> getCapacitySchedulerLeafQueues(Map<String, String> capacitySchedulerMap) {
    Set<String> leafQueues= new HashSet<>();
    Stack<String> toProcessQueues = new Stack<>();
    if (capacitySchedulerMap.containsKey(YARN_SCHEDULER_CAPACITY_ROOT_QUEUES)){
      StringTokenizer queueTokenizer = new StringTokenizer(capacitySchedulerMap.get(
          YARN_SCHEDULER_CAPACITY_ROOT_QUEUES), ",");
      while (queueTokenizer.hasMoreTokens()){
        toProcessQueues.push(queueTokenizer.nextToken());
      }
    }
    while (!toProcessQueues.empty()){
      String queue = toProcessQueues.pop();
      String queueKey = YARN_SCHEDULER_CAPACITY_ROOT_QUEUE + "." + queue + "." + QUEUES;
      if (capacitySchedulerMap.containsKey(queueKey)){
        StringTokenizer queueTokenizer = new StringTokenizer(capacitySchedulerMap.get(queueKey), ",");
        while (queueTokenizer.hasMoreTokens()){
          toProcessQueues.push(queue + "." + queueTokenizer.nextToken());
        }
      } else {
        if (!queue.endsWith(".")){
          String queueName = queue.substring(queue.lastIndexOf('.')+1);
          leafQueues.add(queueName);
        } else {
          LOG.warn("Queue " + queue + " is not valid");
        }
      }
    }
    return leafQueues;
  }
Pars Capacity Scheduler Properties and get all YARN Capacity Scheduler leaf queue names
@param capacitySchedulerMap capacity-scheduler properties map
@return all YARN Capacity Scheduler leaf queue names
ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java