You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by lv...@apache.org on 2022/11/25 03:36:13 UTC
[incubator-streampark] branch dev updated: [improve] get appname improvement (#2075)
This is an automated email from the ASF dual-hosted git repository.
lvshaokang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 590f4c9b7 [improve] get appname improvement (#2075)
590f4c9b7 is described below
commit 590f4c9b77705dab3f34a5e70c4eaa87c73a3a3e
Author: benjobs <be...@apache.org>
AuthorDate: Fri Nov 25 11:36:09 2022 +0800
[improve] get appname improvement (#2075)
* [improve] get appname improvement
---
.../streampark/flink/core/conf/ParameterCli.scala | 24 ++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/src/main/scala/org/apache/streampark/flink/core/conf/ParameterCli.scala b/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/src/main/scala/org/apache/streampark/flink/core/conf/ParameterCli.scala
index 1d2239560..96073e0d0 100644
--- a/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/src/main/scala/org/apache/streampark/flink/core/conf/ParameterCli.scala
+++ b/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/src/main/scala/org/apache/streampark/flink/core/conf/ParameterCli.scala
@@ -48,11 +48,15 @@ object ParameterCli {
}
case action =>
val conf = args(1)
- val map = Try(if (conf.endsWith(".properties")) {
- PropertiesUtils.fromPropertiesFile(conf)
- } else {
- PropertiesUtils.fromYamlFile(conf)
- }) match {
+ val map = Try {
+ val extension = conf.split("\\.").last.toLowerCase
+ extension match {
+ case "yml" | "yaml" => PropertiesUtils.fromYamlFile(conf)
+ case "conf" => PropertiesUtils.fromHoconFile(conf)
+ case "properties" => PropertiesUtils.fromPropertiesFile(conf)
+ case _ => throw new IllegalArgumentException("[StreamPark] Usage:flink.conf file error,must be (yml|conf|properties)")
+ }
+ } match {
case Success(value) => value
case _ => Map.empty[String, String]
}
@@ -82,7 +86,15 @@ object ParameterCli {
val buffer = new StringBuffer()
map
.filter(x => x._1 != optionMain && x._1.startsWith(propertyPrefix) && x._2.nonEmpty)
- .foreach(x => buffer.append(s" -D${x._1.drop(propertyPrefix.length)}=${x._2}"))
+ .foreach { x =>
+ val key = x._1.drop(propertyPrefix.length).trim
+ val value = x._2.trim
+ if (key == ConfigConst.KEY_FLINK_APP_NAME) {
+ buffer.append(s" -D$key=${value.replace(" ", "_")}")
+ } else {
+ buffer.append(s" -D$key=$value")
+ }
+ }
buffer.toString.trim
case "--name" =>
map.getOrElse(propertyPrefix.concat(ConfigConst.KEY_FLINK_APP_NAME), "").trim match {