fix: 2.5.0
1. 支持任务关闭可以手动支持任务 2. 修复任务失败状态没有统计问题 3. 修复重试模块看板更新统计
This commit is contained in:
parent
2bafc083a5
commit
cce2d9d633
@ -40,16 +40,16 @@
|
||||
|
||||
<select id="summaryJobBatchList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.JobBatchSummaryResponseDO">
|
||||
SELECT namespace_id AS namespaceId,
|
||||
job_id AS jobId,
|
||||
group_name AS groupName,
|
||||
task_batch_status AS taskBatchStatus,
|
||||
operation_reason AS operationReason,
|
||||
COUNT(operation_reason) AS operationReasonTotal,
|
||||
SUM(CASE WHEN (task_batch_status = 3) THEN 1 ELSE 0 END) AS successNum,
|
||||
SUM(CASE WHEN (operation_reason IN (2, 3)) THEN 1 ELSE 0 END) AS cancelNum,
|
||||
SUM(CASE WHEN (operation_reason IN (1, 5, 8)) THEN 1 ELSE 0 END) AS stopNum,
|
||||
SUM(CASE WHEN (operation_reason IN (4, 6, 7)) THEN 1 ELSE 0 END) AS failNum
|
||||
SELECT namespace_id AS namespaceId,
|
||||
job_id AS jobId,
|
||||
group_name AS groupName,
|
||||
task_batch_status AS taskBatchStatus,
|
||||
operation_reason AS operationReason,
|
||||
COUNT(operation_reason) AS operationReasonTotal,
|
||||
SUM(CASE WHEN (task_batch_status = 3) THEN 1 ELSE 0 END) AS successNum,
|
||||
SUM(CASE WHEN (task_batch_status = 6) THEN 1 ELSE 0 END) AS cancelNum,
|
||||
SUM(CASE WHEN (task_batch_status = 5) THEN 1 ELSE 0 END) AS stopNum,
|
||||
SUM(CASE WHEN (task_batch_status = 4) THEN 1 ELSE 0 END) AS failNum
|
||||
FROM job_task_batch
|
||||
WHERE create_dt BETWEEN #{from} AND #{to}
|
||||
GROUP BY namespace_id, group_name, job_id, task_batch_status, operation_reason
|
||||
|
@ -33,10 +33,10 @@
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
namespace_id = values(`namespace_id`),
|
||||
group_name = values(`group_name`),
|
||||
scene_name = values(`scene_name`),
|
||||
trigger_at = values(`trigger_at`)
|
||||
running_num = values(`running_num`),
|
||||
finish_num = values(`finish_num`),
|
||||
max_count_num = values(`max_count_num`),
|
||||
suspend_num = values(`suspend_num`)
|
||||
</insert>
|
||||
|
||||
<select id="retryTask"
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.aizuda.easy.retry.server.common.enums;
|
||||
|
||||
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* job 触发器类型枚举
|
||||
*
|
||||
* @author: xiaowoniu
|
||||
* @date : 2023-12-06 17:21
|
||||
* @since : 2.5.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum JobTriggerTypeEnum {
|
||||
AUTO(1, "自动触发"),
|
||||
MANUAL(2, "手动触发");
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
/**
|
||||
* 根据给定的类型获取对应的触发器类型枚举
|
||||
*
|
||||
* @param type 触发器类型的整数值
|
||||
* @return 对应的触发器类型枚举
|
||||
* @throws EasyRetryServerException 当给定的类型不是有效的枚举类型时抛出异常
|
||||
*/
|
||||
public static JobTriggerTypeEnum get(Integer type) {
|
||||
for (JobTriggerTypeEnum jobTriggerTypeEnum : JobTriggerTypeEnum.values()) {
|
||||
if(jobTriggerTypeEnum.getType().equals(type)) {
|
||||
return jobTriggerTypeEnum;
|
||||
}
|
||||
}
|
||||
|
||||
throw new EasyRetryServerException("无效枚举类型.[{}]", type);
|
||||
}
|
||||
|
||||
}
|
@ -52,4 +52,9 @@ public class JobTaskPrepareDTO {
|
||||
|
||||
private boolean onlyTimeoutCheck;
|
||||
|
||||
/**
|
||||
* 触发类似 1、auto 2、manual
|
||||
*/
|
||||
private Integer triggerType;
|
||||
|
||||
}
|
||||
|
@ -12,4 +12,8 @@ public class JobTimerTaskDTO {
|
||||
|
||||
private Long taskBatchId;
|
||||
private Long jobId;
|
||||
/**
|
||||
* 触发类似 1、auto 2、manual
|
||||
*/
|
||||
private Integer triggerType;
|
||||
}
|
||||
|
@ -11,5 +11,9 @@ public class TaskExecuteDTO {
|
||||
|
||||
private Long jobId;
|
||||
private Long taskBatchId;
|
||||
/**
|
||||
* 触发类似 1、auto 2、manual
|
||||
*/
|
||||
private Integer triggerType;
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.server.common.WaitStrategy;
|
||||
import com.aizuda.easy.retry.server.common.akka.ActorGenerator;
|
||||
import com.aizuda.easy.retry.server.common.cache.CacheRegisterTable;
|
||||
import com.aizuda.easy.retry.server.common.enums.JobTriggerTypeEnum;
|
||||
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||
import com.aizuda.easy.retry.server.common.strategy.WaitStrategies;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
@ -86,10 +87,13 @@ public class JobExecutorActor extends AbstractActor {
|
||||
|
||||
private void doExecute(final TaskExecuteDTO taskExecute) {
|
||||
|
||||
Job job = jobMapper.selectOne(new LambdaQueryWrapper<Job>()
|
||||
.eq(Job::getJobStatus, StatusEnum.YES.getStatus())
|
||||
.eq(Job::getId, taskExecute.getJobId())
|
||||
);
|
||||
LambdaQueryWrapper<Job> queryWrapper = new LambdaQueryWrapper<Job>();
|
||||
// 自动的校验任务必须是开启状态,手动触发无需校验
|
||||
if (JobTriggerTypeEnum.AUTO.getType().equals(taskExecute.getTriggerType())) {
|
||||
queryWrapper.eq(Job::getJobStatus, StatusEnum.YES.getStatus());
|
||||
}
|
||||
|
||||
Job job = jobMapper.selectOne(queryWrapper.eq(Job::getId, taskExecute.getJobId()));
|
||||
|
||||
try {
|
||||
|
||||
@ -146,7 +150,7 @@ public class JobExecutorActor extends AbstractActor {
|
||||
}
|
||||
|
||||
private void doHandlerResidentTask(Job job, TaskExecuteDTO taskExecuteDTO) {
|
||||
if (Objects.isNull(job)) {
|
||||
if (Objects.isNull(job) || JobTriggerTypeEnum.MANUAL.getType().equals(taskExecuteDTO.getTriggerType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -156,6 +160,7 @@ public class JobExecutorActor extends AbstractActor {
|
||||
JobTimerTaskDTO jobTimerTaskDTO = new JobTimerTaskDTO();
|
||||
jobTimerTaskDTO.setJobId(taskExecuteDTO.getJobId());
|
||||
jobTimerTaskDTO.setTaskBatchId(taskExecuteDTO.getTaskBatchId());
|
||||
jobTimerTaskDTO.setTriggerType(JobTriggerTypeEnum.AUTO.getType());
|
||||
ResidentJobTimerTask timerTask = new ResidentJobTimerTask(jobTimerTaskDTO, job);
|
||||
WaitStrategy waitStrategy = WaitStrategies.WaitStrategyEnum.getWaitStrategy(job.getTriggerType());
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.aizuda.easy.retry.server.common.cache.CacheConsumerGroup;
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||
import com.aizuda.easy.retry.server.common.dto.PartitionTask;
|
||||
import com.aizuda.easy.retry.server.common.dto.ScanTask;
|
||||
import com.aizuda.easy.retry.server.common.enums.JobTriggerTypeEnum;
|
||||
import com.aizuda.easy.retry.server.common.strategy.WaitStrategies;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.server.common.util.PartitionTaskUtils;
|
||||
@ -29,7 +30,6 @@ import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@ -90,6 +90,7 @@ public class ScanJobTaskActor extends AbstractActor {
|
||||
for (final JobTaskPrepareDTO waitExecJob : waitExecJobs) {
|
||||
// 执行预处理阶段
|
||||
ActorRef actorRef = ActorGenerator.jobTaskPrepareActor();
|
||||
waitExecJob.setTriggerType(JobTriggerTypeEnum.AUTO.getType());
|
||||
actorRef.tell(waitExecJob, actorRef);
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ public class JobTaskBatchGenerator {
|
||||
JobTimerTaskDTO jobTimerTaskDTO = new JobTimerTaskDTO();
|
||||
jobTimerTaskDTO.setTaskBatchId(jobTaskBatch.getId());
|
||||
jobTimerTaskDTO.setJobId(context.getJobId());
|
||||
jobTimerTaskDTO.setTriggerType(context.getTriggerType());
|
||||
JobTimerWheel.register(jobTaskBatch.getId(),
|
||||
new JobTimerTask(jobTimerTaskDTO), delay, TimeUnit.MILLISECONDS);
|
||||
|
||||
|
@ -40,5 +40,10 @@ public class JobTaskBatchGeneratorContext {
|
||||
*/
|
||||
private Integer taskBatchStatus;
|
||||
|
||||
/**
|
||||
* 触发类似 1、auto 2、manual
|
||||
*/
|
||||
private Integer triggerType;
|
||||
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ public class JobTimerTask implements TimerTask {
|
||||
TaskExecuteDTO taskExecuteDTO = new TaskExecuteDTO();
|
||||
taskExecuteDTO.setTaskBatchId(jobTimerTaskDTO.getTaskBatchId());
|
||||
taskExecuteDTO.setJobId(jobTimerTaskDTO.getJobId());
|
||||
taskExecuteDTO.setTriggerType(jobTimerTaskDTO.getTriggerType());
|
||||
ActorRef actorRef = ActorGenerator.jobTaskExecutorActor();
|
||||
actorRef.tell(taskExecuteDTO, actorRef);
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.aizuda.easy.retry.server.job.task.support.timer;
|
||||
|
||||
import akka.actor.ActorRef;
|
||||
import com.aizuda.easy.retry.server.common.akka.ActorGenerator;
|
||||
import com.aizuda.easy.retry.server.common.enums.JobTriggerTypeEnum;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobTaskPrepareDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobTimerTaskDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.support.JobTaskConverter;
|
||||
@ -29,6 +30,7 @@ public class ResidentJobTimerTask implements TimerTask {
|
||||
// 清除时间轮的缓存
|
||||
JobTimerWheel.clearCache(jobTimerTaskDTO.getTaskBatchId());
|
||||
JobTaskPrepareDTO jobTaskPrepare = JobTaskConverter.INSTANCE.toJobTaskPrepare(job);
|
||||
jobTaskPrepare.setTriggerType(JobTriggerTypeEnum.AUTO.getType());
|
||||
// 执行预处理阶段
|
||||
ActorRef actorRef = ActorGenerator.jobTaskPrepareActor();
|
||||
actorRef.tell(jobTaskPrepare, actorRef);
|
||||
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.aizuda.easy.retry.common.core.enums.StatusEnum;
|
||||
import com.aizuda.easy.retry.server.common.WaitStrategy;
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||
import com.aizuda.easy.retry.server.common.enums.JobTriggerTypeEnum;
|
||||
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||
import com.aizuda.easy.retry.server.common.strategy.WaitStrategies;
|
||||
import com.aizuda.easy.retry.server.common.util.CronUtils;
|
||||
@ -22,11 +23,9 @@ import com.aizuda.easy.retry.server.web.model.response.JobResponseVO;
|
||||
import com.aizuda.easy.retry.server.web.service.JobService;
|
||||
import com.aizuda.easy.retry.server.web.service.convert.JobConverter;
|
||||
import com.aizuda.easy.retry.server.web.service.convert.JobResponseVOConverter;
|
||||
import com.aizuda.easy.retry.server.web.service.convert.SceneConfigResponseVOConverter;
|
||||
import com.aizuda.easy.retry.server.web.util.UserSessionUtils;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.Job;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -34,8 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@ -213,6 +210,7 @@ public class JobServiceImpl implements JobService {
|
||||
JobTaskPrepareDTO jobTaskPrepare = JobTaskConverter.INSTANCE.toJobTaskPrepare(job);
|
||||
// 设置now表示立即执行
|
||||
jobTaskPrepare.setNextTriggerAt(DateUtils.toNowMilli());
|
||||
jobTaskPrepare.setTriggerType(JobTriggerTypeEnum.MANUAL.getType());
|
||||
// 创建批次
|
||||
jobPrePareHandler.handler(jobTaskPrepare);
|
||||
|
||||
@ -230,4 +228,4 @@ public class JobServiceImpl implements JobService {
|
||||
List<JobResponseVO> jobResponseList = JobResponseVOConverter.INSTANCE.toJobResponseVOs(jobs);
|
||||
return jobResponseList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user