From 56d5399dc1e22bfb024b6478aad45ab6c5c2dcc5 Mon Sep 17 00:00:00 2001 From: wangyu096 Date: Fri, 28 Jun 2024 11:53:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=A7=E8=A1=8C=E5=BC=95=E6=93=8E?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6=E9=85=8D=E9=A2=9D=E9=99=90?= =?UTF-8?q?=E5=88=B6=20#261?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/listener/GseStepEventHandler.java | 2 +- .../execute/engine/listener/GseTaskListener.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/listener/GseStepEventHandler.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/listener/GseStepEventHandler.java index 5bfb918ced..df7ea103ea 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/listener/GseStepEventHandler.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/listener/GseStepEventHandler.java @@ -236,7 +236,7 @@ private void prepareFile(StepInstanceDTO stepInstance) { private Long saveInitialGseTask(StepInstanceDTO stepInstance) { GseTaskDTO gseTask = new GseTaskDTO(stepInstance.getId(), stepInstance.getExecuteCount(), stepInstance.getBatch()); - gseTask.setStatus(RunStatusEnum.WAITING_USER.getValue()); + gseTask.setStatus(RunStatusEnum.BLANK.getValue()); return gseTaskService.saveGseTask(gseTask); } diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/listener/GseTaskListener.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/listener/GseTaskListener.java index 2161ea65d1..2f76a9d42b 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/listener/GseTaskListener.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/listener/GseTaskListener.java @@ -24,6 +24,7 @@ package com.tencent.bk.job.execute.engine.listener; +import com.tencent.bk.job.execute.common.constants.RunStatusEnum; import com.tencent.bk.job.execute.common.exception.MessageHandleException; import com.tencent.bk.job.execute.common.exception.MessageHandlerUnavailableException; import com.tencent.bk.job.execute.engine.consts.GseTaskActionEnum; @@ -92,7 +93,11 @@ private void handleException(GseTaskDTO gseTask, Throwable e) throws MessageHand if (e instanceof MessageHandlerUnavailableException) { throw (MessageHandlerUnavailableException) e; } + + updateGseTaskResult(gseTask); + gseTasksExceptionCounter.increment(); + taskExecuteMQEventDispatcher.dispatchStepEvent( StepEvent.refreshStep( gseTask.getStepInstanceId(), @@ -105,4 +110,15 @@ private void handleException(GseTaskDTO gseTask, Throwable e) throws MessageHand ) ); } + + private void updateGseTaskResult(GseTaskDTO gseTask) { + gseTask.setStatus(RunStatusEnum.ABNORMAL_STATE.getValue()); + if (gseTask.getStartTime() == null) { + gseTask.setStartTime(System.currentTimeMillis()); + } + long endTime = System.currentTimeMillis(); + gseTask.setEndTime(endTime); + gseTask.setTotalTime(endTime - gseTask.getStartTime()); + gseTaskService.updateGseTask(gseTask); + } }