Skip to content

Commit

Permalink
Optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengJie1053 committed Oct 24, 2023
1 parent 524117b commit 913c270
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class AMConfiguration {
public static final CommonVars<String> 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<String> ALLOW_BATCH_KILL_ENGINE_TYPES =
CommonVars.apply("wds.linkis.allow.batch.kill.engine.types", "spark,hive,python");
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class LabelCommonConfig {
CommonVars.apply("wds.linkis.python.engine.version", "python2");

public static final CommonVars<String> REPL_ENGINE_VERSION =
CommonVars.apply("wds.linkis.repl.engine.version", "1");
CommonVars.apply("linkis.repl.engine.version", "1");

public static final CommonVars<String> FILE_ENGINE_VERSION =
CommonVars.apply("wds.linkis.file.engine.version", "1.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
8 changes: 3 additions & 5 deletions linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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":{
Expand Down Expand Up @@ -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
```

3 changes: 0 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@
<sqoop.version>1.4.6</sqoop.version>
<elasticsearch.version>7.6.2</elasticsearch.version>

<!-- javassist -->
<javassist.version>3.28.0-GA</javassist.version>

<!-- This is the same as the kubernetes-client version referenced in spark3.2.1 -->
<kubernetes-client.version>5.4.1</kubernetes-client.version>

Expand Down

0 comments on commit 913c270

Please sign in to comment.