Skip to content

Commit

Permalink
Fix linkis cli async exeute throw npe close #4869
Browse files Browse the repository at this point in the history
  • Loading branch information
peacewong committed Aug 22, 2023
1 parent faa8d15 commit 77472ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -116,7 +117,7 @@ public JobResult run() {
// async job, return
if (isAsync) {
return new InteractiveJobResult(
submitResult.getJobStatus().isJobSubmitted(),
jobInfoResult.getJobStatus().isJobSubmitted(),
"Async Submission Success",
new HashMap<>());
}
Expand Down Expand Up @@ -171,7 +172,14 @@ private JobResult getResult(
"Job status is not success but \'"
+ jobInfoResult.getJobStatus()
+ "\'. Will not try to retrieve any Result");
return new InteractiveJobResult(false, "Execute Error!!!", new HashMap<>());
Map<String, String> extraMap = new HashMap<>();
if (jobInfoResult.getErrCode() != null) {
extraMap.put("errorCode", String.valueOf(jobInfoResult.getErrCode()));
}
if (StringUtils.isNotBlank(jobInfoResult.getErrDesc())) {
extraMap.put("errorDesc", jobInfoResult.getErrDesc());
}
return new InteractiveJobResult(false, "Execute Error!!!", extraMap);
}
InteractiveJobResult result =
new InteractiveJobResult(true, "Execute Success!!!", new HashMap<>());
Expand Down Expand Up @@ -209,7 +217,8 @@ private LinkisOperResultAdapter waitJobComplete(String user, String jobId)
// query progress
try {
jobInfoResult = oper.queryJobInfo(user, jobId);
oper.queryJobStatus(user, jobId, jobInfoResult.getStrongerExecId());
oper.queryJobStatus(
jobInfoResult.getUser(), jobInfoResult.getJobID(), jobInfoResult.getStrongerExecId());
} catch (Exception e) {
logger.warn("", e);
retryCnt++;
Expand Down Expand Up @@ -246,6 +255,9 @@ public void onDestroy() {
logger.warn("Failed to kill job username or jobId is blank");
return;
}
if (isAsync) {
return;
}
try {
new JobKiller(oper).doKill(username, jobId);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,14 @@ public Message executeECMOperation(HttpServletRequest req, @RequestBody JsonNode
"Fail to process the operation parameters, cased by "
+ ExceptionUtils.getRootCauseMessage(e));
}
String engineConnInstance = (String) parameters.get("engineConnInstance");
return executeECMOperation(
ecmNode, engineConnInstance, new ECMOperateRequest(userName, parameters));
if (parameters.containsKey("engineConnInstance")) {
return executeECMOperation(
ecmNode,
parameters.get("engineConnInstance").toString(),
new ECMOperateRequest(userName, parameters));
} else {
return executeECMOperation(ecmNode, "", new ECMOperateRequest(userName, parameters));
}
}

@ApiOperation(value = "openEngineLog", notes = "open Engine log", response = Message.class)
Expand Down

0 comments on commit 77472ff

Please sign in to comment.