[ 
https://issues.apache.org/jira/browse/YARN-5746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15617279#comment-15617279
 ] 

Tsuyoshi Ozawa commented on YARN-5746:
--------------------------------------

[~xgong] thanks for taking this issue.

{code}
  public QueueState getConfiguredState(String queue) {
    String state = get(getQueuePrefix(queue) + STATE);
    if (state == null) {
      return null;
    } else {
      return QueueState.valueOf(StringUtils.toUpperCase(state));
    }
{code}

It's a bit difficult to understand what the state of "null" mean.
I would like to suggest that we create new state, QueueState.NOT_FOUND, and 
return it instead of returning null. What do you think?

{quote}
Let's collapse these nested conditionals into an else if:
{quote}
+1

In addition to Daniel's comments, how about adding new private method to wrap 
up the following routine?
{code}
      if (parent != null) {
        QueueState configuredState = csContext.getConfiguration()
            .getConfiguredState(getQueuePath());
        QueueState parentState = parent.getState();
        if (configuredState == null) {
          this.state = parentState;
        } else {
          if (configuredState == QueueState.RUNNING
              && parentState == QueueState.STOPPED) {
            throw new IllegalArgumentException(
                "Illegal" + " State of " + configuredState
                + " for children of queue: " + queueName
                + ". The state of its parent queue: " + parent.getQueueName()
                + " is " + parentState);
          } else {
            this.state = configuredState;
          }
        }
    } else {
        // if this is the root queue, get the state from the configuration.
        // if the state is not set, use RUNNING as default state.
        this.state = csContext.getConfiguration().getState(getQueuePath());
      }
{code}


> The state of the parentQueue and its childQueues should be synchronized.
> ------------------------------------------------------------------------
>
>                 Key: YARN-5746
>                 URL: https://issues.apache.org/jira/browse/YARN-5746
>             Project: Hadoop YARN
>          Issue Type: Sub-task
>          Components: capacity scheduler, resourcemanager
>            Reporter: Xuan Gong
>            Assignee: Xuan Gong
>              Labels: oct16-easy
>         Attachments: YARN-5746.1.patch, YARN-5746.2.patch
>
>
> The state of the parentQueue and its childQeues need to be synchronized. 
> * If the state of the parentQueue becomes STOPPED, the state of its 
> childQueue need to become STOPPED as well. 
> * If we change the state of the queue to RUNNING, we should make sure the 
> state of all its ancestor must be RUNNING. Otherwise, we need to fail this 
> operation.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org

Reply via email to