You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by le...@apache.org on 2022/04/25 13:28:53 UTC

[incubator-linkis] branch dev-1.1.2 updated (048428ba1 -> 53a66d109)

This is an automated email from the ASF dual-hosted git repository.

leebai pushed a change to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


    from 048428ba1 Fix ecp material download error,change start byte 0 to 1 in VersionServiceImpl.updateVersion, and fix log info (#2027)
     new e00582c71 Configuration rpc interface optimization #2031
     new 495a7ecd4 Optimize the Replace into syntax to remove useGeneratedKeys
     new 53a66d109 add the repeatability judgment of key-value

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../linkis/configuration/dao/impl/ConfigMapper.xml |   4 +-
 .../service/impl/ConfigKeyServiceImpl.java         |  20 +++-
 .../service/ConfigurationService.scala             | 107 ++++++++++++++-------
 3 files changed, 88 insertions(+), 43 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org


[incubator-linkis] 02/03: Optimize the Replace into syntax to remove useGeneratedKeys

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

leebai pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git

commit 495a7ecd4ea38ea0b2b764d28b1fbfee35c993d4
Author: peacewong <wp...@gmail.com>
AuthorDate: Mon Apr 25 20:19:38 2022 +0800

    Optimize the Replace into syntax to remove useGeneratedKeys
---
 .../java/org/apache/linkis/configuration/dao/impl/ConfigMapper.xml    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/impl/ConfigMapper.xml b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/impl/ConfigMapper.xml
index b72380833..b22b135b2 100644
--- a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/impl/ConfigMapper.xml
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/impl/ConfigMapper.xml
@@ -15,7 +15,7 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-  
+
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 
 <mapper namespace="org.apache.linkis.configuration.dao.ConfigMapper">
@@ -179,7 +179,7 @@
     </update>
 
     <!--ConfigValue-->
-    <insert id="insertValue" useGeneratedKeys="true" keyProperty="id" parameterType="org.apache.linkis.configuration.entity.ConfigValue">
+    <insert id="insertValue"  parameterType="org.apache.linkis.configuration.entity.ConfigValue">
         REPLACE INTO linkis_ps_configuration_config_value(
             id, config_key_id, config_value, config_label_id, create_time, update_time)
         VALUES (


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org


[incubator-linkis] 03/03: add the repeatability judgment of key-value

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

leebai pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git

commit 53a66d109b9d193f8f2ca233565d58e3e7a2754d
Author: peacewong <wp...@gmail.com>
AuthorDate: Mon Apr 25 20:20:23 2022 +0800

    add the repeatability judgment of key-value
---
 .../service/impl/ConfigKeyServiceImpl.java           | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/ConfigKeyServiceImpl.java b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/ConfigKeyServiceImpl.java
index 381aa41be..8f3314294 100644
--- a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/ConfigKeyServiceImpl.java
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/ConfigKeyServiceImpl.java
@@ -80,10 +80,22 @@ public class ConfigKeyServiceImpl implements ConfigKeyService {
             labelMapper.insertLabel(configLabel);
             logger.info("succeed to create label: {}", configLabel.getStringValue());
         }
-        ConfigValue configValue = new ConfigValue();
-        configValue.setConfigKeyId(configKey.getId());
-        configValue.setConfigValue(configKeyValue.getConfigValue());
-        configValue.setConfigLabelId(configLabel.getId());
+        List<ConfigValue> configValues = getConfigValue(configKeyValue.getKey(), labelList);
+        ConfigValue configValue = null;
+        if (configValues.size() > 1) {
+            throw new ConfigurationException(
+                    combinedLabel.getStringValue()
+                            + "There are multiple values for the corresponding Key: "
+                            + configKeyValue.getKey());
+        } else if (configValues.size() == 1) {
+            configValue = configValues.get(0);
+            configValue.setConfigValue(configKeyValue.getConfigValue());
+        } else {
+            configValue = new ConfigValue();
+            configValue.setConfigKeyId(configKey.getId());
+            configValue.setConfigValue(configKeyValue.getConfigValue());
+            configValue.setConfigLabelId(configLabel.getId());
+        }
         configMapper.insertValue(configValue);
         logger.info(
                 "succeed to save key: {} by label: {} value: {} ",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org


[incubator-linkis] 01/03: Configuration rpc interface optimization #2031

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

leebai pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git

commit e00582c71e6accf7ae138a2fea0bacf763b23235
Author: peacewong <wp...@gmail.com>
AuthorDate: Mon Apr 25 20:17:53 2022 +0800

    Configuration rpc interface optimization #2031
---
 .../service/ConfigurationService.scala             | 107 ++++++++++++++-------
 1 file changed, 70 insertions(+), 37 deletions(-)

diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/scala/org/apache/linkis/configuration/service/ConfigurationService.scala b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/scala/org/apache/linkis/configuration/service/ConfigurationService.scala
index 2e6d4b915..a7a175715 100644
--- a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/scala/org/apache/linkis/configuration/service/ConfigurationService.scala
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/scala/org/apache/linkis/configuration/service/ConfigurationService.scala
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 package org.apache.linkis.configuration.service
 
 import org.apache.commons.lang3.StringUtils
@@ -255,15 +255,7 @@ class ConfigurationService extends Logging {
     })
   }
 
-  /**
-   * Priority: User Configuration-->Creator's Default Engine Configuration-->Default Engine Configuration
-   * For database initialization: you need to modify the linkis.dml file--associated label and default configuration,
-   * modify the engine such as label.label_value = @SPARK_ALL to @SPARK_IDE and so on for each application
-   * @param labelList
-   * @param useDefaultConfig
-   * @return
-   */
-  def getFullTreeByLabelList(labelList: java.util.List[Label[_]], useDefaultConfig: Boolean = true): util.ArrayList[ConfigTree] = {
+  def getConfigsByLabelList(labelList: java.util.List[Label[_]], useDefaultConfig: Boolean = true): (util.List[ConfigKeyValue], util.List[ConfigKeyValue]) = {
     LabelParameterParser.labelCheck(labelList)
     val combinedLabel = combinedLabelBuilder.build("", labelList).asInstanceOf[CombinedLabelImpl]
     val label = labelMapper.getLabelByKeyValue(combinedLabel.getLabelKey, combinedLabel.getStringValue)
@@ -294,12 +286,54 @@ class ConfigurationService extends Logging {
         replaceCreatorToEngine(defaultCreatorConfigs, defaultEngineConfigs)
       }
     }
+    (configs, defaultEngineConfigs)
+  }
+
+  /**
+   * Priority: User Configuration-->Creator's Default Engine Configuration-->Default Engine Configuration
+   * For database initialization: you need to modify the linkis.dml file--associated label and default configuration,
+   * modify the engine such as label.label_value = @SPARK_ALL to @SPARK_IDE and so on for each application
+   * @param labelList
+   * @param useDefaultConfig
+   * @return
+   */
+  def getFullTreeByLabelList(labelList: java.util.List[Label[_]], useDefaultConfig: Boolean = true): util.ArrayList[ConfigTree] = {
+    val (configs, defaultEngineConfigs) = getConfigsByLabelList(labelList, useDefaultConfig)
     buildTreeResult(configs, defaultEngineConfigs)
   }
 
+  /**
+   * Priority: labelList > defaultConfig
+   * @param labelList
+   * @param useDefaultConfig
+   * @return
+   */
+  def getConfigMapByLabels(labelList: java.util.List[Label[_]], useDefaultConfig: Boolean = true): util.Map[String, String] = {
+    val (configs, defaultEngineConfigs) = getConfigsByLabelList(labelList, useDefaultConfig)
+    val configMap = new util.HashMap[String, String]()
+    if (null != defaultEngineConfigs) {
+      defaultEngineConfigs.asScala.foreach{ keyValue =>
+        if (StringUtils.isNoneBlank(keyValue.getKey) && StringUtils.isNotEmpty(keyValue.getConfigValue)) {
+          configMap.put(keyValue.getKey, keyValue.getConfigValue)
+        }
+      }
+    }
+    if (null != configs) {
+      configs.asScala.foreach{ keyValue =>
+        if (StringUtils.isNoneBlank(keyValue.getKey)) {
+          if (StringUtils.isNoneEmpty(keyValue.getConfigValue)) {
+            configMap.put(keyValue.getKey, keyValue.getConfigValue)
+          } else {
+            configMap.put(keyValue.getKey, keyValue.getDefaultValue)
+          }
+        }
+      }
+    }
+    configMap
+  }
 
   @Transactional
-   def persisteUservalue(configs: util.List[ConfigKeyValue], defaultConfigs: util.List[ConfigKeyValue], combinedLabel: CombinedLabel, existsLabel: ConfigLabel): Unit = {
+  def persisteUservalue(configs: util.List[ConfigKeyValue], defaultConfigs: util.List[ConfigKeyValue], combinedLabel: CombinedLabel, existsLabel: ConfigLabel): Unit = {
     info(s"Start checking the integrity of user configuration data(开始检查用户配置数据的完整性): label标签为:${combinedLabel.getStringValue}")
     val userConfigList = configs.asScala
     val userConfigKeyIdList = userConfigList.map(config => config.getId)
@@ -328,17 +362,18 @@ class ConfigurationService extends Logging {
     info(s"User configuration data integrity check completed!(用户配置数据完整性检查完毕!): label标签为:${combinedLabel.getStringValue}")
   }
 
-    def queryConfigByLabel(labelList: java.util.List[Label[_]], isMerge: Boolean = true, filter: String = null): ResponseQueryConfig = {
-      LabelParameterParser.labelCheck(labelList)
-      val allGolbalUserConfig = getFullTreeByLabelList(labelList)
-      val defaultLabel = LabelParameterParser.changeUserToDefault(labelList)
-      val allGolbalDefaultConfig = getFullTreeByLabelList(defaultLabel)
-      val config = new ResponseQueryConfig
-      config.setKeyAndValue(getMap(allGolbalDefaultConfig, allGolbalUserConfig, filter))
-      config
+  def queryConfigByLabel(labelList: java.util.List[Label[_]], isMerge: Boolean = true, filter: String = null): ResponseQueryConfig = {
+    LabelParameterParser.labelCheck(labelList)
+    val allGolbalUserConfig = getConfigMapByLabels(labelList)
+    val defaultLabel = LabelParameterParser.changeUserToDefault(labelList)
+    val allGolbalDefaultConfig = getConfigMapByLabels(defaultLabel)
+    val config = new ResponseQueryConfig
+    config.setKeyAndValue(getMap(allGolbalDefaultConfig, allGolbalUserConfig, filter))
+    config
   }
 
 
+
   def queryDefaultEngineConfig(engineTypeLabel: EngineTypeLabel): ResponseQueryConfig = {
     val labelList = LabelEntityParser.generateUserCreatorEngineTypeLabelList("*", "*", engineTypeLabel.getEngineType, engineTypeLabel.getVersion)
     queryConfigByLabel(labelList)
@@ -367,28 +402,26 @@ class ConfigurationService extends Logging {
     engineConfig
   }
 
-  private def getMap(all: util.List[ConfigTree], user: util.List[ConfigTree], filter: String = null): util.Map[String, String] = {
+  private def getMap(all: util.Map[String, String], user: util.Map[String, String], filter: String = null): util.Map[String, String] = {
     val map = new util.HashMap[String, String]()
-    val allConfig = all.asScala.map(configTree => configTree.getSettings)
-    val userConfig = user.asScala.map(configTree => configTree.getSettings)
     if (filter != null) {
-      allConfig.foreach(f => f.asScala.foreach(configKeyValue => if (configKeyValue.getKey.contains(filter)) map.put(configKeyValue.getKey, configKeyValue.getDefaultValue)))
-      userConfig.foreach(f => f.asScala.foreach(configKeyValue => if (configKeyValue.getKey.contains(filter)) {
-        if (StringUtils.isNotEmpty(configKeyValue.getConfigValue)) {
-          map.put(configKeyValue.getKey, configKeyValue.getConfigValue)
-        } else {
-          map.put(configKeyValue.getKey, configKeyValue.getDefaultValue)
+      if (null != all) {
+        all.asScala.foreach { keyValue =>
+          if (keyValue._1.contains(filter)) {
+            map.put(keyValue._1, keyValue._2)
+          }
         }
-      }))
-    } else {
-      allConfig.foreach(f => f.asScala.foreach(configKeyValue => map.put(configKeyValue.getKey, configKeyValue.getDefaultValue)))
-      userConfig.foreach(f => f.asScala.foreach(configKeyValue => {
-        if (StringUtils.isNotEmpty(configKeyValue.getConfigValue)) {
-          map.put(configKeyValue.getKey, configKeyValue.getConfigValue)
-        } else {
-          map.put(configKeyValue.getKey, configKeyValue.getDefaultValue)
+      }
+      if (null != user) {
+        user.asScala.foreach{ keyValue =>
+          if (keyValue._1.contains(filter)) {
+            map.put(keyValue._1, keyValue._2)
+          }
         }
-      }))
+      }
+    } else {
+      map.putAll(all)
+      map.putAll(user)
     }
     //user conf reset default value
     map


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org