You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@streampark.apache.org by "RocMarshal (via GitHub)" <gi...@apache.org> on 2023/02/10 14:11:41 UTC

[GitHub] [incubator-streampark] RocMarshal opened a new pull request, #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

RocMarshal opened a new pull request, #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317

   <!--
   Thank you for contributing to StreamPark! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   ## Contribution Checklist
   
     - If this is your first time, please read our contributor guidelines: [Submit Code](https://streampark.apache.org/community/submit_guide/submit_code).
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-streampark/issues).
   
     - Name the pull request in the form "[Feature] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
   
     - If the PR is unfinished, add `[WIP]` in your PR title, e.g., `[WIP][Feature] Title of the pull request`.
   
   -->
   
   ## What changes were proposed in this pull request
   
   Issue Number: close #2299 <!-- REMOVE this line if no issue to close -->
   
   <!--(For example: This pull request proposed to add checkstyle plugin).-->
   
   ## Brief change log
   
   <!--*(for example:)*
   - *Add maven-checkstyle-plugin to root pom.xml*
   -->
   Support the yarn queue label quick-setting for yarn application mode.
   
   ## Verifying this change
   
   - Add some unit test cases.
   - *Manually verified the change by testing locally.* 
   
   ## Does this pull request potentially affect one of the following parts
    - Dependencies (does it add or upgrade a dependency): (yes / **no**)
   


-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1106626228


##########
streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts:
##########
@@ -466,8 +467,8 @@ export const useCreateAndEditSchema = (
         field: 'yarnQueue',
         label: t('flink.app.yarnQueue'),
         component: 'Input',
-        componentProps: { placeholder: t('flink.app.addAppTips.yarnQueuePlaceholder') },
         ifShow: ({ values }) => values.executionMode == ExecModeEnum.YARN_APPLICATION,

Review Comment:
   both `ExecModeEnum.YARN_APPLICATION ` and `ExecModeEnum.YARN_PER_JOB` need to be show
   



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] RocMarshal commented on pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#issuecomment-1427844193

   Hi, @wolfboys I added the note hints to the corresponding input, PTAL.
   Thx~!


-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1107906832


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1620,11 +1636,16 @@ private Map<String, Object> getProperties(Application application) {
       properties.put(RestOptions.ADDRESS.key(), activeAddress.getHost());
       properties.put(RestOptions.PORT.key(), activeAddress.getPort());
     } else if (ExecutionMode.isYarnMode(application.getExecutionModeEnum())) {
+

Review Comment:
   how about?
   ```
   if (ExecutionMode.YARN_SESSION.equals(application.getExecutionModeEnum())) {
           FlinkCluster cluster = flinkClusterService.getById(application.getFlinkClusterId());
           AssertUtils.state(
               cluster != null,
               String.format(
                   "The yarn session clusterId=%s cannot be find, maybe the clusterId is wrong or "
                       + "the cluster has been deleted. Please contact the Admin.",
                   application.getFlinkClusterId()));
           properties.put(ConfigConst.KEY_YARN_APP_ID(), cluster.getClusterId());
         } else {
             String yarnQueue =
                 (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE());
             String yarnLabelExpr =
                 (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_NODE_LABEL());
             if (yarnQueue != null) {
                 properties.put(ConfigConst.KEY_YARN_APP_QUEUE(), yarnQueue);
             }
             if (yarnLabelExpr != null) {
                 properties.put(ConfigConst.KEY_YARN_APP_NODE_LABEL(), yarnLabelExpr);
             }
         }
   
   ```



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] RocMarshal commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1106656182


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/utils/YarnQueueLabelExpression.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.streampark.console.core.utils;
+
+import org.apache.streampark.common.conf.ConfigConst;
+import org.apache.streampark.common.enums.ExecutionMode;
+
+import org.apache.commons.lang3.StringUtils;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+/** Util class for parsing and checking Yarn queue & Label */
+public class YarnQueueLabelExpression {
+
+  public static final String AT = "@";
+
+  public static final String REGEX = "[a-zA-Z0-9_\\-]+";
+
+  public static final String ERR_HINTS = "Yarn queue label format is invalid.";
+
+  public static final Pattern QUEUE_LABEL_PATTERN =
+      Pattern.compile(String.format("^(%s)(.%s)*(%s(%s)(,%s)*)?$", REGEX, REGEX, AT, REGEX, REGEX));
+
+  public static final String QUEUE_LABEL_FORMAT = "%s" + AT + "%s";
+
+  private final String queue;
+  private @Nullable final String labelExpression;
+
+  private YarnQueueLabelExpression(String queue, String labelExpression) {
+    this.labelExpression = StringUtils.isEmpty(labelExpression) ? null : labelExpression;
+    this.queue = queue;
+  }
+
+  public Optional<String> getLabelExpression() {
+    return Optional.ofNullable(labelExpression);
+  }
+
+  public @Nonnull String getQueue() {
+    return queue;
+  }
+
+  @Override
+  public String toString() {
+    return StringUtils.isEmpty(labelExpression)
+        ? queue
+        : String.format(QUEUE_LABEL_FORMAT, queue, labelExpression);
+  }
+
+  private static boolean isValid(String queueLabel, boolean ignoreEmpty) {
+    if (StringUtils.isEmpty(queueLabel)) {
+      return ignoreEmpty;
+    }
+    return QUEUE_LABEL_PATTERN.matcher(queueLabel).matches();
+  }
+
+  // Visible for test.
+  public static boolean isValid(String queueLabel) {
+    return isValid(queueLabel, false);
+  }
+
+  /**
+   * Only check the validation of queue-labelExpression when using yarn application or yarn-session
+   * mode.
+   *
+   * @param executionMode execution mode.
+   * @param queueLabel queueLabel expression.
+   */
+  public static void checkQueueLabelIfNeed(int executionMode, String queueLabel) {
+    if ((ExecutionMode.YARN_SESSION == ExecutionMode.of(executionMode)
+            || ExecutionMode.YARN_APPLICATION == ExecutionMode.of(executionMode))
+        && !YarnQueueLabelExpression.isValid(queueLabel, true)) {
+      throw new IllegalArgumentException(ERR_HINTS);
+    }
+  }
+
+  // Visible for test.
+  public static YarnQueueLabelExpression of(@Nonnull String queueLabelExpr) {
+    if (isValid(queueLabelExpr, false)) {
+      String[] strs = queueLabelExpr.split(AT);
+      if (strs.length == 2) {
+        return new YarnQueueLabelExpression(strs[0], strs[1]);
+      }
+      return new YarnQueueLabelExpression(strs[0], null);
+    }
+    throw new IllegalArgumentException(ERR_HINTS);
+  }
+
+  public static YarnQueueLabelExpression of(
+      @Nonnull String queue, @Nullable String labelExpression) {
+    YarnQueueLabelExpression queueLabelExpression =
+        new YarnQueueLabelExpression(queue, labelExpression);
+    if (isValid(queueLabelExpression.toString(), false)) {
+      return queueLabelExpression;
+    }
+    throw new IllegalArgumentException(ERR_HINTS);
+  }
+
+  /**
+   * Add the queue and label expression into the map as the specified configuration items. For
+   * {@link ConfigConst#KEY_YARN_APP_QUEUE} & {@link ConfigConst#KEY_YARN_APP_NODE_LABEL()}.
+   *
+   * @param queueLabelExp queue and label expression
+   * @param map the target properties.
+   */
+  public static <V> void addQueueLabelExprInto(String queueLabelExp, @Nonnull Map<String, V> map) {

Review Comment:
   If the label or queue exists, the corresponding value would be put.



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys merged pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys merged PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317


-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#issuecomment-1426806601

   good job, Thanks for your contribution, I will review it later


-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1106592000


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/utils/YarnQueueLabelExpression.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.streampark.console.core.utils;
+
+import org.apache.streampark.common.conf.ConfigConst;
+import org.apache.streampark.common.enums.ExecutionMode;
+
+import org.apache.commons.lang3.StringUtils;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+/** Util class for parsing and checking Yarn queue & Label */
+public class YarnQueueLabelExpression {
+
+  public static final String AT = "@";

Review Comment:
   private is better.



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/utils/YarnQueueLabelExpression.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.streampark.console.core.utils;
+
+import org.apache.streampark.common.conf.ConfigConst;
+import org.apache.streampark.common.enums.ExecutionMode;
+
+import org.apache.commons.lang3.StringUtils;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+/** Util class for parsing and checking Yarn queue & Label */
+public class YarnQueueLabelExpression {
+
+  public static final String AT = "@";
+
+  public static final String REGEX = "[a-zA-Z0-9_\\-]+";
+
+  public static final String ERR_HINTS = "Yarn queue label format is invalid.";
+
+  public static final Pattern QUEUE_LABEL_PATTERN =
+      Pattern.compile(String.format("^(%s)(.%s)*(%s(%s)(,%s)*)?$", REGEX, REGEX, AT, REGEX, REGEX));
+
+  public static final String QUEUE_LABEL_FORMAT = "%s" + AT + "%s";
+
+  private final String queue;
+  private @Nullable final String labelExpression;
+
+  private YarnQueueLabelExpression(String queue, String labelExpression) {
+    this.labelExpression = StringUtils.isEmpty(labelExpression) ? null : labelExpression;
+    this.queue = queue;
+  }
+
+  public Optional<String> getLabelExpression() {
+    return Optional.ofNullable(labelExpression);
+  }
+
+  public @Nonnull String getQueue() {
+    return queue;
+  }
+
+  @Override
+  public String toString() {
+    return StringUtils.isEmpty(labelExpression)
+        ? queue
+        : String.format(QUEUE_LABEL_FORMAT, queue, labelExpression);
+  }
+
+  private static boolean isValid(String queueLabel, boolean ignoreEmpty) {
+    if (StringUtils.isEmpty(queueLabel)) {
+      return ignoreEmpty;
+    }
+    return QUEUE_LABEL_PATTERN.matcher(queueLabel).matches();
+  }
+
+  // Visible for test.
+  public static boolean isValid(String queueLabel) {
+    return isValid(queueLabel, false);
+  }
+
+  /**
+   * Only check the validation of queue-labelExpression when using yarn application or yarn-session
+   * mode.
+   *
+   * @param executionMode execution mode.
+   * @param queueLabel queueLabel expression.
+   */
+  public static void checkQueueLabelIfNeed(int executionMode, String queueLabel) {
+    if ((ExecutionMode.YARN_SESSION == ExecutionMode.of(executionMode)
+            || ExecutionMode.YARN_APPLICATION == ExecutionMode.of(executionMode))
+        && !YarnQueueLabelExpression.isValid(queueLabel, true)) {
+      throw new IllegalArgumentException(ERR_HINTS);
+    }
+  }
+
+  // Visible for test.
+  public static YarnQueueLabelExpression of(@Nonnull String queueLabelExpr) {
+    if (isValid(queueLabelExpr, false)) {
+      String[] strs = queueLabelExpr.split(AT);
+      if (strs.length == 2) {
+        return new YarnQueueLabelExpression(strs[0], strs[1]);
+      }
+      return new YarnQueueLabelExpression(strs[0], null);
+    }
+    throw new IllegalArgumentException(ERR_HINTS);
+  }
+
+  public static YarnQueueLabelExpression of(
+      @Nonnull String queue, @Nullable String labelExpression) {
+    YarnQueueLabelExpression queueLabelExpression =
+        new YarnQueueLabelExpression(queue, labelExpression);
+    if (isValid(queueLabelExpression.toString(), false)) {
+      return queueLabelExpression;
+    }
+    throw new IllegalArgumentException(ERR_HINTS);
+  }
+
+  /**
+   * Add the queue and label expression into the map as the specified configuration items. For
+   * {@link ConfigConst#KEY_YARN_APP_QUEUE} & {@link ConfigConst#KEY_YARN_APP_NODE_LABEL()}.
+   *
+   * @param queueLabelExp queue and label expression
+   * @param map the target properties.
+   */
+  public static <V> void addQueueLabelExprInto(String queueLabelExp, @Nonnull Map<String, V> map) {

Review Comment:
   Pass in a Map for filling. Not a good way, how about ? 
   
   ```
   public static Map<String, String> getQueueLabelMap(String queueLabelExp) {
       if (StringUtils.isEmpty(queueLabelExp)) {
         return Collections.emptyMap();
       }
       YarnQueueLabelExpression yarnQueueLabelExpression = of(queueLabelExp);
       Map<String, String> map = new HashMap<>(2);
       yarnQueueLabelExpression
           .getLabelExpression()
           .ifPresent(labelExp -> map.put(ConfigConst.KEY_YARN_APP_NODE_LABEL(), labelExp));
       map.put(ConfigConst.KEY_YARN_APP_QUEUE(), yarnQueueLabelExpression.queue);
       return map;
     }
   
   ```
   
   Also I don't know if both "KEY_YARN_APP_NODE_LABEL" and "KEY_YARN_APP_QUEUE" need to put



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/utils/YarnQueueLabelExpression.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.streampark.console.core.utils;
+
+import org.apache.streampark.common.conf.ConfigConst;
+import org.apache.streampark.common.enums.ExecutionMode;
+
+import org.apache.commons.lang3.StringUtils;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+/** Util class for parsing and checking Yarn queue & Label */
+public class YarnQueueLabelExpression {
+
+  public static final String AT = "@";
+
+  public static final String REGEX = "[a-zA-Z0-9_\\-]+";

Review Comment:
   private...



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/utils/YarnQueueLabelExpression.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.streampark.console.core.utils;
+
+import org.apache.streampark.common.conf.ConfigConst;
+import org.apache.streampark.common.enums.ExecutionMode;
+
+import org.apache.commons.lang3.StringUtils;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+/** Util class for parsing and checking Yarn queue & Label */
+public class YarnQueueLabelExpression {
+
+  public static final String AT = "@";
+
+  public static final String REGEX = "[a-zA-Z0-9_\\-]+";
+
+  public static final String ERR_HINTS = "Yarn queue label format is invalid.";
+
+  public static final Pattern QUEUE_LABEL_PATTERN =
+      Pattern.compile(String.format("^(%s)(.%s)*(%s(%s)(,%s)*)?$", REGEX, REGEX, AT, REGEX, REGEX));
+
+  public static final String QUEUE_LABEL_FORMAT = "%s" + AT + "%s";
+
+  private final String queue;
+  private @Nullable final String labelExpression;
+
+  private YarnQueueLabelExpression(String queue, String labelExpression) {
+    this.labelExpression = StringUtils.isEmpty(labelExpression) ? null : labelExpression;
+    this.queue = queue;
+  }
+
+  public Optional<String> getLabelExpression() {
+    return Optional.ofNullable(labelExpression);
+  }
+
+  public @Nonnull String getQueue() {
+    return queue;
+  }
+
+  @Override
+  public String toString() {
+    return StringUtils.isEmpty(labelExpression)
+        ? queue
+        : String.format(QUEUE_LABEL_FORMAT, queue, labelExpression);
+  }
+
+  private static boolean isValid(String queueLabel, boolean ignoreEmpty) {
+    if (StringUtils.isEmpty(queueLabel)) {
+      return ignoreEmpty;
+    }
+    return QUEUE_LABEL_PATTERN.matcher(queueLabel).matches();
+  }
+
+  // Visible for test.
+  public static boolean isValid(String queueLabel) {
+    return isValid(queueLabel, false);
+  }
+
+  /**
+   * Only check the validation of queue-labelExpression when using yarn application or yarn-session
+   * mode.
+   *
+   * @param executionMode execution mode.
+   * @param queueLabel queueLabel expression.
+   */
+  public static void checkQueueLabelIfNeed(int executionMode, String queueLabel) {

Review Comment:
   how about? 
   
   ```
    public static void checkQueueLabelIfNeed(int executionMode, String queueLabel) {
       if (ExecutionMode.isYarnMode(executionMode)) {
           if (!YarnQueueLabelExpression.isValid(queueLabel, true)) {
               throw new IllegalArgumentException(ERR_HINTS);
           }
       }
     }
   
   ```



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1107997339


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1115,17 +1120,28 @@ public Application getApp(Application appParam) {
       }
     }
 
-    if (!application.getHotParamsMap().isEmpty()) {
-      if (ExecutionMode.YARN_APPLICATION.equals(application.getExecutionModeEnum())) {
-        if (application.getHotParamsMap().containsKey(ConfigConst.KEY_YARN_APP_QUEUE())) {
-          application.setYarnQueue(
-              application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE()).toString());
-        }
-      }
-    }
+    fillBackYarnQueue(application);

Review Comment:
   method name : `fillBackYarnQueue`, how about change to `setYarnQueue`?



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1106607004


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java:
##########
@@ -598,9 +598,7 @@ public void updateHotParams(Application appParam) {
     ExecutionMode executionModeEnum = appParam.getExecutionModeEnum();
     Map<String, String> hotParams = new HashMap<>(0);
     if (ExecutionMode.YARN_APPLICATION.equals(executionModeEnum)) {
-      if (StringUtils.isNotEmpty(appParam.getYarnQueue())) {
-        hotParams.put(ConfigConst.KEY_YARN_APP_QUEUE(), appParam.getYarnQueue());
-      }
+      YarnQueueLabelExpression.addQueueLabelExprInto(appParam.getYarnQueue(), hotParams);

Review Comment:
   `ExecutionMode.YARN_APPLICATION.equals(executionModeEnum)` need to be changed to:
   `ExecutionMode.isYarnMode(executionModeEnum)`
   
   This is a historical bug



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] RocMarshal commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1106658707


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java:
##########
@@ -598,9 +598,7 @@ public void updateHotParams(Application appParam) {
     ExecutionMode executionModeEnum = appParam.getExecutionModeEnum();
     Map<String, String> hotParams = new HashMap<>(0);
     if (ExecutionMode.YARN_APPLICATION.equals(executionModeEnum)) {

Review Comment:
   > yarn-application and yarn-perjob need to be set yarn-queue
   
   that's okay.



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] RocMarshal commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1107225886


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1620,11 +1636,16 @@ private Map<String, Object> getProperties(Application application) {
       properties.put(RestOptions.ADDRESS.key(), activeAddress.getHost());
       properties.put(RestOptions.PORT.key(), activeAddress.getPort());
     } else if (ExecutionMode.isYarnMode(application.getExecutionModeEnum())) {
+
       String yarnQueue =
           (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE());
-      if (yarnQueue != null) {
-        properties.put(ConfigConst.KEY_YARN_APP_QUEUE(), yarnQueue);
-      }
+      String yarnLabelExpr =
+          (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_NODE_LABEL());
+      Optional.ofNullable(yarnQueue)
+          .ifPresent(yq -> properties.put(ConfigConst.KEY_YARN_APP_QUEUE(), yq));
+      Optional.ofNullable(yarnLabelExpr)
+          .ifPresent(yLabel -> properties.put(ConfigConst.KEY_YARN_APP_NODE_LABEL(), yLabel));
+

Review Comment:
   The code block would be ran when the mode is yarn-mode, in the truth, the queue-label value would be set when the following condition is true:
   ```
   private boolean needFillYarnQueueLabel(ExecutionMode mode) {
       return ExecutionMode.YARN_PER_JOB.equals(mode) || ExecutionMode.YARN_APPLICATION.equals(mode);
     }
   ```
   
   so, the current code segment is correct for the context of the application lineage, just not exact enough.
   
   However, If I change the block as follows: 
   ```
   if (ExecutionMode.YARN_APPLICATION == application.getExecutionModeEnum()
             || ExecutionMode.YARN_PER_JOB == application.getExecutionModeEnum()) {
           String yarnQueue =
               (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE());
           String yarnLabelExpr =
               (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_NODE_LABEL());
           Optional.ofNullable(yarnQueue)
               .ifPresent(yq -> properties.put(ConfigConst.KEY_YARN_APP_QUEUE(), yq));
           Optional.ofNullable(yarnLabelExpr)
               .ifPresent(yLabel -> properties.put(ConfigConst.KEY_YARN_APP_NODE_LABEL(), yLabel));
         }
   ```
   The `if` condition is exact, but redundant. because the condition is always true in the local context.



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1106618680


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java:
##########
@@ -598,9 +598,7 @@ public void updateHotParams(Application appParam) {
     ExecutionMode executionModeEnum = appParam.getExecutionModeEnum();
     Map<String, String> hotParams = new HashMap<>(0);
     if (ExecutionMode.YARN_APPLICATION.equals(executionModeEnum)) {

Review Comment:
   oh, yarn-session execmode does not need to be set yarn queue, yarn-perjob is deprecated, but there should be many users who use, so. yarn-application and yarn-perjob need to be set yarn-queue



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] RocMarshal commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1107214387


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1115,17 +1120,28 @@ public Application getApp(Application appParam) {
       }
     }
 
-    if (!application.getHotParamsMap().isEmpty()) {
-      if (ExecutionMode.YARN_APPLICATION.equals(application.getExecutionModeEnum())) {
-        if (application.getHotParamsMap().containsKey(ConfigConst.KEY_YARN_APP_QUEUE())) {
-          application.setYarnQueue(
-              application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE()).toString());
-        }
-      }
-    }
+    fillBackYarnQueue(application);
+
     return application;
   }
 
+  private void fillBackYarnQueue(Application application) {
+    if (!(ExecutionMode.YARN_APPLICATION == application.getExecutionModeEnum()

Review Comment:
   
   AnchorA:   
   The logic is meaningful for y-app mode & y perjob mode not for y-session mode.
   The corresponding config items were set when users create flink yarn-session cluster.



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1620,11 +1636,16 @@ private Map<String, Object> getProperties(Application application) {
       properties.put(RestOptions.ADDRESS.key(), activeAddress.getHost());
       properties.put(RestOptions.PORT.key(), activeAddress.getPort());
     } else if (ExecutionMode.isYarnMode(application.getExecutionModeEnum())) {
+
       String yarnQueue =
           (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE());
-      if (yarnQueue != null) {
-        properties.put(ConfigConst.KEY_YARN_APP_QUEUE(), yarnQueue);
-      }
+      String yarnLabelExpr =
+          (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_NODE_LABEL());
+      Optional.ofNullable(yarnQueue)
+          .ifPresent(yq -> properties.put(ConfigConst.KEY_YARN_APP_QUEUE(), yq));
+      Optional.ofNullable(yarnLabelExpr)
+          .ifPresent(yLabel -> properties.put(ConfigConst.KEY_YARN_APP_NODE_LABEL(), yLabel));
+

Review Comment:
   The code block would be enter when the mode is yarn-mode, in the truth, the queue-label value would be set when the following condition is true:
   ```
   private boolean needFillYarnQueueLabel(ExecutionMode mode) {
       return ExecutionMode.YARN_PER_JOB.equals(mode) || ExecutionMode.YARN_APPLICATION.equals(mode);
     }
   ```
   
   so, the current code segment is correct for the context of the application lineage, just not exact enough.
   
   I'll give the change in the next commit.



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] RocMarshal commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1107239192


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1620,11 +1636,16 @@ private Map<String, Object> getProperties(Application application) {
       properties.put(RestOptions.ADDRESS.key(), activeAddress.getHost());
       properties.put(RestOptions.PORT.key(), activeAddress.getPort());
     } else if (ExecutionMode.isYarnMode(application.getExecutionModeEnum())) {
+
       String yarnQueue =
           (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE());
-      if (yarnQueue != null) {
-        properties.put(ConfigConst.KEY_YARN_APP_QUEUE(), yarnQueue);
-      }
+      String yarnLabelExpr =
+          (String) application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_NODE_LABEL());
+      Optional.ofNullable(yarnQueue)
+          .ifPresent(yq -> properties.put(ConfigConst.KEY_YARN_APP_QUEUE(), yq));
+      Optional.ofNullable(yarnLabelExpr)
+          .ifPresent(yLabel -> properties.put(ConfigConst.KEY_YARN_APP_NODE_LABEL(), yLabel));
+

Review Comment:
   So, please let me know what's your opinions.
   thx~!



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] RocMarshal commented on pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#issuecomment-1427038941

   > good job, Thanks for your contribution, I will review it later
   
   Thank you @wolfboys . ping me if anything you need to communicate about .


-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1107130910


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1116,13 +1121,16 @@ public Application getApp(Application appParam) {
       }
     }
 
-    if (!application.getHotParamsMap().isEmpty()) {
-      if (ExecutionMode.YARN_APPLICATION.equals(application.getExecutionModeEnum())) {
-        if (application.getHotParamsMap().containsKey(ConfigConst.KEY_YARN_APP_QUEUE())) {
-          application.setYarnQueue(
-              application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE()).toString());
-        }
-      }
+    Map<String, Object> hotParamsMap = application.getHotParamsMap();

Review Comment:
   all yarn modes need to be set yarn-queue ,
   ```
   if (ExecutionMode.isYarnMode(application.getExecutionModeEnum())) {
           Map<String, Object> hotParamsMap = application.getHotParamsMap();
           if (!hotParamsMap.isEmpty() && hotParamsMap.containsKey(ConfigConst.KEY_YARN_APP_QUEUE())) {
              String yarnQueue = hotParamsMap.get(ConfigConst.KEY_YARN_APP_QUEUE()).toString();
              String labelExpr =
                  Optional.ofNullable(hotParamsMap.get(ConfigConst.KEY_YARN_APP_NODE_LABEL()))
                      .map(Object::toString)
                      .orElse(null);
              application.setYarnQueue(YarnQueueLabelExpression.of(yarnQueue, labelExpr).toString());
          }
       }
   ```



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1107904365


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1115,17 +1120,28 @@ public Application getApp(Application appParam) {
       }
     }
 
-    if (!application.getHotParamsMap().isEmpty()) {
-      if (ExecutionMode.YARN_APPLICATION.equals(application.getExecutionModeEnum())) {
-        if (application.getHotParamsMap().containsKey(ConfigConst.KEY_YARN_APP_QUEUE())) {
-          application.setYarnQueue(
-              application.getHotParamsMap().get(ConfigConst.KEY_YARN_APP_QUEUE()).toString());
-        }
-      }
-    }
+    fillBackYarnQueue(application);
+
     return application;
   }
 
+  private void fillBackYarnQueue(Application application) {
+    if (!(ExecutionMode.YARN_APPLICATION == application.getExecutionModeEnum()

Review Comment:
   > AnchorA: The logic is meaningful for y-app mode & y perjob mode not for y-session mode. The corresponding config items were set when users create flink yarn-session cluster.
   
   Yes,  as you said



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1106607750


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java:
##########
@@ -598,9 +598,7 @@ public void updateHotParams(Application appParam) {
     ExecutionMode executionModeEnum = appParam.getExecutionModeEnum();
     Map<String, String> hotParams = new HashMap<>(0);
     if (ExecutionMode.YARN_APPLICATION.equals(executionModeEnum)) {

Review Comment:
   `ExecutionMode.YARN_APPLICATION.equals(executionModeEnum)` need to be changed to:
   `ExecutionMode.isYarnMode(executionModeEnum)` This is a historical bug



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2317: [Issue-2299] Support the yarn queue label quick-setting for yarn application mode.

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on code in PR #2317:
URL: https://github.com/apache/incubator-streampark/pull/2317#discussion_r1106681723


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/utils/YarnQueueLabelExpression.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.streampark.console.core.utils;
+
+import org.apache.streampark.common.conf.ConfigConst;
+import org.apache.streampark.common.enums.ExecutionMode;
+
+import org.apache.commons.lang3.StringUtils;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+/** Util class for parsing and checking Yarn queue & Label */
+public class YarnQueueLabelExpression {
+
+  public static final String AT = "@";
+
+  public static final String REGEX = "[a-zA-Z0-9_\\-]+";
+
+  public static final String ERR_HINTS = "Yarn queue label format is invalid.";
+
+  public static final Pattern QUEUE_LABEL_PATTERN =
+      Pattern.compile(String.format("^(%s)(.%s)*(%s(%s)(,%s)*)?$", REGEX, REGEX, AT, REGEX, REGEX));
+
+  public static final String QUEUE_LABEL_FORMAT = "%s" + AT + "%s";
+
+  private final String queue;
+  private @Nullable final String labelExpression;
+
+  private YarnQueueLabelExpression(String queue, String labelExpression) {
+    this.labelExpression = StringUtils.isEmpty(labelExpression) ? null : labelExpression;
+    this.queue = queue;
+  }
+
+  public Optional<String> getLabelExpression() {
+    return Optional.ofNullable(labelExpression);
+  }
+
+  public @Nonnull String getQueue() {
+    return queue;
+  }
+
+  @Override
+  public String toString() {
+    return StringUtils.isEmpty(labelExpression)
+        ? queue
+        : String.format(QUEUE_LABEL_FORMAT, queue, labelExpression);
+  }
+
+  private static boolean isValid(String queueLabel, boolean ignoreEmpty) {
+    if (StringUtils.isEmpty(queueLabel)) {
+      return ignoreEmpty;
+    }
+    return QUEUE_LABEL_PATTERN.matcher(queueLabel).matches();
+  }
+
+  // Visible for test.
+  public static boolean isValid(String queueLabel) {
+    return isValid(queueLabel, false);
+  }
+
+  /**
+   * Only check the validation of queue-labelExpression when using yarn application or yarn-session
+   * mode.
+   *
+   * @param executionMode execution mode.
+   * @param queueLabel queueLabel expression.
+   */
+  public static void checkQueueLabelIfNeed(int executionMode, String queueLabel) {
+    if ((ExecutionMode.YARN_SESSION == ExecutionMode.of(executionMode)
+            || ExecutionMode.YARN_APPLICATION == ExecutionMode.of(executionMode))
+        && !YarnQueueLabelExpression.isValid(queueLabel, true)) {
+      throw new IllegalArgumentException(ERR_HINTS);
+    }
+  }
+
+  // Visible for test.
+  public static YarnQueueLabelExpression of(@Nonnull String queueLabelExpr) {
+    if (isValid(queueLabelExpr, false)) {
+      String[] strs = queueLabelExpr.split(AT);
+      if (strs.length == 2) {
+        return new YarnQueueLabelExpression(strs[0], strs[1]);
+      }
+      return new YarnQueueLabelExpression(strs[0], null);
+    }
+    throw new IllegalArgumentException(ERR_HINTS);
+  }
+
+  public static YarnQueueLabelExpression of(
+      @Nonnull String queue, @Nullable String labelExpression) {
+    YarnQueueLabelExpression queueLabelExpression =
+        new YarnQueueLabelExpression(queue, labelExpression);
+    if (isValid(queueLabelExpression.toString(), false)) {
+      return queueLabelExpression;
+    }
+    throw new IllegalArgumentException(ERR_HINTS);
+  }
+
+  /**
+   * Add the queue and label expression into the map as the specified configuration items. For
+   * {@link ConfigConst#KEY_YARN_APP_QUEUE} & {@link ConfigConst#KEY_YARN_APP_NODE_LABEL()}.
+   *
+   * @param queueLabelExp queue and label expression
+   * @param map the target properties.
+   */
+  public static <V> void addQueueLabelExprInto(String queueLabelExp, @Nonnull Map<String, V> map) {

Review Comment:
   > If the label or queue exists, the corresponding value would be put.
   
   get it



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org