This is an automated email from the ASF dual-hosted git repository.
casion pushed a commit to branch dev-1.3.2
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
new 57e3c9e08 [Feature][Common] Optimize the codeType and Language utility
classes (#3973)
57e3c9e08 is described below
commit 57e3c9e0849c19750bbe8d8492e33da0aa11932d
Author: peacewong <[email protected]>
AuthorDate: Wed Dec 14 21:00:34 2022 +0800
[Feature][Common] Optimize the codeType and Language utility classes (#3973)
* add execute user to task vo
* Modify outstanding tasks not asynchronous
* Fix language type not found issue
* languageType is not match return empty
---
.../linkis/common/utils/CodeAndRunTypeUtils.scala | 80 ++++++++++++++++------
.../apache/linkis/common/utils/VariableUtils.scala | 30 ++++----
.../common/utils/CodeAndRunTypeUtilsTest.scala | 37 +++++++---
.../script/compaction/PYScriptCompaction.scala | 5 +-
.../script/compaction/QLScriptCompaction.scala | 5 +-
.../script/compaction/ScalaScriptCompaction.scala | 5 +-
.../script/compaction/ShellScriptCompaction.scala | 5 +-
.../storage/script/parser/PYScriptParser.scala | 5 +-
.../storage/script/parser/QLScriptParser.scala | 5 +-
.../storage/script/parser/ScalaScriptParser.scala | 5 +-
.../storage/script/parser/ShellScriptParser.scala | 5 +-
.../governance/common/paser/CodeParser.scala | 25 +++----
.../entrance/parser/AbstractEntranceParser.java | 23 +------
.../entrance/conf/EntranceConfiguration.scala | 3 -
.../entrance/interceptor/RuntypeInterceptor.scala | 10 +--
.../interceptor/impl/CommentInterceptor.scala | 12 ++--
.../linkis/entrance/interceptor/impl/Explain.scala | 5 +-
.../impl/PythonCodeCheckInterceptor.scala | 6 +-
.../interceptor/impl/SQLCodeCheckInterceptor.scala | 8 +--
.../impl/SQLLimitEntranceInterceptor.scala | 6 +-
.../interceptor/impl/ScalaCodeInterceptor.scala | 6 +-
.../impl/ShellDangerousGrammerInterceptor.scala | 14 ++--
.../impl/SparkCodeCheckInterceptor.scala | 6 +-
.../spark/args/SparkScalaPreExecutionHook.scala | 2 -
.../cache/impl/DefaultQueryCacheManager.java | 16 +++--
.../linkis/jobhistory/entity/QueryTaskVO.java | 11 +++
.../jobhistory/conversions/TaskConversions.scala | 54 +--------------
27 files changed, 197 insertions(+), 197 deletions(-)
diff --git
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtils.scala
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtils.scala
index d00be6d3a..3870fe6e5 100644
---
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtils.scala
+++
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtils.scala
@@ -24,20 +24,37 @@ import org.apache.commons.lang3.StringUtils
object CodeAndRunTypeUtils {
private val CONF_LOCK = new Object()
+ /**
+ * sql Language type sql/hql/jdbc code Type
+ */
val CODE_TYPE_AND_RUN_TYPE_RELATION = CommonVars(
- "wds.linkis.codeType.runType.relation",
+ "linkis.codeType.language.relation",
"sql=>sql|hql|jdbc|hive|psql|fql|tsql,python=>python|py|pyspark,java=>java,scala=>scala,shell=>sh|shell,json=>json|data_calc"
)
- val RUN_TYPE_SQL = "sql"
- val RUN_TYPE_PYTHON = "python"
- val RUN_TYPE_JAVA = "java"
- val RUN_TYPE_SCALA = "scala"
- val RUN_TYPE_SHELL = "shell"
+ val LANGUAGE_TYPE_SQL = "sql"
- private var codeTypeAndRunTypeRelationMap: Map[String, List[String]] = null
+ val LANGUAGE_TYPE_PYTHON = "python"
- private def codeTypeAndRunTypeRelationMapParser(configV: String):
Map[String, List[String]] = {
+ val LANGUAGE_TYPE_JAVA = "java"
+
+ val LANGUAGE_TYPE_SCALA = "scala"
+
+ val LANGUAGE_TYPE_SHELL = "shell"
+
+ val LANGUAGE_TYPE_JSON = "json"
+
+ private var codeTypeAndLanguageTypeRelationMap: Map[String, List[String]] =
null
+
+ /**
+ * Used to parse the wds.linkis.codeType.runType.relation parameter
+ * 1. Get scripting language type by "=>" 2. Get the code type by "|"
+ * @param configV
+ * @return
+ */
+ private def codeTypeAndLanguageTypeRelationMapParser(
+ configV: String
+ ): Map[String, List[String]] = {
val confDelimiter = ","
if (configV == null || "".equals(configV)) {
Map()
@@ -51,40 +68,59 @@ object CodeAndRunTypeUtils {
(confArr(0), for (x <- confArr(1).split("\\|").toList) yield
x.trim)
} else null
})
- .filter(x => x != null)
+ .filter(runTypeCodeTypes =>
+ runTypeCodeTypes != null && StringUtils.isNotBlank(
+ runTypeCodeTypes._1
+ ) && null != runTypeCodeTypes._2
+ )
.toMap
}
}
- def getCodeTypeAndRunTypeRelationMap: Map[String, List[String]] = {
- if (codeTypeAndRunTypeRelationMap == null) {
+ /**
+ * Obtain the mapping relationship between code Type and script type key:
Language Type value:
+ * list[code type]
+ * @return
+ */
+ def getCodeTypeAndLanguageTypeRelationMap: Map[String, List[String]] = {
+ if (codeTypeAndLanguageTypeRelationMap == null) {
CONF_LOCK.synchronized {
- if (codeTypeAndRunTypeRelationMap == null) {
- codeTypeAndRunTypeRelationMap =
-
codeTypeAndRunTypeRelationMapParser(CODE_TYPE_AND_RUN_TYPE_RELATION.getValue)
+ if (codeTypeAndLanguageTypeRelationMap == null) {
+ codeTypeAndLanguageTypeRelationMap =
+
codeTypeAndLanguageTypeRelationMapParser(CODE_TYPE_AND_RUN_TYPE_RELATION.getValue)
}
}
}
- codeTypeAndRunTypeRelationMap
+ codeTypeAndLanguageTypeRelationMap
}
- def getRunTypeAndCodeTypeRelationMap: Map[String, String] = {
- val codeTypeAndRunTypeRelationMap = getCodeTypeAndRunTypeRelationMap
+ /**
+ * Obtain the Map of script type and CodeType key: script type value:
Language Type
+ * @return
+ */
+ def getLanguageTypeAndCodeTypeRelationMap: Map[String, String] = {
+ val codeTypeAndRunTypeRelationMap = getCodeTypeAndLanguageTypeRelationMap
if (codeTypeAndRunTypeRelationMap.isEmpty) Map()
else codeTypeAndRunTypeRelationMap.flatMap(x => x._2.map(y => (y, x._1)))
}
- def getRunTypeByCodeType(codeType: String, defaultRunType: String = ""):
String = {
+ def getLanguageTypeByCodeType(codeType: String, defaultLanguageType: String
= ""): String = {
if (StringUtils.isBlank(codeType)) {
return ""
}
- getRunTypeAndCodeTypeRelationMap.getOrElse(codeType, defaultRunType)
+ getLanguageTypeAndCodeTypeRelationMap.getOrElse(codeType,
defaultLanguageType)
}
- def getSuffixBelongToRunTypeOrNot(suffix: String, runType: String): Boolean
= {
- val codeTypeAndRunTypeRelationMap = getCodeTypeAndRunTypeRelationMap
+ /**
+ * Determine whether the corresponding file suffix is the corresponding
Language type
+ * @param suffix
+ * @param languageType
+ * @return
+ */
+ def getSuffixBelongToLanguageTypeOrNot(suffix: String, languageType:
String): Boolean = {
+ val codeTypeAndRunTypeRelationMap = getCodeTypeAndLanguageTypeRelationMap
if (codeTypeAndRunTypeRelationMap.isEmpty) return false
- val suffixListOfRunType = codeTypeAndRunTypeRelationMap.getOrElse(runType,
List())
+ val suffixListOfRunType =
codeTypeAndRunTypeRelationMap.getOrElse(languageType, List())
if (suffixListOfRunType.isEmpty) return false
if (suffixListOfRunType.contains(suffix)) return true
false
diff --git
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
index 762609dc6..30bdeb4b1 100644
---
a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
+++
b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
@@ -88,23 +88,16 @@ object VariableUtils extends Logging {
parserDate(codeOperation, run_date)
}
- def replace(code: String, runtType: String, variables: util.Map[String,
String]): String = {
- val codeTypeAndRunTypeRelationMap =
CodeAndRunTypeUtils.getCodeTypeAndRunTypeRelationMap
- if (codeTypeAndRunTypeRelationMap.isEmpty) {
+ def replace(code: String, codeType: String, variables: util.Map[String,
String]): String = {
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
+ if (StringUtils.isBlank(languageType)) {
return code
}
- val allowedRunTypeMap: Map[String, String] =
- CodeAndRunTypeUtils.getRunTypeAndCodeTypeRelationMap
- val codeType = allowedRunTypeMap.getOrElse(runtType, null)
- if (codeType == null) {
- return code
- }
-
var run_date: CustomDateType = null
val nameAndType = mutable.Map[String, variable.VariableType]()
- val nameAndValue: mutable.Map[String, String] = getCustomVar(code,
codeType)
+ val nameAndValue: mutable.Map[String, String] = getCustomVar(code,
languageType)
def putNameAndType(data: mutable.Map[String, String]): Unit = if (null !=
data) data foreach {
case (key, value) =>
@@ -348,23 +341,26 @@ object VariableUtils extends Logging {
* :SQL,PYTHON
* @return
*/
- def getCustomVar(code: String, codeType: String): mutable.Map[String,
String] = {
+ def getCustomVar(code: String, languageType: String): mutable.Map[String,
String] = {
val nameAndValue = mutable.Map[String, String]()
var varString: String = null
var errString: String = null
- codeType match {
- case CodeAndRunTypeUtils.RUN_TYPE_SQL =>
+ languageType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL =>
varString = """\s*--@set\s*.+\s*"""
errString = """\s*--@.*"""
- case CodeAndRunTypeUtils.RUN_TYPE_PYTHON |
CodeAndRunTypeUtils.RUN_TYPE_SHELL =>
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_PYTHON |
CodeAndRunTypeUtils.LANGUAGE_TYPE_SHELL =>
varString = """\s*#@set\s*.+\s*"""
errString = """\s*#@"""
- case CodeAndRunTypeUtils.RUN_TYPE_SCALA =>
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA =>
varString = """\s*//@set\s*.+\s*"""
errString = """\s*//@.+"""
- case CodeAndRunTypeUtils.RUN_TYPE_JAVA => varString =
"""\s*!!@set\s*.+\s*"""
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_JAVA =>
+ varString = """\s*!!@set\s*.+\s*"""
+ case _ =>
+ return nameAndValue
}
val customRegex = varString.r.unanchored
diff --git
a/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtilsTest.scala
b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtilsTest.scala
index d62c85292..32ce3b37b 100644
---
a/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtilsTest.scala
+++
b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/CodeAndRunTypeUtilsTest.scala
@@ -25,7 +25,7 @@ class CodeAndRunTypeUtilsTest {
@Test
def testGetCodeTypeAndRunTypeRelationMap(): Unit = {
- val codeTypeAndRunTypeRelationMap =
CodeAndRunTypeUtils.getCodeTypeAndRunTypeRelationMap
+ val codeTypeAndRunTypeRelationMap =
CodeAndRunTypeUtils.getCodeTypeAndLanguageTypeRelationMap
assertTrue(codeTypeAndRunTypeRelationMap.nonEmpty)
assertTrue(codeTypeAndRunTypeRelationMap.keySet.contains("sql"))
assertEquals(3, codeTypeAndRunTypeRelationMap("python").size)
@@ -33,35 +33,50 @@ class CodeAndRunTypeUtilsTest {
@Test
def testGetRunTypeAndCodeTypeRelationMap(): Unit = {
- val runTypeAndCodeTypeRelationMap =
CodeAndRunTypeUtils.getRunTypeAndCodeTypeRelationMap
+ val runTypeAndCodeTypeRelationMap =
CodeAndRunTypeUtils.getLanguageTypeAndCodeTypeRelationMap
assertTrue(runTypeAndCodeTypeRelationMap.nonEmpty)
-
assertTrue(CodeAndRunTypeUtils.RUN_TYPE_SHELL.equals(runTypeAndCodeTypeRelationMap("sh")))
-
assertTrue(CodeAndRunTypeUtils.RUN_TYPE_SQL.equals(runTypeAndCodeTypeRelationMap("psql")))
+
assertTrue(CodeAndRunTypeUtils.LANGUAGE_TYPE_SHELL.equals(runTypeAndCodeTypeRelationMap("sh")))
+
assertTrue(CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL.equals(runTypeAndCodeTypeRelationMap("psql")))
}
@Test
def testGetRunTypeByCodeType(): Unit = {
val codeType = "psql"
- val runType = CodeAndRunTypeUtils.getRunTypeByCodeType(codeType)
- assertTrue(CodeAndRunTypeUtils.RUN_TYPE_SQL.equals(runType))
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
+ assertTrue(CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL.equals(languageType))
}
@Test
def testGetSuffixBelongToRunTypeOrNot(): Unit = {
val shell =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot("sh",
CodeAndRunTypeUtils.RUN_TYPE_SHELL)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ "sh",
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SHELL
+ )
assertTrue(shell)
val sql =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot("jdbc",
CodeAndRunTypeUtils.RUN_TYPE_SQL)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ "jdbc",
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL
+ )
assertTrue(sql)
val hql =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot("hql",
CodeAndRunTypeUtils.RUN_TYPE_SQL)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ "hql",
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL
+ )
assertTrue(hql)
val python =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot("py",
CodeAndRunTypeUtils.RUN_TYPE_PYTHON)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ "py",
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_PYTHON
+ )
assertTrue(python)
val scala =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot("java",
CodeAndRunTypeUtils.RUN_TYPE_SCALA)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ "java",
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA
+ )
assertTrue(!scala)
}
diff --git
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/PYScriptCompaction.scala
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/PYScriptCompaction.scala
index 55c1877be..a8e72a2d8 100644
---
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/PYScriptCompaction.scala
+++
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/PYScriptCompaction.scala
@@ -22,7 +22,10 @@ import org.apache.linkis.common.utils.CodeAndRunTypeUtils
class PYScriptCompaction private extends CommonScriptCompaction {
override def belongTo(suffix: String): Boolean =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(suffix,
CodeAndRunTypeUtils.RUN_TYPE_PYTHON)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ suffix,
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_PYTHON
+ )
override def prefix: String = "#@set"
diff --git
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/QLScriptCompaction.scala
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/QLScriptCompaction.scala
index cb8dfb2bd..7e420f891 100644
---
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/QLScriptCompaction.scala
+++
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/QLScriptCompaction.scala
@@ -22,7 +22,10 @@ import org.apache.linkis.common.utils.CodeAndRunTypeUtils
class QLScriptCompaction private extends CommonScriptCompaction {
override def belongTo(suffix: String): Boolean =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(suffix,
CodeAndRunTypeUtils.RUN_TYPE_SQL)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ suffix,
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL
+ )
override def prefix: String = "--@set"
diff --git
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/ScalaScriptCompaction.scala
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/ScalaScriptCompaction.scala
index 691a38d23..c75c5a32a 100644
---
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/ScalaScriptCompaction.scala
+++
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/ScalaScriptCompaction.scala
@@ -23,7 +23,10 @@ class ScalaScriptCompaction private extends
CommonScriptCompaction {
override def prefix: String = "//@set"
override def belongTo(suffix: String): Boolean =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(suffix,
CodeAndRunTypeUtils.RUN_TYPE_SCALA)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ suffix,
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA
+ )
override def prefixConf: String = "//conf@set"
}
diff --git
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/ShellScriptCompaction.scala
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/ShellScriptCompaction.scala
index 7c449ccc8..7a0558003 100644
---
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/ShellScriptCompaction.scala
+++
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/compaction/ShellScriptCompaction.scala
@@ -25,7 +25,10 @@ class ShellScriptCompaction private extends
CommonScriptCompaction {
override def prefix: String = "#@set"
override def belongTo(suffix: String): Boolean =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(suffix,
CodeAndRunTypeUtils.RUN_TYPE_SHELL)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ suffix,
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SHELL
+ )
}
diff --git
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/PYScriptParser.scala
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/PYScriptParser.scala
index 5ef8381d5..027b63214 100644
---
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/PYScriptParser.scala
+++
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/PYScriptParser.scala
@@ -23,7 +23,10 @@ class PYScriptParser private extends CommonScriptParser {
override def prefix: String = "#@set"
override def belongTo(suffix: String): Boolean =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(suffix,
CodeAndRunTypeUtils.RUN_TYPE_PYTHON)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ suffix,
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_PYTHON
+ )
override def prefixConf: String = "#conf@set"
}
diff --git
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/QLScriptParser.scala
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/QLScriptParser.scala
index 36bbb3a10..a089f9c36 100644
---
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/QLScriptParser.scala
+++
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/QLScriptParser.scala
@@ -23,7 +23,10 @@ class QLScriptParser private extends CommonScriptParser {
override def prefix: String = "--@set"
override def belongTo(suffix: String): Boolean =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(suffix,
CodeAndRunTypeUtils.RUN_TYPE_SQL)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ suffix,
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL
+ )
override def prefixConf: String = "--conf@set"
}
diff --git
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/ScalaScriptParser.scala
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/ScalaScriptParser.scala
index d0cbc770b..e6729326e 100644
---
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/ScalaScriptParser.scala
+++
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/ScalaScriptParser.scala
@@ -24,7 +24,10 @@ class ScalaScriptParser private extends CommonScriptParser {
override def prefix: String = "//@set"
override def belongTo(suffix: String): Boolean =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(suffix,
CodeAndRunTypeUtils.RUN_TYPE_SCALA)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ suffix,
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA
+ )
override def prefixConf: String = "//conf@set"
}
diff --git
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/ShellScriptParser.scala
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/ShellScriptParser.scala
index f32ad7498..9b3e385ff 100644
---
a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/ShellScriptParser.scala
+++
b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/script/parser/ShellScriptParser.scala
@@ -23,7 +23,10 @@ class ShellScriptParser private extends CommonScriptParser {
override def prefix: String = "#@set"
override def belongTo(suffix: String): Boolean =
- CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(suffix,
CodeAndRunTypeUtils.RUN_TYPE_SHELL)
+ CodeAndRunTypeUtils.getSuffixBelongToLanguageTypeOrNot(
+ suffix,
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SHELL
+ )
override def prefixConf: String = "#conf@set"
}
diff --git
a/linkis-computation-governance/linkis-computation-governance-common/src/main/scala/org/apache/linkis/governance/common/paser/CodeParser.scala
b/linkis-computation-governance/linkis-computation-governance-common/src/main/scala/org/apache/linkis/governance/common/paser/CodeParser.scala
index 92623ad7c..19bd7f9cd 100644
---
a/linkis-computation-governance/linkis-computation-governance-common/src/main/scala/org/apache/linkis/governance/common/paser/CodeParser.scala
+++
b/linkis-computation-governance/linkis-computation-governance-common/src/main/scala/org/apache/linkis/governance/common/paser/CodeParser.scala
@@ -335,22 +335,15 @@ object CodeType extends Enumeration {
val Python, SQL, Scala, Shell, Other, Remain, JSON = Value
def getType(codeType: String): CodeType = {
- val runTypeAndCodeTypeRelationMap: Map[String, String] =
- CodeAndRunTypeUtils.getRunTypeAndCodeTypeRelationMap
- if (
- runTypeAndCodeTypeRelationMap.isEmpty ||
!runTypeAndCodeTypeRelationMap.contains(
- codeType.toLowerCase(Locale.getDefault)
- )
- ) {
- return Other
- }
-
- val runType =
runTypeAndCodeTypeRelationMap(codeType.toLowerCase(Locale.getDefault))
- runType match {
- case CodeAndRunTypeUtils.RUN_TYPE_PYTHON => Python
- case CodeAndRunTypeUtils.RUN_TYPE_SQL => SQL
- case CodeAndRunTypeUtils.RUN_TYPE_SCALA => Scala
- case CodeAndRunTypeUtils.RUN_TYPE_SHELL => Shell
+ val languageTypeType =
CodeAndRunTypeUtils.getLanguageTypeAndCodeTypeRelationMap(
+ codeType.toLowerCase(Locale.getDefault)
+ )
+ languageTypeType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_PYTHON => Python
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL => SQL
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA => Scala
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SHELL => Shell
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_JSON => JSON
case _ => Other
}
}
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/parser/AbstractEntranceParser.java
b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/parser/AbstractEntranceParser.java
index 10f80360c..dd80bc8e8 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/parser/AbstractEntranceParser.java
+++
b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/parser/AbstractEntranceParser.java
@@ -19,16 +19,12 @@ package org.apache.linkis.entrance.parser;
import org.apache.linkis.entrance.EntranceContext;
import org.apache.linkis.entrance.EntranceParser;
-import org.apache.linkis.entrance.conf.EntranceConfiguration;
import org.apache.linkis.entrance.exception.EntranceErrorCode;
import org.apache.linkis.entrance.exception.EntranceIllegalParamException;
import org.apache.linkis.entrance.execute.EntranceJob;
import org.apache.linkis.entrance.job.EntranceExecutionJob;
import org.apache.linkis.entrance.persistence.PersistenceManager;
import org.apache.linkis.governance.common.entity.job.JobRequest;
-import org.apache.linkis.governance.common.paser.CodeParser;
-import org.apache.linkis.governance.common.paser.CodeParserFactory;
-import org.apache.linkis.governance.common.paser.CodeType;
import org.apache.linkis.governance.common.paser.EmptyCodeParser;
import org.apache.linkis.governance.common.utils.GovernanceConstant;
import org.apache.linkis.manager.label.constant.LabelKeyConstant;
@@ -143,24 +139,7 @@ public abstract class AbstractEntranceParser extends
EntranceParser {
job.setListenerEventBus(null);
job.setProgress(0f);
job.setJobRequest(jobReq);
- Label<?> codeTypeLabel =
- jobReq.getLabels().stream()
- .filter(l ->
l.getLabelKey().equalsIgnoreCase(LabelKeyConstant.CODE_TYPE_KEY))
- .findFirst()
- .orElse(null);
- if (null != codeTypeLabel) {
- CodeParser codeParser =
-
CodeParserFactory.getCodeParser(CodeType.getType(codeTypeLabel.getStringValue()));
- if (null != codeParser && !isNoNeedParser()) {
- job.setCodeParser(codeParser);
- } else {
- job.setCodeParser(new EmptyCodeParser());
- }
- }
+ job.setCodeParser(new EmptyCodeParser());
return job;
}
-
- private boolean isNoNeedParser() {
- return !EntranceConfiguration.ENTRANCE_CODEPARSER_ENABLE().getValue();
- }
}
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
index 07a8475af..4b6230299 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
@@ -201,9 +201,6 @@ object EntranceConfiguration {
val CODE_PARSER_SELECTIVE_IGNORED =
CommonVars[java.lang.Boolean]("wds.linkis.entrance.code.parser.selective.ignored",
true)
- val ENTRANCE_CODEPARSER_ENABLE =
- CommonVars[java.lang.Boolean]("wds.linkis.entrance.code.parser.enable",
false)
-
val YARN_QUEUE_CORES_MAX =
CommonVars[Integer]("wds.linkis.entrance.yarn.queue.core.max", 300)
val YARN_QUEUE_MEMORY_MAX =
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/RuntypeInterceptor.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/RuntypeInterceptor.scala
index 021f2aa43..0657eb62f 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/RuntypeInterceptor.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/RuntypeInterceptor.scala
@@ -28,17 +28,17 @@ class RuntypeInterceptor extends EntranceInterceptor with
Logging {
override def apply(task: JobRequest, logAppender: java.lang.StringBuilder):
JobRequest = {
val codeType = LabelUtil.getCodeType(task.getLabels)
- val runType = CodeAndRunTypeUtils.getRunTypeByCodeType(codeType)
- runType match {
- case CodeAndRunTypeUtils.RUN_TYPE_PYTHON =>
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
+ languageType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_PYTHON =>
val code = task.getExecutionCode
task.setExecutionCode("%python\n" + code)
task
- case CodeAndRunTypeUtils.RUN_TYPE_SQL =>
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL =>
val code = task.getExecutionCode
task.setExecutionCode("%sql\n" + code)
task
- case CodeAndRunTypeUtils.RUN_TYPE_SCALA =>
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA =>
val code = task.getExecutionCode
task.setExecutionCode("%scala\n" + code)
task
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala
index da751a4bb..bbb904c6a 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala
@@ -44,15 +44,15 @@ class CommentInterceptor extends EntranceInterceptor {
*/
override def apply(task: JobRequest, logAppender: lang.StringBuilder):
JobRequest = {
val codeType = LabelUtil.getCodeType(task.getLabels)
- val runType = CodeAndRunTypeUtils.getRunTypeByCodeType(codeType)
- runType match {
- case CodeAndRunTypeUtils.RUN_TYPE_SQL =>
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
+ languageType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL =>
task.setExecutionCode(SQLCommentHelper.dealComment(task.getExecutionCode))
- case CodeAndRunTypeUtils.RUN_TYPE_PYTHON =>
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_PYTHON =>
task.setExecutionCode(PythonCommentHelper.dealComment(task.getExecutionCode))
- case CodeAndRunTypeUtils.RUN_TYPE_SCALA |
CodeAndRunTypeUtils.RUN_TYPE_JAVA =>
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA |
CodeAndRunTypeUtils.LANGUAGE_TYPE_JAVA =>
task.setExecutionCode(ScalaCommentHelper.dealComment(task.getExecutionCode))
- case CodeAndRunTypeUtils.RUN_TYPE_SHELL =>
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SHELL =>
case _ =>
}
task
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/Explain.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/Explain.scala
index c16c1a7dd..1279155ee 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/Explain.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/Explain.scala
@@ -103,10 +103,7 @@ object SQLExplain extends Explain {
private val LOG: Logger = LoggerFactory.getLogger(getClass)
override def authPass(code: String, error: StringBuilder): Boolean = {
- if (code.trim.matches(CREATE_DATABASE_SQL)) {
- error.append("Sorry, you have no permission to create database")
- false
- } else true
+ true
}
/**
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/PythonCodeCheckInterceptor.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/PythonCodeCheckInterceptor.scala
index 163d646df..5f2c730c1 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/PythonCodeCheckInterceptor.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/PythonCodeCheckInterceptor.scala
@@ -33,10 +33,10 @@ class PythonCodeCheckInterceptor extends
EntranceInterceptor with Logging {
override def apply(jobRequest: JobRequest, logAppender:
java.lang.StringBuilder): JobRequest = {
val codeType = LabelUtil.getCodeType(jobRequest.getLabels)
- val runType = CodeAndRunTypeUtils.getRunTypeByCodeType(codeType)
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
val errorBuilder = new StringBuilder
- runType match {
- case CodeAndRunTypeUtils.RUN_TYPE_PYTHON =>
+ languageType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_PYTHON =>
Utils.tryThrow {
if (PythonExplain.authPass(jobRequest.getExecutionCode,
errorBuilder)) {
jobRequest
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SQLCodeCheckInterceptor.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SQLCodeCheckInterceptor.scala
index a27d288ab..0bc83de3a 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SQLCodeCheckInterceptor.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SQLCodeCheckInterceptor.scala
@@ -26,10 +26,10 @@ import org.apache.linkis.manager.label.utils.LabelUtil
class SQLCodeCheckInterceptor extends EntranceInterceptor {
override def apply(jobRequest: JobRequest, logAppender:
java.lang.StringBuilder): JobRequest = {
- val engineType = LabelUtil.getEngineType(jobRequest.getLabels)
- val runType =
CodeAndRunTypeUtils.getRunTypeByCodeType(engineType.toLowerCase())
- runType match {
- case CodeAndRunTypeUtils.RUN_TYPE_SQL =>
+ val engineType = LabelUtil.getCodeType(jobRequest.getLabels)
+ val languageType =
CodeAndRunTypeUtils.getLanguageTypeByCodeType(engineType.toLowerCase())
+ languageType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL =>
val sb: StringBuilder = new StringBuilder
val isAuth: Boolean = SQLExplain.authPass(jobRequest.getExecutionCode,
sb)
if (!isAuth) {
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SQLLimitEntranceInterceptor.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SQLLimitEntranceInterceptor.scala
index 2e9b76c78..2abc43af3 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SQLLimitEntranceInterceptor.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SQLLimitEntranceInterceptor.scala
@@ -43,11 +43,11 @@ class SQLLimitEntranceInterceptor extends
EntranceInterceptor {
""
}
}
- val runType = CodeAndRunTypeUtils.getRunTypeByCodeType(codeType)
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
task match {
case jobRequest: JobRequest =>
- runType match {
- case CodeAndRunTypeUtils.RUN_TYPE_SQL =>
+ languageType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SQL =>
val executionCode = jobRequest.getExecutionCode
SQLExplain.dealSQLLimit(executionCode, jobRequest, logAppender)
case _ =>
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ScalaCodeInterceptor.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ScalaCodeInterceptor.scala
index d02e24281..138dd10a8 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ScalaCodeInterceptor.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ScalaCodeInterceptor.scala
@@ -29,10 +29,10 @@ class ScalaCodeInterceptor extends EntranceInterceptor {
override def apply(jobRequest: JobRequest, logAppender: lang.StringBuilder):
JobRequest = {
val codeType = LabelUtil.getCodeType(jobRequest.getLabels)
- val runType = CodeAndRunTypeUtils.getRunTypeByCodeType(codeType)
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
val errorBuilder = new StringBuilder("")
- runType match {
- case CodeAndRunTypeUtils.RUN_TYPE_SCALA =>
+ languageType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA =>
Utils.tryThrow(ScalaExplain.authPass(jobRequest.getExecutionCode,
errorBuilder)) {
case ScalaCodeCheckException(errorCode, errDesc) =>
jobRequest.setErrorCode(errorCode)
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ShellDangerousGrammerInterceptor.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ShellDangerousGrammerInterceptor.scala
index f7ab469c2..ad86f9aed 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ShellDangerousGrammerInterceptor.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ShellDangerousGrammerInterceptor.scala
@@ -17,13 +17,12 @@
package org.apache.linkis.entrance.interceptor.impl
-import org.apache.linkis.common.utils.Logging
+import org.apache.linkis.common.utils.{CodeAndRunTypeUtils, Logging}
import org.apache.linkis.entrance.conf.EntranceConfiguration
import org.apache.linkis.entrance.errorcode.EntranceErrorCodeSummary._
import org.apache.linkis.entrance.exception.DangerousGramsCheckException
import org.apache.linkis.entrance.interceptor.EntranceInterceptor
import org.apache.linkis.governance.common.entity.job.JobRequest
-import org.apache.linkis.governance.common.paser.CodeType
import org.apache.linkis.manager.label.entity.engine.EngineType
import org.apache.linkis.manager.label.utils.LabelUtil
@@ -85,23 +84,20 @@ class ShellDangerousGrammerInterceptor extends
EntranceInterceptor with Logging
}
/**
- * The apply function is to supplement the information of the incoming
parameter task, making the
- * content of this task more complete. * Additional information includes:
database information
- * supplement, custom variable substitution, code check, limit limit, etc.
- * apply函数是对传入参数task进行信息的补充,使得这个task的内容更加完整。 补充的信息包括:
数据库信息补充、自定义变量替换、代码检查、limit限制等
- *
+ * Shell dangerous syntax judgment
* @param jobRequest
* @param logAppender
- * Used to cache the necessary reminder logs and pass them to the upper
layer(用于缓存必要的提醒日志,传给上层)
+ *
* @return
*/
override def apply(jobRequest: JobRequest, logAppender: lang.StringBuilder):
JobRequest = {
if (!shellDangerousGrammerCheckSwitch) return jobRequest
val codeType = LabelUtil.getCodeType(jobRequest.getLabels)
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
val engineType = LabelUtil.getEngineType(jobRequest.getLabels)
if (
- CodeType.Shell.equals(CodeType.getType(codeType)) ||
EngineType.SHELL.equals(
+ CodeAndRunTypeUtils.LANGUAGE_TYPE_SHELL.equals(languageType) ||
EngineType.SHELL.equals(
EngineType.mapStringToEngineType(engineType)
)
) {
diff --git
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SparkCodeCheckInterceptor.scala
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SparkCodeCheckInterceptor.scala
index cb2756259..434066000 100644
---
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SparkCodeCheckInterceptor.scala
+++
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/SparkCodeCheckInterceptor.scala
@@ -27,9 +27,9 @@ class SparkCodeCheckInterceptor extends EntranceInterceptor {
override def apply(jobRequest: JobRequest, logAppender:
java.lang.StringBuilder): JobRequest = {
val codeType = LabelUtil.getCodeType(jobRequest.getLabels)
- val runType = CodeAndRunTypeUtils.getRunTypeByCodeType(codeType)
- runType match {
- case CodeAndRunTypeUtils.RUN_TYPE_SCALA =>
+ val languageType = CodeAndRunTypeUtils.getLanguageTypeByCodeType(codeType)
+ languageType match {
+ case CodeAndRunTypeUtils.LANGUAGE_TYPE_SCALA =>
val codeBuilder: StringBuilder = new StringBuilder()
val isAuth = SparkExplain.authPass(jobRequest.getExecutionCode,
codeBuilder)
if (!isAuth) {
diff --git
a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/args/SparkScalaPreExecutionHook.scala
b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/args/SparkScalaPreExecutionHook.scala
index cab5a0955..c6be24db6 100644
---
a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/args/SparkScalaPreExecutionHook.scala
+++
b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/args/SparkScalaPreExecutionHook.scala
@@ -22,8 +22,6 @@ import
org.apache.linkis.engineconn.computation.executor.execute.EngineExecution
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.apache.commons.lang3.StringUtils
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/cache/impl/DefaultQueryCacheManager.java
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/cache/impl/DefaultQueryCacheManager.java
index 583d5b77f..c83d730b8 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/cache/impl/DefaultQueryCacheManager.java
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/cache/impl/DefaultQueryCacheManager.java
@@ -64,11 +64,17 @@ public class DefaultQueryCacheManager implements
QueryCacheManager, Initializing
@PostConstruct
private void init() {
- try {
- refreshUndoneTask();
- } catch (Exception e) {
- logger.info("Failed to init refresh undone task", e);
- }
+ Thread undoneTask =
+ new Thread(
+ () -> {
+ try {
+ refreshUndoneTask();
+ } catch (Exception e) {
+ logger.info("Failed to init refresh undone task", e);
+ }
+ });
+ undoneTask.setName("refreshUndoneTask");
+ undoneTask.start();
}
@Override
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/QueryTaskVO.java
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/QueryTaskVO.java
index f0a88de78..e50445603 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/QueryTaskVO.java
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/QueryTaskVO.java
@@ -27,7 +27,10 @@ public class QueryTaskVO {
private Long taskID;
private String instance;
private String execId;
+ /** submit User* */
private String umUser;
+
+ private String executeUser;
private String engineInstance;
private String executionCode;
private String progress;
@@ -272,4 +275,12 @@ public class QueryTaskVO {
public void setCanRetry(boolean canRetry) {
this.canRetry = canRetry;
}
+
+ public String getExecuteUser() {
+ return executeUser;
+ }
+
+ public void setExecuteUser(String executeUser) {
+ this.executeUser = executeUser;
+ }
}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conversions/TaskConversions.scala
b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conversions/TaskConversions.scala
index d9ad12f44..82d7d8612 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conversions/TaskConversions.scala
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conversions/TaskConversions.scala
@@ -57,54 +57,6 @@ object TaskConversions extends Logging {
task
}
- /* @deprecated
- def queryTask2RequestPersistTask(queryTask: QueryTask): RequestPersistTask =
{
- QueryUtils.exchangeExecutionCode(queryTask)
- val task = new RequestPersistTask
- BeanUtils.copyProperties(queryTask, task)
- task.setSource(BDPJettyServerHelper.gson.fromJson(queryTask.getSourceJson,
classOf[java.util.HashMap[String, String]]))
- task.setParams(BDPJettyServerHelper.gson.fromJson(queryTask.getParamsJson,
classOf[java.util.HashMap[String, Object]]))
- task
- } */
-
- /* @deprecated
- def requestPersistTaskTask2QueryTask(requestPersistTask:
RequestPersistTask): QueryTask = {
- val task: QueryTask = new QueryTask
- BeanUtils.copyProperties(requestPersistTask, task)
- if (requestPersistTask.getParams != null)
-
task.setParamsJson(BDPJettyServerHelper.gson.toJson(requestPersistTask.getParams))
- else
- task.setParamsJson(null)
- task
- } */
-
- /* def queryTask2QueryTaskVO(queryTask: QueryTask): QueryTaskVO = {
- QueryUtils.exchangeExecutionCode(queryTask)
- val taskVO = new QueryTaskVO
- BeanUtils.copyProperties(queryTask, taskVO)
- if (!StringUtils.isEmpty(taskVO.getSourceJson)) {
- Utils.tryCatch {
- val source = BDPJettyServerHelper.gson.fromJson(taskVO.getSourceJson,
classOf[util.Map[String, String]])
- taskVO.setSourceTailor(source.asScala.map(_._2).foldLeft("")(_ + _ +
"-").stripSuffix("-"))
- } {
- case _ => warn("sourceJson deserializae failed,this task may be the
old data")
- }
- }
- if (queryTask.getExecId() != null && queryTask.getExecuteApplicationName()
!= null && queryTask.getInstance() != null) {
-
taskVO.setStrongerExecId(ZuulEntranceUtils.generateExecID(queryTask.getExecId(),
- queryTask.getExecuteApplicationName(), queryTask.getInstance(),
queryTask.getRequestApplicationName))
- }
- val status = queryTask.getStatus()
- val createdTime = queryTask.getCreatedTime()
- val updatedTime = queryTask.getUpdatedTime()
- if (isJobFinished(status) && createdTime != null && updatedTime != null) {
- taskVO.setCostTime(queryTask.getUpdatedTime().getTime() -
queryTask.getCreatedTime().getTime());
- } else if (createdTime != null) {
- taskVO.setCostTime(System.currentTimeMillis() -
queryTask.getCreatedTime().getTime());
- }
- taskVO
- } */
-
def isJobFinished(status: String): Boolean = {
TaskStatus.Succeed.toString.equals(status) ||
TaskStatus.Failed.toString.equals(status) ||
@@ -247,7 +199,7 @@ object TaskConversions extends Logging {
taskVO.setInstance(job.getInstances)
taskVO.setExecId(job.getJobReqId)
taskVO.setUmUser(job.getSubmitUser)
-
+ taskVO.setExecuteUser(job.getExecuteUser)
taskVO.setProgress(job.getProgress)
taskVO.setLogPath(job.getLogPath)
taskVO.setStatus(job.getStatus)
@@ -263,7 +215,7 @@ object TaskConversions extends Logging {
engineType = LabelUtil.getEngineType(labelList)
}
codeType = LabelUtil.getCodeType(labelList)
- val userCreator =
Option(LabelUtil.getUserCreator(labelList)).getOrElse(null)
+ val userCreator = Option(LabelUtil.getUserCreator(labelList)).orNull
if (null != userCreator) {
creator = userCreator._2
}
@@ -323,7 +275,7 @@ object TaskConversions extends Logging {
val entranceName = JobhistoryConfiguration.ENTRANCE_SPRING_NAME.getValue
val instances =
-
job.getInstances().split(JobhistoryConfiguration.ENTRANCE_INSTANCE_DELEMITER.getValue)
+
job.getInstances.split(JobhistoryConfiguration.ENTRANCE_INSTANCE_DELEMITER.getValue)
taskVO.setStrongerExecId(
ZuulEntranceUtils.generateExecID(job.getJobReqId, entranceName,
instances)
)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]