You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/01/06 12:50:40 UTC
[GitHub] [hadoop] 9uapaw opened a new pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
9uapaw opened a new pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867
<!--
Thanks for sending a pull request!
1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute
2. Make sure your PR title starts with JIRA issue id, e.g., 'HADOOP-17799. Your PR title ...'.
-->
### Description of PR
### How was this patch tested?
### For code changes:
- [ ] Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: have the integration tests been executed and the endpoint declared according to the connector-specific documentation?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, `NOTICE-binary` files?
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] hadoop-yetus commented on pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
hadoop-yetus commented on pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#issuecomment-1006703533
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Logfile | Comment |
|:----:|----------:|--------:|:--------:|:-------:|
| +0 :ok: | reexec | 0m 58s | | Docker mode activated. |
|||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 0s | | No case conflicting files found. |
| +0 :ok: | codespell | 0m 0s | | codespell was not available. |
| +1 :green_heart: | @author | 0m 0s | | The patch does not contain any @author tags. |
| -1 :x: | test4tests | 0m 0s | | The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. |
|||| _ trunk Compile Tests _ |
| +1 :green_heart: | mvninstall | 32m 19s | | trunk passed |
| +1 :green_heart: | compile | 1m 7s | | trunk passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04 |
| +1 :green_heart: | compile | 1m 0s | | trunk passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10 |
| +1 :green_heart: | checkstyle | 0m 49s | | trunk passed |
| +1 :green_heart: | mvnsite | 1m 2s | | trunk passed |
| +1 :green_heart: | javadoc | 0m 52s | | trunk passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04 |
| +1 :green_heart: | javadoc | 0m 47s | | trunk passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10 |
| +1 :green_heart: | spotbugs | 1m 56s | | trunk passed |
| +1 :green_heart: | shadedclient | 21m 11s | | branch has no errors when building and testing our client artifacts. |
|||| _ Patch Compile Tests _ |
| +1 :green_heart: | mvninstall | 0m 54s | | the patch passed |
| +1 :green_heart: | compile | 0m 57s | | the patch passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04 |
| +1 :green_heart: | javac | 0m 57s | | the patch passed |
| +1 :green_heart: | compile | 0m 50s | | the patch passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10 |
| +1 :green_heart: | javac | 0m 50s | | the patch passed |
| +1 :green_heart: | blanks | 0m 0s | | The patch has no blanks issues. |
| -0 :warning: | checkstyle | 0m 39s | [/results-checkstyle-hadoop-yarn-project_hadoop-yarn_hadoop-yarn-server_hadoop-yarn-server-resourcemanager.txt](https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/1/artifact/out/results-checkstyle-hadoop-yarn-project_hadoop-yarn_hadoop-yarn-server_hadoop-yarn-server-resourcemanager.txt) | hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager: The patch generated 1 new + 34 unchanged - 0 fixed = 35 total (was 34) |
| +1 :green_heart: | mvnsite | 0m 54s | | the patch passed |
| +1 :green_heart: | javadoc | 0m 40s | | the patch passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04 |
| +1 :green_heart: | javadoc | 0m 38s | | the patch passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10 |
| +1 :green_heart: | spotbugs | 1m 56s | | the patch passed |
| +1 :green_heart: | shadedclient | 20m 58s | | patch has no errors when building and testing our client artifacts. |
|||| _ Other Tests _ |
| +1 :green_heart: | unit | 96m 30s | | hadoop-yarn-server-resourcemanager in the patch passed. |
| +1 :green_heart: | asflicense | 0m 35s | | The patch does not generate ASF License warnings. |
| | | 186m 50s | | |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/1/artifact/out/Dockerfile |
| GITHUB PR | https://github.com/apache/hadoop/pull/3867 |
| Optional Tests | dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell |
| uname | Linux 1177dc40d4f0 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | maven |
| Personality | dev-support/bin/hadoop.sh |
| git revision | trunk / bee3aa29d9ecf11243cbfe3dbee1ff135bc74303 |
| Default Java | Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10 |
| Multi-JDK versions | /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10 |
| Test Results | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/1/testReport/ |
| Max. process+thread count | 951 (vs. ulimit of 5500) |
| modules | C: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager U: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager |
| Console output | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/1/console |
| versions | git=2.25.1 maven=3.6.3 spotbugs=4.2.2 |
| Powered by | Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org |
This message was automatically generated.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] szilard-nemeth commented on pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
szilard-nemeth commented on pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#issuecomment-1043372471
Hi @9uapaw ,
Thanks for working on this.
Patch LGTM, committed to trunk.
Thanks @tomicooler for the review.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] tomicooler commented on a change in pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
tomicooler commented on a change in pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#discussion_r782027904
##########
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/QueueStateHelper.java
##########
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
+
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.apache.hadoop.yarn.api.records.QueueState;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+import java.util.Set;
+
+/**
+ * Collects all logic that are handling queue state transitions.
+ */
+public final class QueueStateHelper {
+ private static final Set<QueueState> VALID_STATE_CONFIGURATIONS = ImmutableSet.of(
+ QueueState.RUNNING, QueueState.STOPPED);
+ private static final QueueState DEFAULT_STATE = QueueState.RUNNING;
+
+ private QueueStateHelper() {}
+
+ /**
+ * Sets the current state of the queue based on its previous state, its parent's state and its
+ * configured state.
+ * @param queue the queue whose state is set
+ */
+ public static void setQueueState(AbstractCSQueue queue) {
+ QueueState previousState = queue.getState();
+ QueueState configuredState = queue.getQueueContext().getConfiguration().getConfiguredState(
+ queue.getQueuePath());
+ QueueState parentState = (queue.getParent() == null) ? null : queue.getParent().getState();
+
+ // verify that we can not any value for State other than RUNNING/STOPPED
+ if (configuredState != null && !VALID_STATE_CONFIGURATIONS.contains(configuredState)) {
+ throw new IllegalArgumentException("Invalid queue state configuration."
+ + " We can only use RUNNING or STOPPED.");
+ }
+
+ if (previousState == null) {
+ initializeState(queue, configuredState, parentState);
+ } else {
+ reinitializeState(queue, previousState, configuredState);
+ }
+ }
+
+ private static void reinitializeState(
+ AbstractCSQueue queue, QueueState previousState, QueueState configuredState) {
+ // when we get a refreshQueue request from AdminService,
+ if (previousState == QueueState.RUNNING) {
+ if (configuredState == QueueState.STOPPED) {
+ queue.stopQueue();
+ }
+ } else {
+ if (configuredState == QueueState.RUNNING) {
+ try {
+ queue.activateQueue();
+ } catch (YarnException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
+ }
+ }
+ }
+
+ private static void initializeState(
+ AbstractCSQueue queue, QueueState configuredState, QueueState parentState) {
+ QueueState currentState = configuredState == null ? DEFAULT_STATE : configuredState;
+
+ if (configuredState == QueueState.RUNNING && parentState != QueueState.RUNNING) {
+ throw new IllegalArgumentException(
+ "The parent queue:" + queue.getParent().getQueuePath()
+ + " cannot be STOPPED as the child queue:" + queue.getQueuePath()
+ + " is in RUNNING state.");
+ }
+
+ if (parentState != null && configuredState == null) {
+ currentState = parentState == QueueState.DRAINING ? QueueState.STOPPED : parentState;
+ }
+
+ queue.updateQueueState(currentState);
Review comment:
Yes, I think it's correct now. Thanks for working this, the latest change looks good to me. Non-binding +1.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] tomicooler commented on a change in pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
tomicooler commented on a change in pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#discussion_r781283853
##########
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/QueueStateHelper.java
##########
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
+
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.apache.hadoop.yarn.api.records.QueueState;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+import java.util.Set;
+
+/**
+ * Collects all logic that are handling queue state transitions.
+ */
+public final class QueueStateHelper {
+ private static final Set<QueueState> VALID_STATE_CONFIGURATIONS = ImmutableSet.of(
+ QueueState.RUNNING, QueueState.STOPPED);
+ private static final QueueState DEFAULT_STATE = QueueState.RUNNING;
+
+ private QueueStateHelper() {}
+
+ /**
+ * Sets the current state of the queue based on its previous state, its parent's state and its
+ * configured state.
+ * @param queue the queue whose state is set
+ */
+ public static void setQueueState(AbstractCSQueue queue) {
+ QueueState previousState = queue.getState();
+ QueueState configuredState = queue.getQueueContext().getConfiguration().getConfiguredState(
+ queue.getQueuePath());
+ QueueState parentState = (queue.getParent() == null) ? null : queue.getParent().getState();
+
+ // verify that we can not any value for State other than RUNNING/STOPPED
+ if (configuredState != null && !VALID_STATE_CONFIGURATIONS.contains(configuredState)) {
+ throw new IllegalArgumentException("Invalid queue state configuration."
+ + " We can only use RUNNING or STOPPED.");
+ }
+
+ if (previousState == null) {
+ initializeState(queue, configuredState, parentState);
+ } else {
+ reinitializeState(queue, previousState, configuredState);
+ }
+ }
+
+ private static void reinitializeState(
+ AbstractCSQueue queue, QueueState previousState, QueueState configuredState) {
+ // when we get a refreshQueue request from AdminService,
+ if (previousState == QueueState.RUNNING) {
+ if (configuredState == QueueState.STOPPED) {
+ queue.stopQueue();
+ }
+ } else {
+ if (configuredState == QueueState.RUNNING) {
+ try {
+ queue.activateQueue();
+ } catch (YarnException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
+ }
+ }
+ }
+
+ private static void initializeState(
+ AbstractCSQueue queue, QueueState configuredState, QueueState parentState) {
+ QueueState currentState = configuredState == null ? DEFAULT_STATE : configuredState;
+
+ if (configuredState == QueueState.RUNNING && parentState != QueueState.RUNNING) {
+ throw new IllegalArgumentException(
+ "The parent queue:" + queue.getParent().getQueuePath()
+ + " cannot be STOPPED as the child queue:" + queue.getQueuePath()
+ + " is in RUNNING state.");
+ }
+
+ if (parentState != null && configuredState == null) {
+ currentState = parentState == QueueState.DRAINING ? QueueState.STOPPED : parentState;
+ }
+
+ queue.updateQueueState(currentState);
Review comment:
Never mind, an exception will be thrown in that case.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] tomicooler commented on a change in pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
tomicooler commented on a change in pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#discussion_r781227524
##########
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/CSQueueUtils.java
##########
@@ -302,15 +307,4 @@ public static void updateAbsoluteCapacitiesByNodeLabels(QueueCapacities queueCap
}
}
}
-
- public static ApplicationPlacementContext extractQueuePath(String queuePath) {
Review comment:
This seems to be unrelated for this change.
##########
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/QueueStateHelper.java
##########
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
+
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.apache.hadoop.yarn.api.records.QueueState;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+import java.util.Set;
+
+/**
+ * Collects all logic that are handling queue state transitions.
+ */
+public final class QueueStateHelper {
+ private static final Set<QueueState> VALID_STATE_CONFIGURATIONS = ImmutableSet.of(
+ QueueState.RUNNING, QueueState.STOPPED);
+ private static final QueueState DEFAULT_STATE = QueueState.RUNNING;
+
+ private QueueStateHelper() {}
+
+ /**
+ * Sets the current state of the queue based on its previous state, its parent's state and its
+ * configured state.
+ * @param queue the queue whose state is set
+ */
+ public static void setQueueState(AbstractCSQueue queue) {
+ QueueState previousState = queue.getState();
+ QueueState configuredState = queue.getQueueContext().getConfiguration().getConfiguredState(
+ queue.getQueuePath());
+ QueueState parentState = (queue.getParent() == null) ? null : queue.getParent().getState();
+
+ // verify that we can not any value for State other than RUNNING/STOPPED
+ if (configuredState != null && !VALID_STATE_CONFIGURATIONS.contains(configuredState)) {
+ throw new IllegalArgumentException("Invalid queue state configuration."
+ + " We can only use RUNNING or STOPPED.");
+ }
+
+ if (previousState == null) {
+ initializeState(queue, configuredState, parentState);
+ } else {
+ reinitializeState(queue, previousState, configuredState);
+ }
+ }
+
+ private static void reinitializeState(
+ AbstractCSQueue queue, QueueState previousState, QueueState configuredState) {
+ // when we get a refreshQueue request from AdminService,
+ if (previousState == QueueState.RUNNING) {
+ if (configuredState == QueueState.STOPPED) {
+ queue.stopQueue();
+ }
+ } else {
+ if (configuredState == QueueState.RUNNING) {
+ try {
+ queue.activateQueue();
+ } catch (YarnException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
+ }
+ }
+ }
+
+ private static void initializeState(
+ AbstractCSQueue queue, QueueState configuredState, QueueState parentState) {
+ QueueState currentState = configuredState == null ? DEFAULT_STATE : configuredState;
+
+ if (configuredState == QueueState.RUNNING && parentState != QueueState.RUNNING) {
+ throw new IllegalArgumentException(
+ "The parent queue:" + queue.getParent().getQueuePath()
+ + " cannot be STOPPED as the child queue:" + queue.getQueuePath()
+ + " is in RUNNING state.");
+ }
+
+ if (parentState != null && configuredState == null) {
+ currentState = parentState == QueueState.DRAINING ? QueueState.STOPPED : parentState;
+ }
+
+ queue.updateQueueState(currentState);
Review comment:
The behaviour changed a little bit, before:
Breaking the if-else statements to single ifs using the original code:
```
if (parentState == null) {
updateQueueState((configuredState == null) ? defaultState : configuredState);
}
if (parentState != null &&
configuredState == null) {
updateQueueState((parentState == QueueState.DRAINING) ? QueueState.STOPPED : parentState);
}
if (parentState != null &&
configuredState != null &&
(configuredState == QueueState.RUNNING
&& parentState != QueueState.RUNNING)) {
throw new IllegalArgumentException(...
}
if (parentState != null &&
configuredState != null &&
!(configuredState == QueueState.RUNNING
&& parentState != QueueState.RUNNING)) {
updateQueueState(configuredState);
}
```
When queue updates were done?
```
if ((parentState == null) ||
(parentState != null && configuredState == null)
(parentState != null && configuredState != null) && !(configuredState == QueueState.RUNNING && parentState != QueueState.RUNNING)) {
// changes were made
}
```
Simplified using this formula: "a || (!a && b) || ((!a && !b) && !(c && d))" at https://www.dcode.fr/boolean-expressions-calculator
```
if (parentState == null ||
configuredState == null ||
configuredState != QueueState.RUNNING ||
parentState == QueueState.RUNNING) {
// changes were made
}
```
According to this, the *updateQueueState* was not called for (configuredState = QueueState.RUNNING and parentState = QueueState.STOPPED) or (configuredState = QueueState.RUNNING and QueueState.DRAINING). If the parent is stopped then the child should not be running. Probably the same applies when the parent is in draining state.
##########
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/CSQueueUtils.java
##########
@@ -32,6 +34,9 @@
public class CSQueueUtils {
public final static float EPSILON = 0.0001f;
+ private static final Set<QueueState> VALID_STATE_CONFIGURATIONS = ImmutableSet.of(
Review comment:
These are unused.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] 9uapaw commented on a change in pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
9uapaw commented on a change in pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#discussion_r781894505
##########
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/QueueStateHelper.java
##########
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
+
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.apache.hadoop.yarn.api.records.QueueState;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+import java.util.Set;
+
+/**
+ * Collects all logic that are handling queue state transitions.
+ */
+public final class QueueStateHelper {
+ private static final Set<QueueState> VALID_STATE_CONFIGURATIONS = ImmutableSet.of(
+ QueueState.RUNNING, QueueState.STOPPED);
+ private static final QueueState DEFAULT_STATE = QueueState.RUNNING;
+
+ private QueueStateHelper() {}
+
+ /**
+ * Sets the current state of the queue based on its previous state, its parent's state and its
+ * configured state.
+ * @param queue the queue whose state is set
+ */
+ public static void setQueueState(AbstractCSQueue queue) {
+ QueueState previousState = queue.getState();
+ QueueState configuredState = queue.getQueueContext().getConfiguration().getConfiguredState(
+ queue.getQueuePath());
+ QueueState parentState = (queue.getParent() == null) ? null : queue.getParent().getState();
+
+ // verify that we can not any value for State other than RUNNING/STOPPED
+ if (configuredState != null && !VALID_STATE_CONFIGURATIONS.contains(configuredState)) {
+ throw new IllegalArgumentException("Invalid queue state configuration."
+ + " We can only use RUNNING or STOPPED.");
+ }
+
+ if (previousState == null) {
+ initializeState(queue, configuredState, parentState);
+ } else {
+ reinitializeState(queue, previousState, configuredState);
+ }
+ }
+
+ private static void reinitializeState(
+ AbstractCSQueue queue, QueueState previousState, QueueState configuredState) {
+ // when we get a refreshQueue request from AdminService,
+ if (previousState == QueueState.RUNNING) {
+ if (configuredState == QueueState.STOPPED) {
+ queue.stopQueue();
+ }
+ } else {
+ if (configuredState == QueueState.RUNNING) {
+ try {
+ queue.activateQueue();
+ } catch (YarnException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
+ }
+ }
+ }
+
+ private static void initializeState(
+ AbstractCSQueue queue, QueueState configuredState, QueueState parentState) {
+ QueueState currentState = configuredState == null ? DEFAULT_STATE : configuredState;
+
+ if (configuredState == QueueState.RUNNING && parentState != QueueState.RUNNING) {
+ throw new IllegalArgumentException(
+ "The parent queue:" + queue.getParent().getQueuePath()
+ + " cannot be STOPPED as the child queue:" + queue.getQueuePath()
+ + " is in RUNNING state.");
+ }
+
+ if (parentState != null && configuredState == null) {
+ currentState = parentState == QueueState.DRAINING ? QueueState.STOPPED : parentState;
+ }
+
+ queue.updateQueueState(currentState);
Review comment:
Correct, is
```
if (configuredState == QueueState.RUNNING && parentState != null &&
parentState != QueueState.RUNNING) {
throw new IllegalArgumentException(
"The parent queue:" + queue.getParent().getQueuePath()
+ " cannot be STOPPED as the child queue:" + queue.getQueuePath()
+ " is in RUNNING state.");
}
```
sufficient here? Thanks for the resource, it will be useful for future refactors like this.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] hadoop-yetus commented on pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
hadoop-yetus commented on pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#issuecomment-1009894369
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Logfile | Comment |
|:----:|----------:|--------:|:--------:|:-------:|
| +0 :ok: | reexec | 0m 44s | | Docker mode activated. |
|||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 0s | | No case conflicting files found. |
| +0 :ok: | codespell | 0m 1s | | codespell was not available. |
| +1 :green_heart: | @author | 0m 0s | | The patch does not contain any @author tags. |
| -1 :x: | test4tests | 0m 0s | | The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. |
|||| _ trunk Compile Tests _ |
| +1 :green_heart: | mvninstall | 32m 39s | | trunk passed |
| +1 :green_heart: | compile | 1m 7s | | trunk passed with JDK Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 |
| +1 :green_heart: | compile | 0m 58s | | trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| +1 :green_heart: | checkstyle | 0m 48s | | trunk passed |
| +1 :green_heart: | mvnsite | 1m 5s | | trunk passed |
| +1 :green_heart: | javadoc | 0m 54s | | trunk passed with JDK Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 |
| +1 :green_heart: | javadoc | 0m 45s | | trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| +1 :green_heart: | spotbugs | 1m 56s | | trunk passed |
| +1 :green_heart: | shadedclient | 21m 20s | | branch has no errors when building and testing our client artifacts. |
|||| _ Patch Compile Tests _ |
| +1 :green_heart: | mvninstall | 0m 53s | | the patch passed |
| +1 :green_heart: | compile | 0m 57s | | the patch passed with JDK Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 |
| +1 :green_heart: | javac | 0m 57s | | the patch passed |
| +1 :green_heart: | compile | 0m 49s | | the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| +1 :green_heart: | javac | 0m 49s | | the patch passed |
| +1 :green_heart: | blanks | 0m 0s | | The patch has no blanks issues. |
| -0 :warning: | checkstyle | 0m 39s | [/results-checkstyle-hadoop-yarn-project_hadoop-yarn_hadoop-yarn-server_hadoop-yarn-server-resourcemanager.txt](https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/3/artifact/out/results-checkstyle-hadoop-yarn-project_hadoop-yarn_hadoop-yarn-server_hadoop-yarn-server-resourcemanager.txt) | hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager: The patch generated 2 new + 34 unchanged - 0 fixed = 36 total (was 34) |
| +1 :green_heart: | mvnsite | 0m 53s | | the patch passed |
| +1 :green_heart: | javadoc | 0m 41s | | the patch passed with JDK Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 |
| +1 :green_heart: | javadoc | 0m 36s | | the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| +1 :green_heart: | spotbugs | 1m 54s | | the patch passed |
| +1 :green_heart: | shadedclient | 20m 43s | | patch has no errors when building and testing our client artifacts. |
|||| _ Other Tests _ |
| +1 :green_heart: | unit | 96m 56s | | hadoop-yarn-server-resourcemanager in the patch passed. |
| +1 :green_heart: | asflicense | 0m 34s | | The patch does not generate ASF License warnings. |
| | | 187m 12s | | |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/3/artifact/out/Dockerfile |
| GITHUB PR | https://github.com/apache/hadoop/pull/3867 |
| Optional Tests | dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell |
| uname | Linux ff36404a4592 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | maven |
| Personality | dev-support/bin/hadoop.sh |
| git revision | trunk / 12f1ab963d445a5854b9665fa8462ec55ba8390c |
| Default Java | Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| Multi-JDK versions | /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| Test Results | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/3/testReport/ |
| Max. process+thread count | 948 (vs. ulimit of 5500) |
| modules | C: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager U: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager |
| Console output | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/3/console |
| versions | git=2.25.1 maven=3.6.3 spotbugs=4.2.2 |
| Powered by | Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org |
This message was automatically generated.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] hadoop-yetus commented on pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
hadoop-yetus commented on pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#issuecomment-1009049714
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Logfile | Comment |
|:----:|----------:|--------:|:--------:|:-------:|
| +0 :ok: | reexec | 0m 53s | | Docker mode activated. |
|||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 0s | | No case conflicting files found. |
| +0 :ok: | codespell | 0m 0s | | codespell was not available. |
| +1 :green_heart: | @author | 0m 0s | | The patch does not contain any @author tags. |
| -1 :x: | test4tests | 0m 0s | | The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. |
|||| _ trunk Compile Tests _ |
| +1 :green_heart: | mvninstall | 32m 31s | | trunk passed |
| +1 :green_heart: | compile | 1m 6s | | trunk passed with JDK Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 |
| +1 :green_heart: | compile | 0m 59s | | trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| +1 :green_heart: | checkstyle | 0m 48s | | trunk passed |
| +1 :green_heart: | mvnsite | 1m 3s | | trunk passed |
| +1 :green_heart: | javadoc | 0m 53s | | trunk passed with JDK Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 |
| +1 :green_heart: | javadoc | 0m 46s | | trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| +1 :green_heart: | spotbugs | 1m 59s | | trunk passed |
| +1 :green_heart: | shadedclient | 21m 22s | | branch has no errors when building and testing our client artifacts. |
|||| _ Patch Compile Tests _ |
| +1 :green_heart: | mvninstall | 0m 53s | | the patch passed |
| +1 :green_heart: | compile | 0m 57s | | the patch passed with JDK Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 |
| +1 :green_heart: | javac | 0m 57s | | the patch passed |
| +1 :green_heart: | compile | 0m 48s | | the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| +1 :green_heart: | javac | 0m 48s | | the patch passed |
| +1 :green_heart: | blanks | 0m 0s | | The patch has no blanks issues. |
| +1 :green_heart: | checkstyle | 0m 38s | | the patch passed |
| +1 :green_heart: | mvnsite | 0m 53s | | the patch passed |
| +1 :green_heart: | javadoc | 0m 40s | | the patch passed with JDK Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 |
| +1 :green_heart: | javadoc | 0m 38s | | the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| +1 :green_heart: | spotbugs | 1m 55s | | the patch passed |
| +1 :green_heart: | shadedclient | 20m 56s | | patch has no errors when building and testing our client artifacts. |
|||| _ Other Tests _ |
| +1 :green_heart: | unit | 96m 50s | | hadoop-yarn-server-resourcemanager in the patch passed. |
| +1 :green_heart: | asflicense | 0m 34s | | The patch does not generate ASF License warnings. |
| | | 187m 22s | | |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/2/artifact/out/Dockerfile |
| GITHUB PR | https://github.com/apache/hadoop/pull/3867 |
| Optional Tests | dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell |
| uname | Linux 85f4a8f40a3c 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | maven |
| Personality | dev-support/bin/hadoop.sh |
| git revision | trunk / a0b500166ec23be2879f90c79a4f658525c5644a |
| Default Java | Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| Multi-JDK versions | /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.13+8-Ubuntu-0ubuntu1.20.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
| Test Results | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/2/testReport/ |
| Max. process+thread count | 949 (vs. ulimit of 5500) |
| modules | C: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager U: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager |
| Console output | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3867/2/console |
| versions | git=2.25.1 maven=3.6.3 spotbugs=4.2.2 |
| Powered by | Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org |
This message was automatically generated.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] szilard-nemeth closed pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
szilard-nemeth closed pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] tomicooler commented on a change in pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
tomicooler commented on a change in pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#discussion_r781288313
##########
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/QueueStateHelper.java
##########
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
+
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.apache.hadoop.yarn.api.records.QueueState;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+import java.util.Set;
+
+/**
+ * Collects all logic that are handling queue state transitions.
+ */
+public final class QueueStateHelper {
+ private static final Set<QueueState> VALID_STATE_CONFIGURATIONS = ImmutableSet.of(
+ QueueState.RUNNING, QueueState.STOPPED);
+ private static final QueueState DEFAULT_STATE = QueueState.RUNNING;
+
+ private QueueStateHelper() {}
+
+ /**
+ * Sets the current state of the queue based on its previous state, its parent's state and its
+ * configured state.
+ * @param queue the queue whose state is set
+ */
+ public static void setQueueState(AbstractCSQueue queue) {
+ QueueState previousState = queue.getState();
+ QueueState configuredState = queue.getQueueContext().getConfiguration().getConfiguredState(
+ queue.getQueuePath());
+ QueueState parentState = (queue.getParent() == null) ? null : queue.getParent().getState();
+
+ // verify that we can not any value for State other than RUNNING/STOPPED
+ if (configuredState != null && !VALID_STATE_CONFIGURATIONS.contains(configuredState)) {
+ throw new IllegalArgumentException("Invalid queue state configuration."
+ + " We can only use RUNNING or STOPPED.");
+ }
+
+ if (previousState == null) {
+ initializeState(queue, configuredState, parentState);
+ } else {
+ reinitializeState(queue, previousState, configuredState);
+ }
+ }
+
+ private static void reinitializeState(
+ AbstractCSQueue queue, QueueState previousState, QueueState configuredState) {
+ // when we get a refreshQueue request from AdminService,
+ if (previousState == QueueState.RUNNING) {
+ if (configuredState == QueueState.STOPPED) {
+ queue.stopQueue();
+ }
+ } else {
+ if (configuredState == QueueState.RUNNING) {
+ try {
+ queue.activateQueue();
+ } catch (YarnException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
+ }
+ }
+ }
+
+ private static void initializeState(
+ AbstractCSQueue queue, QueueState configuredState, QueueState parentState) {
+ QueueState currentState = configuredState == null ? DEFAULT_STATE : configuredState;
+
+ if (configuredState == QueueState.RUNNING && parentState != QueueState.RUNNING) {
Review comment:
Previously the parentState != null was also a requirement here.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] 9uapaw commented on a change in pull request #3867: YARN-10947. Simplify AbstractCSQueue#initializeQueueState
Posted by GitBox <gi...@apache.org>.
9uapaw commented on a change in pull request #3867:
URL: https://github.com/apache/hadoop/pull/3867#discussion_r781902080
##########
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/QueueStateHelper.java
##########
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
+
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.apache.hadoop.yarn.api.records.QueueState;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+import java.util.Set;
+
+/**
+ * Collects all logic that are handling queue state transitions.
+ */
+public final class QueueStateHelper {
+ private static final Set<QueueState> VALID_STATE_CONFIGURATIONS = ImmutableSet.of(
+ QueueState.RUNNING, QueueState.STOPPED);
+ private static final QueueState DEFAULT_STATE = QueueState.RUNNING;
+
+ private QueueStateHelper() {}
+
+ /**
+ * Sets the current state of the queue based on its previous state, its parent's state and its
+ * configured state.
+ * @param queue the queue whose state is set
+ */
+ public static void setQueueState(AbstractCSQueue queue) {
+ QueueState previousState = queue.getState();
+ QueueState configuredState = queue.getQueueContext().getConfiguration().getConfiguredState(
+ queue.getQueuePath());
+ QueueState parentState = (queue.getParent() == null) ? null : queue.getParent().getState();
+
+ // verify that we can not any value for State other than RUNNING/STOPPED
+ if (configuredState != null && !VALID_STATE_CONFIGURATIONS.contains(configuredState)) {
+ throw new IllegalArgumentException("Invalid queue state configuration."
+ + " We can only use RUNNING or STOPPED.");
+ }
+
+ if (previousState == null) {
+ initializeState(queue, configuredState, parentState);
+ } else {
+ reinitializeState(queue, previousState, configuredState);
+ }
+ }
+
+ private static void reinitializeState(
+ AbstractCSQueue queue, QueueState previousState, QueueState configuredState) {
+ // when we get a refreshQueue request from AdminService,
+ if (previousState == QueueState.RUNNING) {
+ if (configuredState == QueueState.STOPPED) {
+ queue.stopQueue();
+ }
+ } else {
+ if (configuredState == QueueState.RUNNING) {
+ try {
+ queue.activateQueue();
+ } catch (YarnException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
+ }
+ }
+ }
+
+ private static void initializeState(
+ AbstractCSQueue queue, QueueState configuredState, QueueState parentState) {
+ QueueState currentState = configuredState == null ? DEFAULT_STATE : configuredState;
+
+ if (configuredState == QueueState.RUNNING && parentState != QueueState.RUNNING) {
Review comment:
You are right, fixed.
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org