You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/03/14 15:36:12 UTC

[incubator-linkis] branch dev-1.1.1 updated (0654e3a -> 040940a)

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

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


    from 0654e3a  Optimize the performance of API /api/rest_j/v1/udf/all #1726 (#1728)
     new dfce301  #1725 1. replace old package header "com.webank.wedatasphere.linkis" to "org.apache.linkis"
     new 119f8dd  #1727 1. linkis-engineplugin-spark - replace old package header "com.webank.wedatasphere.linkis" to "org.apache.linkis"
     new 040940a  1. format the code.

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:
 .../assembly-combined/conf/linkis-ps-cs.properties |  4 +-
 .../spark/args/SparkScalaPreExecutionHook.scala    | 63 ++++++++++++++++++++++
 .../spark/config/SparkConfiguration.scala          |  6 +++
 .../cs/persistence/conf/PersistenceConf.java       | 10 ++++
 .../persistence/impl/ContextIDPersistenceImpl.java | 35 ++++++++++++
 .../impl/ContextMapPersistenceImpl.java            | 33 ++++++++++++
 6 files changed, 150 insertions(+), 1 deletion(-)
 create mode 100644 linkis-engineconn-plugins/engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/args/SparkScalaPreExecutionHook.scala

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


[incubator-linkis] 03/03: 1. format the code.

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

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

commit 040940a6661e17215389d6a4311ae9b310c676ce
Author: alexkun <xu...@qq.com>
AuthorDate: Mon Mar 14 23:03:02 2022 +0800

    1. format the code.
---
 .../cs/persistence/conf/PersistenceConf.java       | 10 ++++---
 .../persistence/impl/ContextIDPersistenceImpl.java | 33 ++++++++++++++++++----
 .../impl/ContextMapPersistenceImpl.java            | 31 ++++++++++++++++----
 3 files changed, 58 insertions(+), 16 deletions(-)

diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/conf/PersistenceConf.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/conf/PersistenceConf.java
index 0897081..7739d0f 100644
--- a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/conf/PersistenceConf.java
+++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/conf/PersistenceConf.java
@@ -17,7 +17,6 @@
 
 package org.apache.linkis.cs.persistence.conf;
 
-import com.sun.org.apache.xpath.internal.operations.Bool;
 import org.apache.linkis.common.conf.CommonVars;
 
 public class PersistenceConf {
@@ -32,10 +31,13 @@ public class PersistenceConf {
     public static final CommonVars<String> TUNING_METHOD =
             CommonVars.apply("wds.linkis.cs.ha.proxymethod", "getContextHAProxy");
 
-    public static final CommonVars<Boolean> ENABLE_CS_DESERIALIZE_REPLACE_PACKAGE_HEADER = CommonVars.apply("wds.linkis.cs.deserialize.replace_package_header.enable", false);
+    public static final CommonVars<Boolean> ENABLE_CS_DESERIALIZE_REPLACE_PACKAGE_HEADER =
+            CommonVars.apply("wds.linkis.cs.deserialize.replace_package_header.enable", false);
 
-    public static final CommonVars<String> CS_DESERIALIZE_REPLACE_PACKAGE_HEADER = CommonVars.apply("wds.linkis.cs.deserialize.replace_package.header", "com.webank.wedatasphere.linkis");
+    public static final CommonVars<String> CS_DESERIALIZE_REPLACE_PACKAGE_HEADER =
+            CommonVars.apply(
+                    "wds.linkis.cs.deserialize.replace_package.header",
+                    "com.webank.wedatasphere.linkis");
 
     public static final String CSID_PACKAGE_HEADER = "org.apache.linkis";
-
 }
diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextIDPersistenceImpl.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextIDPersistenceImpl.java
index fdbc3e3..820fc71 100644
--- a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextIDPersistenceImpl.java
+++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextIDPersistenceImpl.java
@@ -17,7 +17,6 @@
 
 package org.apache.linkis.cs.persistence.persistence.impl;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.linkis.cs.common.entity.source.ContextID;
 import org.apache.linkis.cs.common.exception.CSErrorException;
 import org.apache.linkis.cs.persistence.conf.PersistenceConf;
@@ -28,6 +27,7 @@ import org.apache.linkis.cs.persistence.persistence.ContextIDPersistence;
 import org.apache.linkis.cs.persistence.util.PersistenceUtils;
 import org.apache.linkis.server.BDPJettyServerHelper;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.math3.util.Pair;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -85,14 +85,35 @@ public class ContextIDPersistenceImpl implements ContextIDPersistence {
             PersistenceContextID pContextID = contextIDMapper.getContextID(contextId);
             if (pContextID == null) return null;
             if (PersistenceConf.ENABLE_CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue()) {
-                if (StringUtils.isBlank(pContextID.getSource()) || StringUtils.isBlank(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
-                    logger.error("Source : {} of ContextID or CSID_REPLACE_PACKAGE_HEADER : {} cannot be empty.", pContextID.getSource(), PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue());
+                if (StringUtils.isBlank(pContextID.getSource())
+                        || StringUtils.isBlank(
+                                PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
+                    logger.error(
+                            "Source : {} of ContextID or CSID_REPLACE_PACKAGE_HEADER : {} cannot be empty.",
+                            pContextID.getSource(),
+                            PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue());
                 } else {
-                    if (pContextID.getSource().contains(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
+                    if (pContextID
+                            .getSource()
+                            .contains(
+                                    PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER
+                                            .getValue())) {
                         if (logger.isDebugEnabled()) {
-                            logger.debug("Will replace package header of source : {} from : {} to : {}", pContextID.getSource(), PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue(), PersistenceConf.CSID_PACKAGE_HEADER);
+                            logger.debug(
+                                    "Will replace package header of source : {} from : {} to : {}",
+                                    pContextID.getSource(),
+                                    PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER
+                                            .getValue(),
+                                    PersistenceConf.CSID_PACKAGE_HEADER);
                         }
-                        pContextID.setSource(pContextID.getSource().replaceAll(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue(), PersistenceConf.CSID_PACKAGE_HEADER));
+                        pContextID.setSource(
+                                pContextID
+                                        .getSource()
+                                        .replaceAll(
+                                                PersistenceConf
+                                                        .CS_DESERIALIZE_REPLACE_PACKAGE_HEADER
+                                                        .getValue(),
+                                                PersistenceConf.CSID_PACKAGE_HEADER));
                     }
                 }
             }
diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextMapPersistenceImpl.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextMapPersistenceImpl.java
index ebe5cad..38235bf 100644
--- a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextMapPersistenceImpl.java
+++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextMapPersistenceImpl.java
@@ -17,7 +17,6 @@
 
 package org.apache.linkis.cs.persistence.persistence.impl;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.linkis.cs.common.entity.enumeration.ContextScope;
 import org.apache.linkis.cs.common.entity.enumeration.ContextType;
 import org.apache.linkis.cs.common.entity.source.ContextID;
@@ -37,6 +36,7 @@ import org.apache.linkis.cs.persistence.persistence.ContextMapPersistence;
 import org.apache.linkis.cs.persistence.util.PersistenceUtils;
 import org.apache.linkis.server.BDPJettyServerHelper;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.math3.util.Pair;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -125,14 +125,33 @@ public class ContextMapPersistenceImpl implements ContextMapPersistence {
             PersistenceContextKey pK = (PersistenceContextKey) pKV.getContextKey();
             PersistenceContextValue pV = (PersistenceContextValue) pKV.getContextValue();
             if (PersistenceConf.ENABLE_CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue()) {
-                if (StringUtils.isBlank(pKV.getProps()) || StringUtils.isBlank(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
-                    logger.error("Props : {} of ContextMap or CSID_REPLACE_PACKAGE_HEADER : {} cannot be empty.", pKV.getProps(), PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue());
+                if (StringUtils.isBlank(pKV.getProps())
+                        || StringUtils.isBlank(
+                                PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
+                    logger.error(
+                            "Props : {} of ContextMap or CSID_REPLACE_PACKAGE_HEADER : {} cannot be empty.",
+                            pKV.getProps(),
+                            PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue());
                 } else {
-                    if (pKV.getProps().contains(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
+                    if (pKV.getProps()
+                            .contains(
+                                    PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER
+                                            .getValue())) {
                         if (logger.isDebugEnabled()) {
-                            logger.debug("Will replace package header of source : {} from : {} to : {}", pKV.getProps(), PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue(), PersistenceConf.CSID_PACKAGE_HEADER);
+                            logger.debug(
+                                    "Will replace package header of source : {} from : {} to : {}",
+                                    pKV.getProps(),
+                                    PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER
+                                            .getValue(),
+                                    PersistenceConf.CSID_PACKAGE_HEADER);
                         }
-                        pKV.setProps(pKV.getProps().replaceAll(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue(), PersistenceConf.CSID_PACKAGE_HEADER));
+                        pKV.setProps(
+                                pKV.getProps()
+                                        .replaceAll(
+                                                PersistenceConf
+                                                        .CS_DESERIALIZE_REPLACE_PACKAGE_HEADER
+                                                        .getValue(),
+                                                PersistenceConf.CSID_PACKAGE_HEADER));
                     }
                 }
             }

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


[incubator-linkis] 02/03: #1727 1. linkis-engineplugin-spark - replace old package header "com.webank.wedatasphere.linkis" to "org.apache.linkis"

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

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

commit 119f8dd4eb00d334573beb4029176fd3ad9c14b2
Author: alexkun <xu...@qq.com>
AuthorDate: Mon Mar 14 22:38:40 2022 +0800

    #1727
    1. linkis-engineplugin-spark - replace old package header "com.webank.wedatasphere.linkis" to "org.apache.linkis"
---
 .../spark/args/SparkScalaPreExecutionHook.scala    | 63 ++++++++++++++++++++++
 .../spark/config/SparkConfiguration.scala          |  6 +++
 2 files changed, 69 insertions(+)

diff --git a/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/args/SparkScalaPreExecutionHook.scala b/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/args/SparkScalaPreExecutionHook.scala
new file mode 100644
index 0000000..e042a77
--- /dev/null
+++ b/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/args/SparkScalaPreExecutionHook.scala
@@ -0,0 +1,63 @@
+/*
+ * 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.linkis.engineplugin.spark.args
+
+import org.apache.commons.lang3.StringUtils
+import org.apache.linkis.common.utils.Logging
+import org.apache.linkis.engineconn.computation.executor.execute.EngineExecutionContext
+import org.apache.linkis.engineplugin.spark.common.SparkKind
+import org.apache.linkis.engineplugin.spark.config.SparkConfiguration
+import org.apache.linkis.engineplugin.spark.extension.SparkPreExecutionHook
+import org.apache.linkis.governance.common.paser.CodeType
+import org.apache.linkis.manager.label.entity.engine.RunType
+import org.apache.linkis.manager.label.utils.LabelUtil
+import org.springframework.stereotype.Component
+
+import javax.annotation.PostConstruct
+import scala.collection.JavaConverters.seqAsJavaListConverter
+
+@Component
+class SparkScalaPreExecutionHook extends SparkPreExecutionHook with Logging {
+
+  @PostConstruct
+  private def init(): Unit = {
+    SparkPreExecutionHook.register(this)
+  }
+
+  override def hookName: String = getClass.getSimpleName
+
+  override def callPreExecutionHook(engineExecutionContext: EngineExecutionContext, code: String): String = {
+    if (!SparkConfiguration.ENABLE_REPLACE_PACKAGE_NAME.getValue || StringUtils.isBlank(code)) {
+      return code
+    }
+    val codeTypeLabel = LabelUtil.getCodeTypeLabel(engineExecutionContext.getLabels.toList.asJava)
+    if (null != codeTypeLabel) {
+      codeTypeLabel.getCodeType.toLowerCase() match {
+        case SparkKind.SCALA_LAN | SparkKind.FUNCTION_MDQ_TYPE =>
+          if (!code.contains(SparkConfiguration.REPLACE_PACKAGE_HEADER.getValue)) {
+            return code
+          } else {
+            logger.info(s"Replaced ${SparkConfiguration.REPLACE_PACKAGE_HEADER.getValue} to ${SparkConfiguration.REPLACE_PACKAGE_TO_HEADER}")
+            return code.replaceAll(SparkConfiguration.REPLACE_PACKAGE_HEADER.getValue, SparkConfiguration.REPLACE_PACKAGE_TO_HEADER)
+          }
+        case _ =>
+      }
+    }
+    code
+  }
+}
diff --git a/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/config/SparkConfiguration.scala b/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/config/SparkConfiguration.scala
index 1f9d3dd..893f016 100644
--- a/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/config/SparkConfiguration.scala
+++ b/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/config/SparkConfiguration.scala
@@ -84,6 +84,12 @@ object SparkConfiguration extends Logging {
 
   val PYSPARK_PYTHON3_PATH = CommonVars[String]("pyspark.python3.path", "/appcom/Install/anaconda3/bin/python")
 
+  val ENABLE_REPLACE_PACKAGE_NAME = CommonVars("wds.linkis.spark.engine.scala.replace_package_header.enable", true)
+
+  val REPLACE_PACKAGE_HEADER = CommonVars("wds.linkis.spark.engine.scala.replace_package.header", "com.webank.wedatasphere.linkis")
+
+  val REPLACE_PACKAGE_TO_HEADER = "org.apache.linkis"
+
   private def getMainJarName(): String = {
     val somePath = ClassUtils.jarOfClass(classOf[SparkEngineConnFactory])
     if (somePath.isDefined) {

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


[incubator-linkis] 01/03: #1725 1. replace old package header "com.webank.wedatasphere.linkis" to "org.apache.linkis"

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

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

commit dfce3010fe0f5e4e754416f6a18e37dced0e7a18
Author: alexkun <xu...@qq.com>
AuthorDate: Mon Mar 14 22:36:20 2022 +0800

    #1725
    1. replace old package header "com.webank.wedatasphere.linkis" to "org.apache.linkis"
---
 .../assembly-combined/conf/linkis-ps-cs.properties         |  4 +++-
 .../apache/linkis/cs/persistence/conf/PersistenceConf.java |  8 ++++++++
 .../persistence/impl/ContextIDPersistenceImpl.java         | 14 ++++++++++++++
 .../persistence/impl/ContextMapPersistenceImpl.java        | 14 ++++++++++++++
 4 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/assembly-combined-package/assembly-combined/conf/linkis-ps-cs.properties b/assembly-combined-package/assembly-combined/conf/linkis-ps-cs.properties
index 26b9c97..f5526de 100644
--- a/assembly-combined-package/assembly-combined/conf/linkis-ps-cs.properties
+++ b/assembly-combined-package/assembly-combined/conf/linkis-ps-cs.properties
@@ -23,4 +23,6 @@ wds.linkis.server.mybatis.BasePackage=org.apache.linkis.cs.persistence.dao
 ##Spring
 spring.server.port=9108
 # ps-cs prefix must be started with 'cs_'
-spring.eureka.instance.metadata-map.route=cs_1_dev
\ No newline at end of file
+spring.eureka.instance.metadata-map.route=cs_1_dev
+wds.linkis.cs.deserialize.replace_package_header.enable=false
+
diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/conf/PersistenceConf.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/conf/PersistenceConf.java
index f870e09..0897081 100644
--- a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/conf/PersistenceConf.java
+++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/conf/PersistenceConf.java
@@ -17,6 +17,7 @@
 
 package org.apache.linkis.cs.persistence.conf;
 
+import com.sun.org.apache.xpath.internal.operations.Bool;
 import org.apache.linkis.common.conf.CommonVars;
 
 public class PersistenceConf {
@@ -30,4 +31,11 @@ public class PersistenceConf {
 
     public static final CommonVars<String> TUNING_METHOD =
             CommonVars.apply("wds.linkis.cs.ha.proxymethod", "getContextHAProxy");
+
+    public static final CommonVars<Boolean> ENABLE_CS_DESERIALIZE_REPLACE_PACKAGE_HEADER = CommonVars.apply("wds.linkis.cs.deserialize.replace_package_header.enable", false);
+
+    public static final CommonVars<String> CS_DESERIALIZE_REPLACE_PACKAGE_HEADER = CommonVars.apply("wds.linkis.cs.deserialize.replace_package.header", "com.webank.wedatasphere.linkis");
+
+    public static final String CSID_PACKAGE_HEADER = "org.apache.linkis";
+
 }
diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextIDPersistenceImpl.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextIDPersistenceImpl.java
index 4e40bc3..fdbc3e3 100644
--- a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextIDPersistenceImpl.java
+++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextIDPersistenceImpl.java
@@ -17,8 +17,10 @@
 
 package org.apache.linkis.cs.persistence.persistence.impl;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.linkis.cs.common.entity.source.ContextID;
 import org.apache.linkis.cs.common.exception.CSErrorException;
+import org.apache.linkis.cs.persistence.conf.PersistenceConf;
 import org.apache.linkis.cs.persistence.dao.ContextIDMapper;
 import org.apache.linkis.cs.persistence.entity.ExtraFieldClass;
 import org.apache.linkis.cs.persistence.entity.PersistenceContextID;
@@ -82,6 +84,18 @@ public class ContextIDPersistenceImpl implements ContextIDPersistence {
         try {
             PersistenceContextID pContextID = contextIDMapper.getContextID(contextId);
             if (pContextID == null) return null;
+            if (PersistenceConf.ENABLE_CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue()) {
+                if (StringUtils.isBlank(pContextID.getSource()) || StringUtils.isBlank(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
+                    logger.error("Source : {} of ContextID or CSID_REPLACE_PACKAGE_HEADER : {} cannot be empty.", pContextID.getSource(), PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue());
+                } else {
+                    if (pContextID.getSource().contains(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("Will replace package header of source : {} from : {} to : {}", pContextID.getSource(), PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue(), PersistenceConf.CSID_PACKAGE_HEADER);
+                        }
+                        pContextID.setSource(pContextID.getSource().replaceAll(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue(), PersistenceConf.CSID_PACKAGE_HEADER));
+                    }
+                }
+            }
             ExtraFieldClass extraFieldClass =
                     json.readValue(pContextID.getSource(), ExtraFieldClass.class);
             ContextID contextID = PersistenceUtils.transfer(extraFieldClass, pContextID);
diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextMapPersistenceImpl.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextMapPersistenceImpl.java
index ab65c8b..ebe5cad 100644
--- a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextMapPersistenceImpl.java
+++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/src/main/java/org/apache/linkis/cs/persistence/persistence/impl/ContextMapPersistenceImpl.java
@@ -17,6 +17,7 @@
 
 package org.apache.linkis.cs.persistence.persistence.impl;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.linkis.cs.common.entity.enumeration.ContextScope;
 import org.apache.linkis.cs.common.entity.enumeration.ContextType;
 import org.apache.linkis.cs.common.entity.source.ContextID;
@@ -26,6 +27,7 @@ import org.apache.linkis.cs.common.entity.source.ContextValue;
 import org.apache.linkis.cs.common.exception.CSErrorException;
 import org.apache.linkis.cs.common.serialize.helper.ContextSerializationHelper;
 import org.apache.linkis.cs.common.serialize.helper.SerializationHelper;
+import org.apache.linkis.cs.persistence.conf.PersistenceConf;
 import org.apache.linkis.cs.persistence.dao.ContextMapMapper;
 import org.apache.linkis.cs.persistence.entity.ExtraFieldClass;
 import org.apache.linkis.cs.persistence.entity.PersistenceContextKey;
@@ -122,6 +124,18 @@ public class ContextMapPersistenceImpl implements ContextMapPersistence {
             // TODO: 2020/2/14 null return
             PersistenceContextKey pK = (PersistenceContextKey) pKV.getContextKey();
             PersistenceContextValue pV = (PersistenceContextValue) pKV.getContextValue();
+            if (PersistenceConf.ENABLE_CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue()) {
+                if (StringUtils.isBlank(pKV.getProps()) || StringUtils.isBlank(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
+                    logger.error("Props : {} of ContextMap or CSID_REPLACE_PACKAGE_HEADER : {} cannot be empty.", pKV.getProps(), PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue());
+                } else {
+                    if (pKV.getProps().contains(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue())) {
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("Will replace package header of source : {} from : {} to : {}", pKV.getProps(), PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue(), PersistenceConf.CSID_PACKAGE_HEADER);
+                        }
+                        pKV.setProps(pKV.getProps().replaceAll(PersistenceConf.CS_DESERIALIZE_REPLACE_PACKAGE_HEADER.getValue(), PersistenceConf.CSID_PACKAGE_HEADER));
+                    }
+                }
+            }
             ExtraFieldClass extraFieldClass = json.readValue(pKV.getProps(), ExtraFieldClass.class);
             ContextKey key = PersistenceUtils.transfer(extraFieldClass.getOneSub(0), pK);
             ContextValue value = PersistenceUtils.transfer(extraFieldClass.getOneSub(1), pV);

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