From 913c2703aa85d763891568436597a7c497f513e2 Mon Sep 17 00:00:00 2001 From: ChengJie1053 <18033291053@163.com> Date: Tue, 24 Oct 2023 21:05:49 +0800 Subject: [PATCH] Optimized code --- .../manager/am/conf/AMConfiguration.java | 6 ++--- .../manager/label/conf/LabelCommonConfig.java | 2 +- .../repl/executor/ReplEngineConnExecutor.java | 24 ++++++++----------- .../repl/src/main/resources/repl-ec.md | 8 +++---- pom.xml | 3 --- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/conf/AMConfiguration.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/conf/AMConfiguration.java index 0c95cef777..0f018ca9de 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/conf/AMConfiguration.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/conf/AMConfiguration.java @@ -69,7 +69,7 @@ public class AMConfiguration { public static final CommonVars MULTI_USER_ENGINE_TYPES = CommonVars.apply( "wds.linkis.multi.user.engine.types", - "jdbc,es,presto,io_file,appconn,openlookeng,trino,nebula,hbase,repl"); + "jdbc,es,presto,io_file,appconn,openlookeng,trino,nebula,hbase"); public static final CommonVars ALLOW_BATCH_KILL_ENGINE_TYPES = CommonVars.apply("wds.linkis.allow.batch.kill.engine.types", "spark,hive,python"); @@ -105,8 +105,8 @@ public class AMConfiguration { public static String getDefaultMultiEngineUser() { String jvmUser = Utils.getJvmUser(); return String.format( - "{jdbc:\"%s\", es: \"%s\", presto:\"%s\", appconn:\"%s\", openlookeng:\"%s\", trino:\"%s\", nebula:\"%s\",repl:\"%s\", hbase:\"%s\",io_file:\"root\"}", - jvmUser, jvmUser, jvmUser, jvmUser, jvmUser, jvmUser, jvmUser, jvmUser, jvmUser); + "{jdbc:\"%s\", es: \"%s\", presto:\"%s\", appconn:\"%s\", openlookeng:\"%s\", trino:\"%s\", nebula:\"%s\", hbase:\"%s\",io_file:\"root\"}", + jvmUser, jvmUser, jvmUser, jvmUser, jvmUser, jvmUser, jvmUser, jvmUser); } public static boolean isMultiUserEngine(String engineType) { diff --git a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/conf/LabelCommonConfig.java b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/conf/LabelCommonConfig.java index fbb4e5d38c..89169eb58f 100644 --- a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/conf/LabelCommonConfig.java +++ b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/conf/LabelCommonConfig.java @@ -43,7 +43,7 @@ public class LabelCommonConfig { CommonVars.apply("wds.linkis.python.engine.version", "python2"); public static final CommonVars REPL_ENGINE_VERSION = - CommonVars.apply("wds.linkis.repl.engine.version", "1"); + CommonVars.apply("linkis.repl.engine.version", "1"); public static final CommonVars FILE_ENGINE_VERSION = CommonVars.apply("wds.linkis.file.engine.version", "1.0"); diff --git a/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/ReplEngineConnExecutor.java b/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/ReplEngineConnExecutor.java index f18714132c..bf7201cb61 100644 --- a/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/ReplEngineConnExecutor.java +++ b/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/ReplEngineConnExecutor.java @@ -130,20 +130,16 @@ public ExecuteResponse executeLine(EngineExecutionContext engineExecutorContext, String methodName = ReplConfiguration.METHOD_NAME.getValue(configMap); - Thread thread = - new Thread( - () -> { - try { - replAdapter.executorCode(realCode, classpathDir, methodName); - } catch (Exception e) { - String errorMessage = ExceptionUtils.getStackTrace(e); - logger.error("Repl engine execute failed : {}", errorMessage); - engineExecutorContext.appendStdout(LogUtils.generateERROR(errorMessage)); - } - }); - - thread.start(); - threadCache.put(taskId, thread); + threadCache.put(taskId, Thread.currentThread()); + + try { + replAdapter.executorCode(realCode, classpathDir, methodName); + } catch (Exception e) { + String errorMessage = ExceptionUtils.getStackTrace(e); + logger.error("Repl engine execute failed : {}", errorMessage); + engineExecutorContext.appendStdout(LogUtils.generateERROR(errorMessage)); + } + return new SuccessExecuteResponse(); } diff --git a/linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md b/linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md index 2f41238266..5eb8c6c1b2 100644 --- a/linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md +++ b/linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md @@ -11,10 +11,6 @@ package com.linkis.javassist; import org.apache.commons.lang3.StringUtils; -/** - * @Author linkis - * @Date 2023/10/9 - */ public class Test { public void sayHello() { System.out.println("hello"); @@ -27,7 +23,7 @@ public class Test { ```json { "executionContent":{ - "code":"package com.linkis.javassist;\n\nimport org.apache.commons.lang3.StringUtils;\n\n/**\n * @Author linkis\n * @Date 2023/10/9\n */\npublic class Test {\n public void sayHello() {\n System.out.println(\"hello\");\n System.out.println(StringUtils.isEmpty(\"hello\"));\n }\n}\n", + "code":"package com.linkis.javassist;\n\nimport org.apache.commons.lang3.StringUtils;\n\npublic class Test {\n public void sayHello() {\n System.out.println(\"hello\");\n System.out.println(StringUtils.isEmpty(\"hello\"));\n }\n}\n", "runType":"repl" }, "params":{ @@ -113,5 +109,7 @@ http://www.javassist.org/tutorial/tutorial.html https://github.com/jboss-javassist/javassist https://github.com/apache/dubbo + +https://docs.scala-lang.org/overviews/scala-book/scala-repl.html ``` diff --git a/pom.xml b/pom.xml index 5b310a8773..db87cce8c3 100644 --- a/pom.xml +++ b/pom.xml @@ -139,9 +139,6 @@ 1.4.6 7.6.2 - - 3.28.0-GA - 5.4.1