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:13 UTC
[incubator-linkis] 01/03: #1725 1. replace old package header "com.webank.wedatasphere.linkis" to "org.apache.linkis"
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