Skip to content

Commit

Permalink
feat: 执行引擎任务调度配额限制 TencentBlueKing#261
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Jun 28, 2024
1 parent c1d6334 commit 56d5399
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand All @@ -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);
}
}

0 comments on commit 56d5399

Please sign in to comment.