feat:(1.2.0-beta2): 优化完善openapi,增加相关常量
This commit is contained in:
parent
9e5abcb43c
commit
8384f9a746
@ -0,0 +1,13 @@
|
|||||||
|
package com.aizuda.snailjob.client.job.core.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum JobTypeEnum {
|
||||||
|
JOB(1),
|
||||||
|
WORKFLOW(2);
|
||||||
|
|
||||||
|
private final int type;
|
||||||
|
}
|
@ -9,6 +9,7 @@ import com.aizuda.snailjob.client.common.exception.SnailJobClientException;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractRequestHandler<R> implements RequestHandler<R> {
|
public abstract class AbstractRequestHandler<R> implements RequestHandler<R> {
|
||||||
|
|
||||||
|
protected static final String SHARD_NUM = "shardNum";
|
||||||
/**
|
/**
|
||||||
* 具体调用
|
* 具体调用
|
||||||
* @return
|
* @return
|
||||||
|
@ -6,10 +6,7 @@ import com.aizuda.snailjob.client.job.core.dto.RequestAddJobDTO;
|
|||||||
import com.aizuda.snailjob.client.job.core.enums.AllocationAlgorithmEnum;
|
import com.aizuda.snailjob.client.job.core.enums.AllocationAlgorithmEnum;
|
||||||
import com.aizuda.snailjob.client.job.core.enums.TriggerTypeEnum;
|
import com.aizuda.snailjob.client.job.core.enums.TriggerTypeEnum;
|
||||||
import com.aizuda.snailjob.client.job.core.util.ValidatorUtils;
|
import com.aizuda.snailjob.client.job.core.util.ValidatorUtils;
|
||||||
import com.aizuda.snailjob.common.core.enums.BlockStrategyEnum;
|
import com.aizuda.snailjob.common.core.enums.*;
|
||||||
import com.aizuda.snailjob.common.core.enums.ExecutorTypeEnum;
|
|
||||||
import com.aizuda.snailjob.common.core.enums.JobTaskTypeEnum;
|
|
||||||
import com.aizuda.snailjob.common.core.enums.StatusEnum;
|
|
||||||
import com.aizuda.snailjob.common.core.util.JsonUtil;
|
import com.aizuda.snailjob.common.core.util.JsonUtil;
|
||||||
import com.aizuda.snailjob.common.log.SnailJobLog;
|
import com.aizuda.snailjob.common.log.SnailJobLog;
|
||||||
|
|
||||||
@ -17,7 +14,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
||||||
private RequestAddJobDTO requestAddJobDTO;
|
private final RequestAddJobDTO requestAddJobDTO;
|
||||||
|
|
||||||
public RequestAddHandler(JobTaskTypeEnum taskType, Integer shardNum) {
|
public RequestAddHandler(JobTaskTypeEnum taskType, Integer shardNum) {
|
||||||
this.requestAddJobDTO = new RequestAddJobDTO();
|
this.requestAddJobDTO = new RequestAddJobDTO();
|
||||||
@ -28,9 +25,9 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
// 默认java
|
// 默认java
|
||||||
requestAddJobDTO.setExecutorType(ExecutorTypeEnum.JAVA.getType());
|
requestAddJobDTO.setExecutorType(ExecutorTypeEnum.JAVA.getType());
|
||||||
// 设置分片
|
// 设置分片
|
||||||
if (shardNum != null){
|
if (shardNum != null) {
|
||||||
Map<String, Object> map = new HashMap<>(1);
|
Map<String, Object> map = new HashMap<>(1);
|
||||||
map.put("shardNum", shardNum);
|
map.put(SHARD_NUM, shardNum);
|
||||||
requestAddJobDTO.setArgsStr(JsonUtil.toJsonString(map));
|
requestAddJobDTO.setArgsStr(JsonUtil.toJsonString(map));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,11 +44,11 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
boolean validated = ValidatorUtils.validateEntity(requestAddJobDTO);
|
boolean validated = ValidatorUtils.validateEntity(requestAddJobDTO);
|
||||||
// 如果校验正确,则正对进行相关筛选
|
// 如果校验正确,则正对进行相关筛选
|
||||||
if (validated) {
|
if (validated) {
|
||||||
if (requestAddJobDTO.getTaskType() == JobTaskTypeEnum.CLUSTER.getType()){
|
if (requestAddJobDTO.getTaskType() == JobTaskTypeEnum.CLUSTER.getType()) {
|
||||||
// 集群模式只允许并发为 1
|
// 集群模式只允许并发为 1
|
||||||
setParallelNum(1);
|
setParallelNum(1);
|
||||||
}
|
}
|
||||||
if (requestAddJobDTO.getTriggerType() == TriggerTypeEnum.WORK_FLOW.getType()){
|
if (requestAddJobDTO.getTriggerType() == TriggerTypeEnum.WORK_FLOW.getType()) {
|
||||||
// 工作流没有调度时间
|
// 工作流没有调度时间
|
||||||
setTriggerInterval("*");
|
setTriggerInterval("*");
|
||||||
}
|
}
|
||||||
@ -61,6 +58,7 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置任务名
|
* 设置任务名
|
||||||
|
*
|
||||||
* @param jobName 任务名
|
* @param jobName 任务名
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -71,65 +69,69 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置参数
|
* 设置参数
|
||||||
|
*
|
||||||
* @param argsStr
|
* @param argsStr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private RequestAddHandler setArgsStr(Map<String, Object> argsStr) {
|
private RequestAddHandler setArgsStr(Map<String, Object> argsStr) {
|
||||||
Map<String, Object> args = new HashMap<>();
|
Map<String, Object> args = new HashMap<>();
|
||||||
if (StrUtil.isNotBlank(requestAddJobDTO.getArgsStr())){
|
if (StrUtil.isNotBlank(requestAddJobDTO.getArgsStr())) {
|
||||||
args = JsonUtil.parseHashMap(requestAddJobDTO.getArgsStr());
|
args = JsonUtil.parseHashMap(requestAddJobDTO.getArgsStr());
|
||||||
}
|
}
|
||||||
args.putAll(argsStr);
|
args.putAll(argsStr);
|
||||||
requestAddJobDTO.setArgsStr(JsonUtil.toJsonString(args));
|
requestAddJobDTO.setArgsStr(JsonUtil.toJsonString(args));
|
||||||
requestAddJobDTO.setArgsType(2);
|
requestAddJobDTO.setArgsType(JobArgsTypeEnum.JSON.getArgsType());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加参数,可支持多次添加
|
* 添加参数,可支持多次添加
|
||||||
* 静态分片不可使用该方法
|
* 静态分片不可使用该方法
|
||||||
|
*
|
||||||
* @param argsKey 参数名
|
* @param argsKey 参数名
|
||||||
* @param argsValue 参数值
|
* @param argsValue 参数值
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RequestAddHandler addArgsStr(String argsKey, Object argsValue) {
|
public RequestAddHandler addArgsStr(String argsKey, Object argsValue) {
|
||||||
if (requestAddJobDTO.getTaskType().equals(JobTaskTypeEnum.SHARDING.getType())){
|
if (requestAddJobDTO.getTaskType().equals(JobTaskTypeEnum.SHARDING.getType())) {
|
||||||
SnailJobLog.LOCAL.warn("静态分片任务,不可使用该方法添加相关任务参数,请使用addShardingArgs");
|
SnailJobLog.LOCAL.warn("静态分片任务,不可使用该方法添加相关任务参数,请使用addShardingArgs");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
if (StrUtil.isNotBlank(requestAddJobDTO.getArgsStr())){
|
if (StrUtil.isNotBlank(requestAddJobDTO.getArgsStr())) {
|
||||||
map = JsonUtil.parseHashMap(requestAddJobDTO.getArgsStr());
|
map = JsonUtil.parseHashMap(requestAddJobDTO.getArgsStr());
|
||||||
}
|
}
|
||||||
map.put(argsKey, argsValue);
|
map.put(argsKey, argsValue);
|
||||||
requestAddJobDTO.setArgsStr(JsonUtil.toJsonString(map));
|
requestAddJobDTO.setArgsStr(JsonUtil.toJsonString(map));
|
||||||
requestAddJobDTO.setArgsType(2);
|
requestAddJobDTO.setArgsType(JobArgsTypeEnum.JSON.getArgsType());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加静态分片相关参数
|
* 添加静态分片相关参数
|
||||||
|
*
|
||||||
* @param shardingValue
|
* @param shardingValue
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RequestAddHandler addShardingArgs(String[] shardingValue){
|
public RequestAddHandler addShardingArgs(String[] shardingValue) {
|
||||||
if (!requestAddJobDTO.getTaskType().equals(JobTaskTypeEnum.SHARDING.getType())){
|
if (!requestAddJobDTO.getTaskType().equals(JobTaskTypeEnum.SHARDING.getType())) {
|
||||||
SnailJobLog.LOCAL.warn("非静态分片任务,不可使用该方法添加相关任务参数,请使用addArgsStr");
|
SnailJobLog.LOCAL.warn("非静态分片任务,不可使用该方法添加相关任务参数,请使用addArgsStr");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
requestAddJobDTO.setArgsStr(JsonUtil.toJsonString(shardingValue));
|
requestAddJobDTO.setArgsStr(JsonUtil.toJsonString(shardingValue));
|
||||||
requestAddJobDTO.setArgsType(1);
|
requestAddJobDTO.setArgsType(JobArgsTypeEnum.TEXT.getArgsType());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置路由
|
* 设置路由
|
||||||
|
*
|
||||||
* @param algorithmEnum 路由算法
|
* @param algorithmEnum 路由算法
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RequestAddHandler setRouteKey(AllocationAlgorithmEnum algorithmEnum) {
|
public RequestAddHandler setRouteKey(AllocationAlgorithmEnum algorithmEnum) {
|
||||||
// 非集群模式 路由策略只能为轮询
|
// 非集群模式 路由策略只能为轮询
|
||||||
if (requestAddJobDTO.getTaskType() != JobTaskTypeEnum.CLUSTER.getType()){
|
if (requestAddJobDTO.getTaskType() != JobTaskTypeEnum.CLUSTER.getType()) {
|
||||||
setRouteKey(AllocationAlgorithmEnum.ROUND);
|
setRouteKey(AllocationAlgorithmEnum.ROUND);
|
||||||
SnailJobLog.LOCAL.warn("非集群模式 路由策略只能为轮询");
|
SnailJobLog.LOCAL.warn("非集群模式 路由策略只能为轮询");
|
||||||
return this;
|
return this;
|
||||||
@ -140,6 +142,7 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置执行器信息
|
* 设置执行器信息
|
||||||
|
*
|
||||||
* @param executorInfo
|
* @param executorInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -150,12 +153,13 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置调度类型
|
* 设置调度类型
|
||||||
|
*
|
||||||
* @param triggerType
|
* @param triggerType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RequestAddHandler setTriggerType(TriggerTypeEnum triggerType) {
|
public RequestAddHandler setTriggerType(TriggerTypeEnum triggerType) {
|
||||||
requestAddJobDTO.setTriggerType(triggerType.getType());
|
requestAddJobDTO.setTriggerType(triggerType.getType());
|
||||||
if (requestAddJobDTO.getTriggerType() == TriggerTypeEnum.WORK_FLOW.getType()){
|
if (requestAddJobDTO.getTriggerType() == TriggerTypeEnum.WORK_FLOW.getType()) {
|
||||||
// 工作流没有调度时间
|
// 工作流没有调度时间
|
||||||
setTriggerInterval("*");
|
setTriggerInterval("*");
|
||||||
}
|
}
|
||||||
@ -166,6 +170,7 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
* 设置触发间隔;
|
* 设置触发间隔;
|
||||||
* 单位:秒
|
* 单位:秒
|
||||||
* 工作流无需配置
|
* 工作流无需配置
|
||||||
|
*
|
||||||
* @param triggerInterval
|
* @param triggerInterval
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -176,13 +181,14 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置阻塞策略
|
* 设置阻塞策略
|
||||||
|
*
|
||||||
* @param blockStrategy
|
* @param blockStrategy
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RequestAddHandler setBlockStrategy(BlockStrategyEnum blockStrategy) {
|
public RequestAddHandler setBlockStrategy(BlockStrategyEnum blockStrategy) {
|
||||||
// 非集群模式 路由策略只能为轮询
|
// 非集群模式 路由策略只能为轮询
|
||||||
if (requestAddJobDTO.getTaskType() == JobTaskTypeEnum.CLUSTER.getType()
|
if (requestAddJobDTO.getTaskType() == JobTaskTypeEnum.CLUSTER.getType()
|
||||||
&& blockStrategy.getBlockStrategy() == BlockStrategyEnum.CONCURRENCY.getBlockStrategy()){
|
&& blockStrategy.getBlockStrategy() == BlockStrategyEnum.CONCURRENCY.getBlockStrategy()) {
|
||||||
throw new SnailJobClientException("集群模式不能使用并行阻塞策略");
|
throw new SnailJobClientException("集群模式不能使用并行阻塞策略");
|
||||||
}
|
}
|
||||||
requestAddJobDTO.setBlockStrategy(blockStrategy.getBlockStrategy());
|
requestAddJobDTO.setBlockStrategy(blockStrategy.getBlockStrategy());
|
||||||
@ -191,6 +197,7 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置执行器超时时间
|
* 设置执行器超时时间
|
||||||
|
*
|
||||||
* @param executorTimeout
|
* @param executorTimeout
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -201,6 +208,7 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置任务最大重试次数
|
* 设置任务最大重试次数
|
||||||
|
*
|
||||||
* @param maxRetryTimes
|
* @param maxRetryTimes
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -211,6 +219,7 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置重试间隔
|
* 设置重试间隔
|
||||||
|
*
|
||||||
* @param retryInterval
|
* @param retryInterval
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -221,6 +230,7 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置并发数量
|
* 设置并发数量
|
||||||
|
*
|
||||||
* @param parallelNum
|
* @param parallelNum
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -231,6 +241,7 @@ public class RequestAddHandler extends AbstractRequestHandler<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置定时任务描述
|
* 设置定时任务描述
|
||||||
|
*
|
||||||
* @param description
|
* @param description
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -9,7 +9,7 @@ import com.aizuda.snailjob.common.core.util.JsonUtil;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class RequestQueryHandler extends AbstractRequestHandler<JobResponseVO> {
|
public class RequestQueryHandler extends AbstractRequestHandler<JobResponseVO> {
|
||||||
private Long queryJobId;
|
private final Long queryJobId;
|
||||||
|
|
||||||
public RequestQueryHandler(Long queryJobId) {
|
public RequestQueryHandler(Long queryJobId) {
|
||||||
this.queryJobId = queryJobId;
|
this.queryJobId = queryJobId;
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
package com.aizuda.snailjob.client.job.core.handler;
|
package com.aizuda.snailjob.client.job.core.handler;
|
||||||
|
|
||||||
import com.aizuda.snailjob.client.common.exception.SnailJobClientException;
|
import com.aizuda.snailjob.client.common.exception.SnailJobClientException;
|
||||||
|
import com.aizuda.snailjob.client.job.core.enums.JobTypeEnum;
|
||||||
|
|
||||||
public class RequestTriggerJobHandler extends AbstractRequestHandler<Boolean>{
|
public class RequestTriggerJobHandler extends AbstractRequestHandler<Boolean>{
|
||||||
private Long triggerJobId;
|
private final Long triggerJobId;
|
||||||
// 1: job; 2: workflow
|
// 1: job; 2: workflow
|
||||||
private int triggerType;
|
private final int triggerType;
|
||||||
|
|
||||||
public RequestTriggerJobHandler(Long tiggerJobId, int triggerType) {
|
public RequestTriggerJobHandler(Long triggerJobId, int triggerType) {
|
||||||
this.triggerJobId = tiggerJobId;
|
this.triggerJobId = triggerJobId;
|
||||||
this.triggerType = triggerType;
|
this.triggerType = triggerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doExecute() {
|
protected Boolean doExecute() {
|
||||||
if (triggerType == 1) {
|
if (triggerType == JobTypeEnum.JOB.getType()) {
|
||||||
return (Boolean) client.triggerJob(triggerJobId).getData();
|
return (Boolean) client.triggerJob(triggerJobId).getData();
|
||||||
}
|
}
|
||||||
if (triggerType == 2) {
|
if (triggerType == JobTypeEnum.WORKFLOW.getType()) {
|
||||||
return (Boolean) client.triggerWorkFlow(triggerJobId).getData();
|
return (Boolean) client.triggerWorkFlow(triggerJobId).getData();
|
||||||
}
|
}
|
||||||
throw new SnailJobClientException("snail job openapi check error");
|
throw new SnailJobClientException("snail job openapi check error");
|
||||||
|
@ -8,6 +8,7 @@ import com.aizuda.snailjob.client.job.core.enums.TriggerTypeEnum;
|
|||||||
import com.aizuda.snailjob.client.job.core.util.ValidatorUtils;
|
import com.aizuda.snailjob.client.job.core.util.ValidatorUtils;
|
||||||
import com.aizuda.snailjob.common.core.enums.BlockStrategyEnum;
|
import com.aizuda.snailjob.common.core.enums.BlockStrategyEnum;
|
||||||
import com.aizuda.snailjob.common.core.enums.ExecutorTypeEnum;
|
import com.aizuda.snailjob.common.core.enums.ExecutorTypeEnum;
|
||||||
|
import com.aizuda.snailjob.common.core.enums.JobArgsTypeEnum;
|
||||||
import com.aizuda.snailjob.common.core.enums.JobTaskTypeEnum;
|
import com.aizuda.snailjob.common.core.enums.JobTaskTypeEnum;
|
||||||
import com.aizuda.snailjob.common.core.util.JsonUtil;
|
import com.aizuda.snailjob.common.core.util.JsonUtil;
|
||||||
import com.aizuda.snailjob.common.log.SnailJobLog;
|
import com.aizuda.snailjob.common.log.SnailJobLog;
|
||||||
@ -16,7 +17,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class RequestUpdateHandler extends AbstractRequestHandler<Boolean> {
|
public class RequestUpdateHandler extends AbstractRequestHandler<Boolean> {
|
||||||
private RequestUpdateJobDTO requestUpdateJobDTO;
|
private final RequestUpdateJobDTO requestUpdateJobDTO;
|
||||||
|
|
||||||
public RequestUpdateHandler(Long jobId) {
|
public RequestUpdateHandler(Long jobId) {
|
||||||
this.requestUpdateJobDTO = new RequestUpdateJobDTO();
|
this.requestUpdateJobDTO = new RequestUpdateJobDTO();
|
||||||
@ -67,7 +68,7 @@ public class RequestUpdateHandler extends AbstractRequestHandler<Boolean> {
|
|||||||
// 设置分片
|
// 设置分片
|
||||||
if (shardNum != null){
|
if (shardNum != null){
|
||||||
Map<String, Object> map = new HashMap<>(1);
|
Map<String, Object> map = new HashMap<>(1);
|
||||||
map.put("shardNum", shardNum);
|
map.put(SHARD_NUM, shardNum);
|
||||||
requestUpdateJobDTO.setArgsStr(JsonUtil.toJsonString(map));
|
requestUpdateJobDTO.setArgsStr(JsonUtil.toJsonString(map));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
@ -99,7 +100,7 @@ public class RequestUpdateHandler extends AbstractRequestHandler<Boolean> {
|
|||||||
}
|
}
|
||||||
args.putAll(argsStr);
|
args.putAll(argsStr);
|
||||||
requestUpdateJobDTO.setArgsStr(JsonUtil.toJsonString(args));
|
requestUpdateJobDTO.setArgsStr(JsonUtil.toJsonString(args));
|
||||||
requestUpdateJobDTO.setArgsType(2);
|
requestUpdateJobDTO.setArgsType(JobArgsTypeEnum.JSON.getArgsType());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +124,7 @@ public class RequestUpdateHandler extends AbstractRequestHandler<Boolean> {
|
|||||||
}
|
}
|
||||||
map.put(argsKey, argsValue);
|
map.put(argsKey, argsValue);
|
||||||
requestUpdateJobDTO.setArgsStr(JsonUtil.toJsonString(map));
|
requestUpdateJobDTO.setArgsStr(JsonUtil.toJsonString(map));
|
||||||
requestUpdateJobDTO.setArgsType(2);
|
requestUpdateJobDTO.setArgsType(JobArgsTypeEnum.JSON.getArgsType());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +140,7 @@ public class RequestUpdateHandler extends AbstractRequestHandler<Boolean> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
requestUpdateJobDTO.setArgsStr(JsonUtil.toJsonString(shardingValue));
|
requestUpdateJobDTO.setArgsStr(JsonUtil.toJsonString(shardingValue));
|
||||||
requestUpdateJobDTO.setArgsType(1);
|
requestUpdateJobDTO.setArgsType(JobArgsTypeEnum.TEXT.getArgsType());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,14 +2,15 @@ package com.aizuda.snailjob.client.job.core.handler;
|
|||||||
|
|
||||||
import com.aizuda.snailjob.client.common.exception.SnailJobClientException;
|
import com.aizuda.snailjob.client.common.exception.SnailJobClientException;
|
||||||
import com.aizuda.snailjob.client.job.core.dto.RequestUpdateStatusDTO;
|
import com.aizuda.snailjob.client.job.core.dto.RequestUpdateStatusDTO;
|
||||||
|
import com.aizuda.snailjob.client.job.core.enums.JobTypeEnum;
|
||||||
import com.aizuda.snailjob.client.job.core.util.ValidatorUtils;
|
import com.aizuda.snailjob.client.job.core.util.ValidatorUtils;
|
||||||
import com.aizuda.snailjob.common.core.enums.StatusEnum;
|
import com.aizuda.snailjob.common.core.enums.StatusEnum;
|
||||||
|
|
||||||
|
|
||||||
public class RequestUpdateStatusHandler extends AbstractRequestHandler<Boolean>{
|
public class RequestUpdateStatusHandler extends AbstractRequestHandler<Boolean>{
|
||||||
private RequestUpdateStatusDTO statusDTO;
|
private final RequestUpdateStatusDTO statusDTO;
|
||||||
// 1: job; 2: workflow
|
// 1: job; 2: workflow
|
||||||
private int type;
|
private final int type;
|
||||||
|
|
||||||
public RequestUpdateStatusHandler(Long id, int type) {
|
public RequestUpdateStatusHandler(Long id, int type) {
|
||||||
this.statusDTO = new RequestUpdateStatusDTO();
|
this.statusDTO = new RequestUpdateStatusDTO();
|
||||||
@ -19,10 +20,10 @@ public class RequestUpdateStatusHandler extends AbstractRequestHandler<Boolean>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doExecute() {
|
protected Boolean doExecute() {
|
||||||
if (type == 1){
|
if (type == JobTypeEnum.JOB.getType()){
|
||||||
return (Boolean) client.updateJobStatus(statusDTO).getData();
|
return (Boolean) client.updateJobStatus(statusDTO).getData();
|
||||||
}
|
}
|
||||||
if (type == 2){
|
if (type == JobTypeEnum.WORKFLOW.getType()){
|
||||||
return (Boolean) client.updateWorkFlowStatus(statusDTO).getData();
|
return (Boolean) client.updateWorkFlowStatus(statusDTO).getData();
|
||||||
}
|
}
|
||||||
throw new SnailJobClientException("snail job openapi check error");
|
throw new SnailJobClientException("snail job openapi check error");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.aizuda.snailjob.client.job.core.openapi;
|
package com.aizuda.snailjob.client.job.core.openapi;
|
||||||
|
|
||||||
|
import com.aizuda.snailjob.client.job.core.enums.JobTypeEnum;
|
||||||
import com.aizuda.snailjob.client.job.core.handler.*;
|
import com.aizuda.snailjob.client.job.core.handler.*;
|
||||||
import com.aizuda.snailjob.common.core.enums.JobTaskTypeEnum;
|
import com.aizuda.snailjob.common.core.enums.JobTaskTypeEnum;
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ public final class SnailJobOpenApi {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static RequestTriggerJobHandler triggerJob(Long jobId) {
|
public static RequestTriggerJobHandler triggerJob(Long jobId) {
|
||||||
return new RequestTriggerJobHandler(jobId, 1);
|
return new RequestTriggerJobHandler(jobId, JobTypeEnum.JOB.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +96,7 @@ public final class SnailJobOpenApi {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static RequestTriggerJobHandler triggerWorkFlow(Long id) {
|
public static RequestTriggerJobHandler triggerWorkFlow(Long id) {
|
||||||
return new RequestTriggerJobHandler(id, 2);
|
return new RequestTriggerJobHandler(id, JobTypeEnum.WORKFLOW.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +106,7 @@ public final class SnailJobOpenApi {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static RequestUpdateStatusHandler updateJobStatus(Long jobId) {
|
public static RequestUpdateStatusHandler updateJobStatus(Long jobId) {
|
||||||
return new RequestUpdateStatusHandler(jobId, 1);
|
return new RequestUpdateStatusHandler(jobId, JobTypeEnum.JOB.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,6 +116,6 @@ public final class SnailJobOpenApi {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static RequestUpdateStatusHandler updateWorkFlowStatus(Long workFlowId) {
|
public static RequestUpdateStatusHandler updateWorkFlowStatus(Long workFlowId) {
|
||||||
return new RequestUpdateStatusHandler(workFlowId, 2);
|
return new RequestUpdateStatusHandler(workFlowId, JobTypeEnum.WORKFLOW.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user