From 442fc539b96c9073623bff3eb87b38a933cbe0f5 Mon Sep 17 00:00:00 2001 From: sjgllgh Date: Tue, 26 Sep 2023 13:43:23 +0800 Subject: [PATCH] #4918 fix bug:linkis cli npe error --- .../job/interactive/InteractiveJob.java | 18 ++++++++++-------- .../operator/ujes/LinkisJobOper.java | 2 +- .../operator/ujes/UJESResultAdapter.java | 4 ++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/interactor/job/interactive/InteractiveJob.java b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/interactor/job/interactive/InteractiveJob.java index a097b1b25b..12e491c5af 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/interactor/job/interactive/InteractiveJob.java +++ b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/interactor/job/interactive/InteractiveJob.java @@ -88,17 +88,17 @@ public JobResult run() { LinkisOperResultAdapter jobInfoResult = oper.queryJobInfo(submitResult.getUser(), submitResult.getJobID()); oper.queryJobStatus( - jobInfoResult.getUser(), jobInfoResult.getJobID(), jobInfoResult.getStrongerExecId()); + submitResult.getUser(), submitResult.getJobID(), submitResult.getStrongerExecId()); infoBuilder.setLength(0); infoBuilder .append("JobId:") - .append(jobInfoResult.getJobID()) + .append(submitResult.getJobID()) .append(System.lineSeparator()) .append("TaskId:") - .append(jobInfoResult.getJobID()) + .append(submitResult.getJobID()) .append(System.lineSeparator()) .append("ExecId:") - .append(jobInfoResult.getStrongerExecId()); + .append(submitResult.getStrongerExecId()); LoggerManager.getPlaintTextLogger().info(infoBuilder.toString()); infoBuilder.setLength(0); @@ -137,7 +137,9 @@ public JobResult run() { logRetriever.retrieveLogAsync(); // wait complete - jobInfoResult = waitJobComplete(submitResult.getUser(), submitResult.getJobID()); + jobInfoResult = + waitJobComplete( + submitResult.getUser(), submitResult.getJobID(), submitResult.getStrongerExecId()); logRetriever.waitIncLogComplete(); // get result-set @@ -205,19 +207,19 @@ private JobResult getResult( return result; } - private LinkisOperResultAdapter waitJobComplete(String user, String jobId) + private LinkisOperResultAdapter waitJobComplete(String user, String jobId, String execId) throws LinkisClientRuntimeException { int retryCnt = 0; final int MAX_RETRY = 30; LinkisOperResultAdapter jobInfoResult = oper.queryJobInfo(user, jobId); - oper.queryJobStatus(user, jobId, jobInfoResult.getStrongerExecId()); + oper.queryJobStatus(user, jobId, execId); while (!jobInfoResult.getJobStatus().isJobFinishedState()) { // query progress try { jobInfoResult = oper.queryJobInfo(user, jobId); - oper.queryJobStatus(user, jobId, jobInfoResult.getStrongerExecId()); + oper.queryJobStatus(user, jobId, execId); } catch (Exception e) { logger.warn("", e); retryCnt++; diff --git a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/operator/ujes/LinkisJobOper.java b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/operator/ujes/LinkisJobOper.java index c4f7a3aadc..f696c86740 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/operator/ujes/LinkisJobOper.java +++ b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/operator/ujes/LinkisJobOper.java @@ -127,7 +127,7 @@ public LinkisOperResultAdapter submit(InteractiveJobDesc jobDesc) // jobExecuteResult = client.execute(jobExecuteAction); jobSubmitResult = client.submit(jobSubmitAction); - logger.info("Response info from Linkis: \n{}", CliUtils.GSON.toJson(jobSubmitAction)); + logger.info("Response info from Linkis: \n{}", CliUtils.GSON.toJson(jobSubmitResult)); } catch (Exception e) { // must throw if exception diff --git a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/operator/ujes/UJESResultAdapter.java b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/operator/ujes/UJESResultAdapter.java index 6c746ff57c..63fb004db5 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/operator/ujes/UJESResultAdapter.java +++ b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/operator/ujes/UJESResultAdapter.java @@ -162,6 +162,10 @@ public String getStrongerExecId() { return null; } String execId = null; + + if (result instanceof JobSubmitResult) { + execId = ((JobSubmitResult) result).getExecID(); + } if (result instanceof JobInfoResult) { if (result != null && ((JobInfoResult) result).getTask() != null