|
|
@ -37,7 +37,6 @@ import org.apache.dolphinscheduler.common.enums.ExecutionStatus; |
|
|
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy; |
|
|
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy; |
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.spi.enums.ResourceType; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.enums.TaskDependType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.TaskDependType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.TimeoutFlag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.TimeoutFlag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
@ -102,8 +101,10 @@ import org.apache.dolphinscheduler.dao.utils.DagHelper; |
|
|
|
import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand; |
|
|
|
import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand; |
|
|
|
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; |
|
|
|
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; |
|
|
|
import org.apache.dolphinscheduler.remote.utils.Host; |
|
|
|
import org.apache.dolphinscheduler.remote.utils.Host; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.service.exceptions.ServiceException; |
|
|
|
import org.apache.dolphinscheduler.service.log.LogClientService; |
|
|
|
import org.apache.dolphinscheduler.service.log.LogClientService; |
|
|
|
import org.apache.dolphinscheduler.service.quartz.cron.CronUtils; |
|
|
|
import org.apache.dolphinscheduler.service.quartz.cron.CronUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.spi.enums.ResourceType; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
@ -140,10 +141,10 @@ public class ProcessService { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass()); |
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass()); |
|
|
|
|
|
|
|
|
|
|
|
private final int[] stateArray = new int[]{ExecutionStatus.SUBMITTED_SUCCESS.ordinal(), |
|
|
|
private final int[] stateArray = new int[]{ExecutionStatus.SUBMITTED_SUCCESS.ordinal(), |
|
|
|
ExecutionStatus.RUNNING_EXECUTION.ordinal(), |
|
|
|
ExecutionStatus.RUNNING_EXECUTION.ordinal(), |
|
|
|
ExecutionStatus.DELAY_EXECUTION.ordinal(), |
|
|
|
ExecutionStatus.DELAY_EXECUTION.ordinal(), |
|
|
|
ExecutionStatus.READY_PAUSE.ordinal(), |
|
|
|
ExecutionStatus.READY_PAUSE.ordinal(), |
|
|
|
ExecutionStatus.READY_STOP.ordinal()}; |
|
|
|
ExecutionStatus.READY_STOP.ordinal()}; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
private UserMapper userMapper; |
|
|
@ -215,9 +216,9 @@ public class ProcessService { |
|
|
|
* @param logger logger |
|
|
|
* @param logger logger |
|
|
|
* @param host host |
|
|
|
* @param host host |
|
|
|
* @param command found command |
|
|
|
* @param command found command |
|
|
|
* @param processDefinitionCacheMaps |
|
|
|
|
|
|
|
* @return process instance |
|
|
|
* @return process instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public ProcessInstance handleCommand(Logger logger, String host, Command command, HashMap<String, ProcessDefinition> processDefinitionCacheMaps) { |
|
|
|
public ProcessInstance handleCommand(Logger logger, String host, Command command, HashMap<String, ProcessDefinition> processDefinitionCacheMaps) { |
|
|
|
ProcessInstance processInstance = constructProcessInstance(command, host, processDefinitionCacheMaps); |
|
|
|
ProcessInstance processInstance = constructProcessInstance(command, host, processDefinitionCacheMaps); |
|
|
|
// cannot construct process instance, return null
|
|
|
|
// cannot construct process instance, return null
|
|
|
@ -231,21 +232,21 @@ public class ProcessService { |
|
|
|
//if the processDefination is serial
|
|
|
|
//if the processDefination is serial
|
|
|
|
ProcessDefinition processDefinition = this.findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); |
|
|
|
ProcessDefinition processDefinition = this.findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); |
|
|
|
if (processDefinition.getExecutionType().typeIsSerial()) { |
|
|
|
if (processDefinition.getExecutionType().typeIsSerial()) { |
|
|
|
saveSerialProcess(processInstance,processDefinition); |
|
|
|
saveSerialProcess(processInstance, processDefinition); |
|
|
|
if (processInstance.getState() != ExecutionStatus.SUBMITTED_SUCCESS) { |
|
|
|
if (processInstance.getState() != ExecutionStatus.SUBMITTED_SUCCESS) { |
|
|
|
this.setSubProcessParam(processInstance); |
|
|
|
setSubProcessParam(processInstance); |
|
|
|
this.commandMapper.deleteById(command.getId()); |
|
|
|
deleteCommandWithCheck(command.getId()); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
saveProcessInstance(processInstance); |
|
|
|
saveProcessInstance(processInstance); |
|
|
|
} |
|
|
|
} |
|
|
|
this.setSubProcessParam(processInstance); |
|
|
|
setSubProcessParam(processInstance); |
|
|
|
this.commandMapper.deleteById(command.getId()); |
|
|
|
deleteCommandWithCheck(command.getId()); |
|
|
|
return processInstance; |
|
|
|
return processInstance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void saveSerialProcess(ProcessInstance processInstance,ProcessDefinition processDefinition) { |
|
|
|
private void saveSerialProcess(ProcessInstance processInstance, ProcessDefinition processDefinition) { |
|
|
|
processInstance.setState(ExecutionStatus.SERIAL_WAIT); |
|
|
|
processInstance.setState(ExecutionStatus.SERIAL_WAIT); |
|
|
|
saveProcessInstance(processInstance); |
|
|
|
saveProcessInstance(processInstance); |
|
|
|
//serial wait
|
|
|
|
//serial wait
|
|
|
@ -253,7 +254,7 @@ public class ProcessService { |
|
|
|
if (processDefinition.getExecutionType().typeIsSerialWait()) { |
|
|
|
if (processDefinition.getExecutionType().typeIsSerialWait()) { |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndStatusAndNextId(processInstance.getProcessDefinitionCode(), |
|
|
|
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndStatusAndNextId(processInstance.getProcessDefinitionCode(), |
|
|
|
Constants.RUNNING_PROCESS_STATE,processInstance.getId()); |
|
|
|
Constants.RUNNING_PROCESS_STATE, processInstance.getId()); |
|
|
|
if (CollectionUtils.isEmpty(runningProcessInstances)) { |
|
|
|
if (CollectionUtils.isEmpty(runningProcessInstances)) { |
|
|
|
processInstance.setState(ExecutionStatus.SUBMITTED_SUCCESS); |
|
|
|
processInstance.setState(ExecutionStatus.SUBMITTED_SUCCESS); |
|
|
|
saveProcessInstance(processInstance); |
|
|
|
saveProcessInstance(processInstance); |
|
|
@ -266,14 +267,14 @@ public class ProcessService { |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (processDefinition.getExecutionType().typeIsSerialDiscard()) { |
|
|
|
} else if (processDefinition.getExecutionType().typeIsSerialDiscard()) { |
|
|
|
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndStatusAndNextId(processInstance.getProcessDefinitionCode(), |
|
|
|
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndStatusAndNextId(processInstance.getProcessDefinitionCode(), |
|
|
|
Constants.RUNNING_PROCESS_STATE,processInstance.getId()); |
|
|
|
Constants.RUNNING_PROCESS_STATE, processInstance.getId()); |
|
|
|
if (CollectionUtils.isEmpty(runningProcessInstances)) { |
|
|
|
if (CollectionUtils.isEmpty(runningProcessInstances)) { |
|
|
|
processInstance.setState(ExecutionStatus.STOP); |
|
|
|
processInstance.setState(ExecutionStatus.STOP); |
|
|
|
saveProcessInstance(processInstance); |
|
|
|
saveProcessInstance(processInstance); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (processDefinition.getExecutionType().typeIsSerialPriority()) { |
|
|
|
} else if (processDefinition.getExecutionType().typeIsSerialPriority()) { |
|
|
|
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndStatusAndNextId(processInstance.getProcessDefinitionCode(), |
|
|
|
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndStatusAndNextId(processInstance.getProcessDefinitionCode(), |
|
|
|
Constants.RUNNING_PROCESS_STATE,processInstance.getId()); |
|
|
|
Constants.RUNNING_PROCESS_STATE, processInstance.getId()); |
|
|
|
if (CollectionUtils.isNotEmpty(runningProcessInstances)) { |
|
|
|
if (CollectionUtils.isNotEmpty(runningProcessInstances)) { |
|
|
|
for (ProcessInstance info : runningProcessInstances) { |
|
|
|
for (ProcessInstance info : runningProcessInstances) { |
|
|
|
info.setCommandType(CommandType.STOP); |
|
|
|
info.setCommandType(CommandType.STOP); |
|
|
@ -345,10 +346,6 @@ public class ProcessService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* get command page |
|
|
|
* get command page |
|
|
|
* |
|
|
|
|
|
|
|
* @param pageSize |
|
|
|
|
|
|
|
* @param pageNumber |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<Command> findCommandPage(int pageSize, int pageNumber) { |
|
|
|
public List<Command> findCommandPage(int pageSize, int pageNumber) { |
|
|
|
return commandMapper.queryCommandPage(pageSize, pageNumber * pageSize); |
|
|
|
return commandMapper.queryCommandPage(pageSize, pageNumber * pageSize); |
|
|
@ -569,21 +566,21 @@ public class ProcessService { |
|
|
|
// process instance quit by "waiting thread" state
|
|
|
|
// process instance quit by "waiting thread" state
|
|
|
|
if (originCommand == null) { |
|
|
|
if (originCommand == null) { |
|
|
|
Command command = new Command( |
|
|
|
Command command = new Command( |
|
|
|
CommandType.RECOVER_WAITING_THREAD, |
|
|
|
CommandType.RECOVER_WAITING_THREAD, |
|
|
|
processInstance.getTaskDependType(), |
|
|
|
processInstance.getTaskDependType(), |
|
|
|
processInstance.getFailureStrategy(), |
|
|
|
processInstance.getFailureStrategy(), |
|
|
|
processInstance.getExecutorId(), |
|
|
|
processInstance.getExecutorId(), |
|
|
|
processInstance.getProcessDefinition().getCode(), |
|
|
|
processInstance.getProcessDefinition().getCode(), |
|
|
|
JSONUtils.toJsonString(cmdParam), |
|
|
|
JSONUtils.toJsonString(cmdParam), |
|
|
|
processInstance.getWarningType(), |
|
|
|
processInstance.getWarningType(), |
|
|
|
processInstance.getWarningGroupId(), |
|
|
|
processInstance.getWarningGroupId(), |
|
|
|
processInstance.getScheduleTime(), |
|
|
|
processInstance.getScheduleTime(), |
|
|
|
processInstance.getWorkerGroup(), |
|
|
|
processInstance.getWorkerGroup(), |
|
|
|
processInstance.getEnvironmentCode(), |
|
|
|
processInstance.getEnvironmentCode(), |
|
|
|
processInstance.getProcessInstancePriority(), |
|
|
|
processInstance.getProcessInstancePriority(), |
|
|
|
processInstance.getDryRun(), |
|
|
|
processInstance.getDryRun(), |
|
|
|
processInstance.getId(), |
|
|
|
processInstance.getId(), |
|
|
|
processInstance.getProcessDefinitionVersion() |
|
|
|
processInstance.getProcessDefinitionVersion() |
|
|
|
); |
|
|
|
); |
|
|
|
saveCommand(command); |
|
|
|
saveCommand(command); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -675,10 +672,10 @@ public class ProcessService { |
|
|
|
|
|
|
|
|
|
|
|
// curing global params
|
|
|
|
// curing global params
|
|
|
|
processInstance.setGlobalParams(ParameterUtils.curingGlobalParams( |
|
|
|
processInstance.setGlobalParams(ParameterUtils.curingGlobalParams( |
|
|
|
processDefinition.getGlobalParamMap(), |
|
|
|
processDefinition.getGlobalParamMap(), |
|
|
|
processDefinition.getGlobalParamList(), |
|
|
|
processDefinition.getGlobalParamList(), |
|
|
|
getCommandTypeIfComplement(processInstance, command), |
|
|
|
getCommandTypeIfComplement(processInstance, command), |
|
|
|
processInstance.getScheduleTime())); |
|
|
|
processInstance.getScheduleTime())); |
|
|
|
|
|
|
|
|
|
|
|
// set process instance priority
|
|
|
|
// set process instance priority
|
|
|
|
processInstance.setProcessInstancePriority(command.getProcessInstancePriority()); |
|
|
|
processInstance.setProcessInstancePriority(command.getProcessInstancePriority()); |
|
|
@ -705,7 +702,7 @@ public class ProcessService { |
|
|
|
startParamMap.putAll(fatherParamMap); |
|
|
|
startParamMap.putAll(fatherParamMap); |
|
|
|
// set start param into global params
|
|
|
|
// set start param into global params
|
|
|
|
if (startParamMap.size() > 0 |
|
|
|
if (startParamMap.size() > 0 |
|
|
|
&& processDefinition.getGlobalParamMap() != null) { |
|
|
|
&& processDefinition.getGlobalParamMap() != null) { |
|
|
|
for (Map.Entry<String, String> param : processDefinition.getGlobalParamMap().entrySet()) { |
|
|
|
for (Map.Entry<String, String> param : processDefinition.getGlobalParamMap().entrySet()) { |
|
|
|
String val = startParamMap.get(param.getKey()); |
|
|
|
String val = startParamMap.get(param.getKey()); |
|
|
|
if (val != null) { |
|
|
|
if (val != null) { |
|
|
@ -767,8 +764,8 @@ public class ProcessService { |
|
|
|
private Boolean checkCmdParam(Command command, Map<String, String> cmdParam) { |
|
|
|
private Boolean checkCmdParam(Command command, Map<String, String> cmdParam) { |
|
|
|
if (command.getTaskDependType() == TaskDependType.TASK_ONLY || command.getTaskDependType() == TaskDependType.TASK_PRE) { |
|
|
|
if (command.getTaskDependType() == TaskDependType.TASK_ONLY || command.getTaskDependType() == TaskDependType.TASK_PRE) { |
|
|
|
if (cmdParam == null |
|
|
|
if (cmdParam == null |
|
|
|
|| !cmdParam.containsKey(Constants.CMD_PARAM_START_NODES) |
|
|
|
|| !cmdParam.containsKey(Constants.CMD_PARAM_START_NODES) |
|
|
|
|| cmdParam.get(Constants.CMD_PARAM_START_NODES).isEmpty()) { |
|
|
|
|| cmdParam.get(Constants.CMD_PARAM_START_NODES).isEmpty()) { |
|
|
|
logger.error("command node depend type is {}, but start nodes is null ", command.getTaskDependType()); |
|
|
|
logger.error("command node depend type is {}, but start nodes is null ", command.getTaskDependType()); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -779,9 +776,8 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* construct process instance according to one command. |
|
|
|
* construct process instance according to one command. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param command command |
|
|
|
* @param command command |
|
|
|
* @param host host |
|
|
|
* @param host host |
|
|
|
* @param processDefinitionCacheMaps |
|
|
|
|
|
|
|
* @return process instance |
|
|
|
* @return process instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ProcessInstance constructProcessInstance(Command command, String host, HashMap<String, ProcessDefinition> processDefinitionCacheMaps) { |
|
|
|
private ProcessInstance constructProcessInstance(Command command, String host, HashMap<String, ProcessDefinition> processDefinitionCacheMaps) { |
|
|
@ -954,7 +950,7 @@ public class ProcessService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return processDefineLogMapper.queryByDefinitionCodeAndVersion( |
|
|
|
return processDefineLogMapper.queryByDefinitionCodeAndVersion( |
|
|
|
processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); |
|
|
|
processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1000,9 +996,9 @@ public class ProcessService { |
|
|
|
processInstance.setScheduleTime(complementDate.get(0)); |
|
|
|
processInstance.setScheduleTime(complementDate.get(0)); |
|
|
|
} |
|
|
|
} |
|
|
|
processInstance.setGlobalParams(ParameterUtils.curingGlobalParams( |
|
|
|
processInstance.setGlobalParams(ParameterUtils.curingGlobalParams( |
|
|
|
processDefinition.getGlobalParamMap(), |
|
|
|
processDefinition.getGlobalParamMap(), |
|
|
|
processDefinition.getGlobalParamList(), |
|
|
|
processDefinition.getGlobalParamList(), |
|
|
|
CommandType.COMPLEMENT_DATA, processInstance.getScheduleTime())); |
|
|
|
CommandType.COMPLEMENT_DATA, processInstance.getScheduleTime())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -1020,7 +1016,7 @@ public class ProcessService { |
|
|
|
Map<String, String> paramMap = JSONUtils.toMap(cmdParam); |
|
|
|
Map<String, String> paramMap = JSONUtils.toMap(cmdParam); |
|
|
|
// write sub process id into cmd param.
|
|
|
|
// write sub process id into cmd param.
|
|
|
|
if (paramMap.containsKey(CMD_PARAM_SUB_PROCESS) |
|
|
|
if (paramMap.containsKey(CMD_PARAM_SUB_PROCESS) |
|
|
|
&& CMD_PARAM_EMPTY_SUB_PROCESS.equals(paramMap.get(CMD_PARAM_SUB_PROCESS))) { |
|
|
|
&& CMD_PARAM_EMPTY_SUB_PROCESS.equals(paramMap.get(CMD_PARAM_SUB_PROCESS))) { |
|
|
|
paramMap.remove(CMD_PARAM_SUB_PROCESS); |
|
|
|
paramMap.remove(CMD_PARAM_SUB_PROCESS); |
|
|
|
paramMap.put(CMD_PARAM_SUB_PROCESS, String.valueOf(subProcessInstance.getId())); |
|
|
|
paramMap.put(CMD_PARAM_SUB_PROCESS, String.valueOf(subProcessInstance.getId())); |
|
|
|
subProcessInstance.setCommandParam(JSONUtils.toJsonString(paramMap)); |
|
|
|
subProcessInstance.setCommandParam(JSONUtils.toJsonString(paramMap)); |
|
|
@ -1033,7 +1029,7 @@ public class ProcessService { |
|
|
|
ProcessInstance parentInstance = findProcessInstanceDetailById(Integer.parseInt(parentInstanceId)); |
|
|
|
ProcessInstance parentInstance = findProcessInstanceDetailById(Integer.parseInt(parentInstanceId)); |
|
|
|
if (parentInstance != null) { |
|
|
|
if (parentInstance != null) { |
|
|
|
subProcessInstance.setGlobalParams( |
|
|
|
subProcessInstance.setGlobalParams( |
|
|
|
joinGlobalParams(parentInstance.getGlobalParams(), subProcessInstance.getGlobalParams())); |
|
|
|
joinGlobalParams(parentInstance.getGlobalParams(), subProcessInstance.getGlobalParams())); |
|
|
|
this.saveProcessInstance(subProcessInstance); |
|
|
|
this.saveProcessInstance(subProcessInstance); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.error("sub process command params error, cannot find parent instance: {} ", cmdParam); |
|
|
|
logger.error("sub process command params error, cannot find parent instance: {} ", cmdParam); |
|
|
@ -1080,7 +1076,7 @@ public class ProcessService { |
|
|
|
private void initTaskInstance(TaskInstance taskInstance) { |
|
|
|
private void initTaskInstance(TaskInstance taskInstance) { |
|
|
|
|
|
|
|
|
|
|
|
if (!taskInstance.isSubProcess() |
|
|
|
if (!taskInstance.isSubProcess() |
|
|
|
&& (taskInstance.getState().typeIsCancel() || taskInstance.getState().typeIsFailure())) { |
|
|
|
&& (taskInstance.getState().typeIsCancel() || taskInstance.getState().typeIsFailure())) { |
|
|
|
taskInstance.setFlag(Flag.NO); |
|
|
|
taskInstance.setFlag(Flag.NO); |
|
|
|
updateTaskInstance(taskInstance); |
|
|
|
updateTaskInstance(taskInstance); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1091,11 +1087,6 @@ public class ProcessService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* retry submit task to db |
|
|
|
* retry submit task to db |
|
|
|
* |
|
|
|
|
|
|
|
* @param taskInstance |
|
|
|
|
|
|
|
* @param commitRetryTimes |
|
|
|
|
|
|
|
* @param commitInterval |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public TaskInstance submitTask(TaskInstance taskInstance, int commitRetryTimes, int commitInterval) { |
|
|
|
public TaskInstance submitTask(TaskInstance taskInstance, int commitRetryTimes, int commitInterval) { |
|
|
|
|
|
|
|
|
|
|
@ -1135,12 +1126,12 @@ public class ProcessService { |
|
|
|
public TaskInstance submitTask(TaskInstance taskInstance) { |
|
|
|
public TaskInstance submitTask(TaskInstance taskInstance) { |
|
|
|
ProcessInstance processInstance = this.findProcessInstanceDetailById(taskInstance.getProcessInstanceId()); |
|
|
|
ProcessInstance processInstance = this.findProcessInstanceDetailById(taskInstance.getProcessInstanceId()); |
|
|
|
logger.info("start submit task : {}, instance id:{}, state: {}", |
|
|
|
logger.info("start submit task : {}, instance id:{}, state: {}", |
|
|
|
taskInstance.getName(), taskInstance.getProcessInstanceId(), processInstance.getState()); |
|
|
|
taskInstance.getName(), taskInstance.getProcessInstanceId(), processInstance.getState()); |
|
|
|
//submit to db
|
|
|
|
//submit to db
|
|
|
|
TaskInstance task = submitTaskInstanceToDB(taskInstance, processInstance); |
|
|
|
TaskInstance task = submitTaskInstanceToDB(taskInstance, processInstance); |
|
|
|
if (task == null) { |
|
|
|
if (task == null) { |
|
|
|
logger.error("end submit task to db error, task name:{}, process id:{} state: {} ", |
|
|
|
logger.error("end submit task to db error, task name:{}, process id:{} state: {} ", |
|
|
|
taskInstance.getName(), taskInstance.getProcessInstance(), processInstance.getState()); |
|
|
|
taskInstance.getName(), taskInstance.getProcessInstance(), processInstance.getState()); |
|
|
|
return task; |
|
|
|
return task; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!task.getState().typeIsFinished()) { |
|
|
|
if (!task.getState().typeIsFinished()) { |
|
|
@ -1206,7 +1197,7 @@ public class ProcessService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info("sub process instance is not found,parent task:{},parent instance:{}", |
|
|
|
logger.info("sub process instance is not found,parent task:{},parent instance:{}", |
|
|
|
parentTask.getId(), parentProcessInstance.getId()); |
|
|
|
parentTask.getId(), parentProcessInstance.getId()); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1298,21 +1289,21 @@ public class ProcessService { |
|
|
|
String processParam = getSubWorkFlowParam(instanceMap, parentProcessInstance, fatherParams); |
|
|
|
String processParam = getSubWorkFlowParam(instanceMap, parentProcessInstance, fatherParams); |
|
|
|
int subProcessInstanceId = childInstance == null ? 0 : childInstance.getId(); |
|
|
|
int subProcessInstanceId = childInstance == null ? 0 : childInstance.getId(); |
|
|
|
return new Command( |
|
|
|
return new Command( |
|
|
|
commandType, |
|
|
|
commandType, |
|
|
|
TaskDependType.TASK_POST, |
|
|
|
TaskDependType.TASK_POST, |
|
|
|
parentProcessInstance.getFailureStrategy(), |
|
|
|
parentProcessInstance.getFailureStrategy(), |
|
|
|
parentProcessInstance.getExecutorId(), |
|
|
|
parentProcessInstance.getExecutorId(), |
|
|
|
subProcessDefinition.getCode(), |
|
|
|
subProcessDefinition.getCode(), |
|
|
|
processParam, |
|
|
|
processParam, |
|
|
|
parentProcessInstance.getWarningType(), |
|
|
|
parentProcessInstance.getWarningType(), |
|
|
|
parentProcessInstance.getWarningGroupId(), |
|
|
|
parentProcessInstance.getWarningGroupId(), |
|
|
|
parentProcessInstance.getScheduleTime(), |
|
|
|
parentProcessInstance.getScheduleTime(), |
|
|
|
task.getWorkerGroup(), |
|
|
|
task.getWorkerGroup(), |
|
|
|
task.getEnvironmentCode(), |
|
|
|
task.getEnvironmentCode(), |
|
|
|
parentProcessInstance.getProcessInstancePriority(), |
|
|
|
parentProcessInstance.getProcessInstancePriority(), |
|
|
|
parentProcessInstance.getDryRun(), |
|
|
|
parentProcessInstance.getDryRun(), |
|
|
|
subProcessInstanceId, |
|
|
|
subProcessInstanceId, |
|
|
|
subProcessDefinition.getVersion() |
|
|
|
subProcessDefinition.getVersion() |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1349,7 +1340,7 @@ public class ProcessService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void updateSubProcessDefinitionByParent(ProcessInstance parentProcessInstance, long childDefinitionCode) { |
|
|
|
private void updateSubProcessDefinitionByParent(ProcessInstance parentProcessInstance, long childDefinitionCode) { |
|
|
|
ProcessDefinition fatherDefinition = this.findProcessDefinition(parentProcessInstance.getProcessDefinitionCode(), |
|
|
|
ProcessDefinition fatherDefinition = this.findProcessDefinition(parentProcessInstance.getProcessDefinitionCode(), |
|
|
|
parentProcessInstance.getProcessDefinitionVersion()); |
|
|
|
parentProcessInstance.getProcessDefinitionVersion()); |
|
|
|
ProcessDefinition childDefinition = this.findProcessDefinitionByCode(childDefinitionCode); |
|
|
|
ProcessDefinition childDefinition = this.findProcessDefinitionByCode(childDefinitionCode); |
|
|
|
if (childDefinition != null && fatherDefinition != null) { |
|
|
|
if (childDefinition != null && fatherDefinition != null) { |
|
|
|
childDefinition.setWarningGroupId(fatherDefinition.getWarningGroupId()); |
|
|
|
childDefinition.setWarningGroupId(fatherDefinition.getWarningGroupId()); |
|
|
@ -1372,7 +1363,7 @@ public class ProcessService { |
|
|
|
taskInstance.setRetryTimes(taskInstance.getRetryTimes() + 1); |
|
|
|
taskInstance.setRetryTimes(taskInstance.getRetryTimes() + 1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (processInstanceState != ExecutionStatus.READY_STOP |
|
|
|
if (processInstanceState != ExecutionStatus.READY_STOP |
|
|
|
&& processInstanceState != ExecutionStatus.READY_PAUSE) { |
|
|
|
&& processInstanceState != ExecutionStatus.READY_PAUSE) { |
|
|
|
// failure task set invalid
|
|
|
|
// failure task set invalid
|
|
|
|
taskInstance.setFlag(Flag.NO); |
|
|
|
taskInstance.setFlag(Flag.NO); |
|
|
|
updateTaskInstance(taskInstance); |
|
|
|
updateTaskInstance(taskInstance); |
|
|
@ -1425,9 +1416,9 @@ public class ProcessService { |
|
|
|
// the task already exists in task queue
|
|
|
|
// the task already exists in task queue
|
|
|
|
// return state
|
|
|
|
// return state
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
state == ExecutionStatus.RUNNING_EXECUTION |
|
|
|
state == ExecutionStatus.RUNNING_EXECUTION |
|
|
|
|| state == ExecutionStatus.DELAY_EXECUTION |
|
|
|
|| state == ExecutionStatus.DELAY_EXECUTION |
|
|
|
|| state == ExecutionStatus.KILL |
|
|
|
|| state == ExecutionStatus.KILL |
|
|
|
) { |
|
|
|
) { |
|
|
|
return state; |
|
|
|
return state; |
|
|
|
} |
|
|
|
} |
|
|
@ -1436,7 +1427,7 @@ public class ProcessService { |
|
|
|
if (processInstanceState == ExecutionStatus.READY_PAUSE) { |
|
|
|
if (processInstanceState == ExecutionStatus.READY_PAUSE) { |
|
|
|
state = ExecutionStatus.PAUSE; |
|
|
|
state = ExecutionStatus.PAUSE; |
|
|
|
} else if (processInstanceState == ExecutionStatus.READY_STOP |
|
|
|
} else if (processInstanceState == ExecutionStatus.READY_STOP |
|
|
|
|| !checkProcessStrategy(taskInstance)) { |
|
|
|
|| !checkProcessStrategy(taskInstance)) { |
|
|
|
state = ExecutionStatus.KILL; |
|
|
|
state = ExecutionStatus.KILL; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
state = ExecutionStatus.SUBMITTED_SUCCESS; |
|
|
|
state = ExecutionStatus.SUBMITTED_SUCCESS; |
|
|
@ -1460,7 +1451,7 @@ public class ProcessService { |
|
|
|
|
|
|
|
|
|
|
|
for (TaskInstance task : taskInstances) { |
|
|
|
for (TaskInstance task : taskInstances) { |
|
|
|
if (task.getState() == ExecutionStatus.FAILURE |
|
|
|
if (task.getState() == ExecutionStatus.FAILURE |
|
|
|
&& task.getRetryTimes() >= task.getMaxRetryTimes()) { |
|
|
|
&& task.getRetryTimes() >= task.getMaxRetryTimes()) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1589,7 +1580,8 @@ public class ProcessService { |
|
|
|
private void updateTaskDefinitionResources(TaskDefinition taskDefinition) { |
|
|
|
private void updateTaskDefinitionResources(TaskDefinition taskDefinition) { |
|
|
|
Map<String, Object> taskParameters = JSONUtils.parseObject( |
|
|
|
Map<String, Object> taskParameters = JSONUtils.parseObject( |
|
|
|
taskDefinition.getTaskParams(), |
|
|
|
taskDefinition.getTaskParams(), |
|
|
|
new TypeReference<Map<String, Object>>() { }); |
|
|
|
new TypeReference<Map<String, Object>>() { |
|
|
|
|
|
|
|
}); |
|
|
|
if (taskParameters != null) { |
|
|
|
if (taskParameters != null) { |
|
|
|
// if contains mainJar field, query resource from database
|
|
|
|
// if contains mainJar field, query resource from database
|
|
|
|
// Flink, Spark, MR
|
|
|
|
// Flink, Spark, MR
|
|
|
@ -1815,8 +1807,6 @@ public class ProcessService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* for show in page of taskInstance |
|
|
|
* for show in page of taskInstance |
|
|
|
* |
|
|
|
|
|
|
|
* @param taskInstance |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void changeOutParam(TaskInstance taskInstance) { |
|
|
|
public void changeOutParam(TaskInstance taskInstance) { |
|
|
|
if (StringUtils.isEmpty(taskInstance.getVarPool())) { |
|
|
|
if (StringUtils.isEmpty(taskInstance.getVarPool())) { |
|
|
@ -1827,7 +1817,8 @@ public class ProcessService { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//if the result more than one line,just get the first .
|
|
|
|
//if the result more than one line,just get the first .
|
|
|
|
Map<String, Object> taskParams = JSONUtils.parseObject(taskInstance.getTaskParams(), new TypeReference<Map<String, Object>>() {}); |
|
|
|
Map<String, Object> taskParams = JSONUtils.parseObject(taskInstance.getTaskParams(), new TypeReference<Map<String, Object>>() { |
|
|
|
|
|
|
|
}); |
|
|
|
Object localParams = taskParams.get(LOCAL_PARAMS); |
|
|
|
Object localParams = taskParams.get(LOCAL_PARAMS); |
|
|
|
if (localParams == null) { |
|
|
|
if (localParams == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1928,7 +1919,7 @@ public class ProcessService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<TaskInstance> queryNeedFailoverTaskInstances(String host) { |
|
|
|
public List<TaskInstance> queryNeedFailoverTaskInstances(String host) { |
|
|
|
return taskInstanceMapper.queryByHostAndStatus(host, |
|
|
|
return taskInstanceMapper.queryByHostAndStatus(host, |
|
|
|
stateArray); |
|
|
|
stateArray); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -2024,8 +2015,8 @@ public class ProcessService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProcessInstance findLastSchedulerProcessInterval(Long definitionCode, DateInterval dateInterval) { |
|
|
|
public ProcessInstance findLastSchedulerProcessInterval(Long definitionCode, DateInterval dateInterval) { |
|
|
|
return processInstanceMapper.queryLastSchedulerProcess(definitionCode, |
|
|
|
return processInstanceMapper.queryLastSchedulerProcess(definitionCode, |
|
|
|
dateInterval.getStartTime(), |
|
|
|
dateInterval.getStartTime(), |
|
|
|
dateInterval.getEndTime()); |
|
|
|
dateInterval.getEndTime()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -2037,8 +2028,8 @@ public class ProcessService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProcessInstance findLastManualProcessInterval(Long definitionCode, DateInterval dateInterval) { |
|
|
|
public ProcessInstance findLastManualProcessInterval(Long definitionCode, DateInterval dateInterval) { |
|
|
|
return processInstanceMapper.queryLastManualProcess(definitionCode, |
|
|
|
return processInstanceMapper.queryLastManualProcess(definitionCode, |
|
|
|
dateInterval.getStartTime(), |
|
|
|
dateInterval.getStartTime(), |
|
|
|
dateInterval.getEndTime()); |
|
|
|
dateInterval.getEndTime()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -2051,9 +2042,9 @@ public class ProcessService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProcessInstance findLastRunningProcess(Long definitionCode, Date startTime, Date endTime) { |
|
|
|
public ProcessInstance findLastRunningProcess(Long definitionCode, Date startTime, Date endTime) { |
|
|
|
return processInstanceMapper.queryLastRunningProcess(definitionCode, |
|
|
|
return processInstanceMapper.queryLastRunningProcess(definitionCode, |
|
|
|
startTime, |
|
|
|
startTime, |
|
|
|
endTime, |
|
|
|
endTime, |
|
|
|
stateArray); |
|
|
|
stateArray); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -2259,10 +2250,10 @@ public class ProcessService { |
|
|
|
AbstractParameters params = TaskParametersUtils.getParameters(taskDefinition.getTaskType(), taskDefinition.getTaskParams()); |
|
|
|
AbstractParameters params = TaskParametersUtils.getParameters(taskDefinition.getTaskType(), taskDefinition.getTaskParams()); |
|
|
|
if (params != null && CollectionUtils.isNotEmpty(params.getResourceFilesList())) { |
|
|
|
if (params != null && CollectionUtils.isNotEmpty(params.getResourceFilesList())) { |
|
|
|
resourceIds = params.getResourceFilesList(). |
|
|
|
resourceIds = params.getResourceFilesList(). |
|
|
|
stream() |
|
|
|
stream() |
|
|
|
.filter(t -> t.getId() != 0) |
|
|
|
.filter(t -> t.getId() != 0) |
|
|
|
.map(ResourceInfo::getId) |
|
|
|
.map(ResourceInfo::getId) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(resourceIds)) { |
|
|
|
if (CollectionUtils.isEmpty(resourceIds)) { |
|
|
|
return StringUtils.EMPTY; |
|
|
|
return StringUtils.EMPTY; |
|
|
@ -2282,7 +2273,7 @@ public class ProcessService { |
|
|
|
taskDefinitionLog.setResourceIds(getResourceIds(taskDefinitionLog)); |
|
|
|
taskDefinitionLog.setResourceIds(getResourceIds(taskDefinitionLog)); |
|
|
|
if (taskDefinitionLog.getCode() > 0 && taskDefinitionLog.getVersion() > 0) { |
|
|
|
if (taskDefinitionLog.getCode() > 0 && taskDefinitionLog.getVersion() > 0) { |
|
|
|
TaskDefinitionLog definitionCodeAndVersion = taskDefinitionLogMapper |
|
|
|
TaskDefinitionLog definitionCodeAndVersion = taskDefinitionLogMapper |
|
|
|
.queryByDefinitionCodeAndVersion(taskDefinitionLog.getCode(), taskDefinitionLog.getVersion()); |
|
|
|
.queryByDefinitionCodeAndVersion(taskDefinitionLog.getCode(), taskDefinitionLog.getVersion()); |
|
|
|
if (definitionCodeAndVersion != null) { |
|
|
|
if (definitionCodeAndVersion != null) { |
|
|
|
if (!taskDefinitionLog.equals(definitionCodeAndVersion)) { |
|
|
|
if (!taskDefinitionLog.equals(definitionCodeAndVersion)) { |
|
|
|
taskDefinitionLog.setUserId(definitionCodeAndVersion.getUserId()); |
|
|
|
taskDefinitionLog.setUserId(definitionCodeAndVersion.getUserId()); |
|
|
@ -2356,7 +2347,7 @@ public class ProcessService { |
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = null; |
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = null; |
|
|
|
if (CollectionUtils.isNotEmpty(taskDefinitionLogs)) { |
|
|
|
if (CollectionUtils.isNotEmpty(taskDefinitionLogs)) { |
|
|
|
taskDefinitionLogMap = taskDefinitionLogs.stream() |
|
|
|
taskDefinitionLogMap = taskDefinitionLogs.stream() |
|
|
|
.collect(Collectors.toMap(TaskDefinition::getCode, taskDefinitionLog -> taskDefinitionLog)); |
|
|
|
.collect(Collectors.toMap(TaskDefinition::getCode, taskDefinitionLog -> taskDefinitionLog)); |
|
|
|
} |
|
|
|
} |
|
|
|
Date now = new Date(); |
|
|
|
Date now = new Date(); |
|
|
|
for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) { |
|
|
|
for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) { |
|
|
@ -2394,9 +2385,9 @@ public class ProcessService { |
|
|
|
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode); |
|
|
|
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode); |
|
|
|
if (!processTaskRelationList.isEmpty()) { |
|
|
|
if (!processTaskRelationList.isEmpty()) { |
|
|
|
Set<Long> processDefinitionCodes = processTaskRelationList |
|
|
|
Set<Long> processDefinitionCodes = processTaskRelationList |
|
|
|
.stream() |
|
|
|
.stream() |
|
|
|
.map(ProcessTaskRelation::getProcessDefinitionCode) |
|
|
|
.map(ProcessTaskRelation::getProcessDefinitionCode) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefineMapper.queryByCodes(processDefinitionCodes); |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefineMapper.queryByCodes(processDefinitionCodes); |
|
|
|
// check process definition is already online
|
|
|
|
// check process definition is already online
|
|
|
|
for (ProcessDefinition processDefinition : processDefinitionList) { |
|
|
|
for (ProcessDefinition processDefinition : processDefinitionList) { |
|
|
@ -2429,8 +2420,8 @@ public class ProcessService { |
|
|
|
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogList = genTaskDefineList(processTaskRelations); |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogList = genTaskDefineList(processTaskRelations); |
|
|
|
List<TaskDefinition> taskDefinitions = taskDefinitionLogList.stream() |
|
|
|
List<TaskDefinition> taskDefinitions = taskDefinitionLogList.stream() |
|
|
|
.map(taskDefinitionLog -> JSONUtils.parseObject(JSONUtils.toJsonString(taskDefinitionLog), TaskDefinition.class)) |
|
|
|
.map(taskDefinitionLog -> JSONUtils.parseObject(JSONUtils.toJsonString(taskDefinitionLog), TaskDefinition.class)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
return new DagData(processDefinition, processTaskRelations, taskDefinitions); |
|
|
|
return new DagData(processDefinition, processTaskRelations, taskDefinitions); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2493,7 +2484,7 @@ public class ProcessService { |
|
|
|
taskDefinitionLogs = genTaskDefineList(taskRelationList); |
|
|
|
taskDefinitionLogs = genTaskDefineList(taskRelationList); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = taskDefinitionLogs.stream() |
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = taskDefinitionLogs.stream() |
|
|
|
.collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog)); |
|
|
|
.collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog)); |
|
|
|
List<TaskNode> taskNodeList = new ArrayList<>(); |
|
|
|
List<TaskNode> taskNodeList = new ArrayList<>(); |
|
|
|
for (Entry<Long, List<Long>> code : taskCodeMap.entrySet()) { |
|
|
|
for (Entry<Long, List<Long>> code : taskCodeMap.entrySet()) { |
|
|
|
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(code.getKey()); |
|
|
|
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(code.getKey()); |
|
|
@ -2518,8 +2509,8 @@ public class ProcessService { |
|
|
|
taskNode.setWorkerGroup(taskDefinitionLog.getWorkerGroup()); |
|
|
|
taskNode.setWorkerGroup(taskDefinitionLog.getWorkerGroup()); |
|
|
|
taskNode.setEnvironmentCode(taskDefinitionLog.getEnvironmentCode()); |
|
|
|
taskNode.setEnvironmentCode(taskDefinitionLog.getEnvironmentCode()); |
|
|
|
taskNode.setTimeout(JSONUtils.toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN, |
|
|
|
taskNode.setTimeout(JSONUtils.toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN, |
|
|
|
taskDefinitionLog.getTimeoutNotifyStrategy(), |
|
|
|
taskDefinitionLog.getTimeoutNotifyStrategy(), |
|
|
|
taskDefinitionLog.getTimeout()))); |
|
|
|
taskDefinitionLog.getTimeout()))); |
|
|
|
taskNode.setDelayTime(taskDefinitionLog.getDelayTime()); |
|
|
|
taskNode.setDelayTime(taskDefinitionLog.getDelayTime()); |
|
|
|
taskNode.setPreTasks(JSONUtils.toJsonString(code.getValue().stream().map(taskDefinitionLogMap::get).map(TaskDefinition::getCode).collect(Collectors.toList()))); |
|
|
|
taskNode.setPreTasks(JSONUtils.toJsonString(code.getValue().stream().map(taskDefinitionLogMap::get).map(TaskDefinition::getCode).collect(Collectors.toList()))); |
|
|
|
taskNodeList.add(taskNode); |
|
|
|
taskNodeList.add(taskNode); |
|
|
@ -2545,6 +2536,13 @@ public class ProcessService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ProcessInstance loadNextProcess4Serial(long code, int state) { |
|
|
|
public ProcessInstance loadNextProcess4Serial(long code, int state) { |
|
|
|
return this.processInstanceMapper.loadNextProcess4Serial(code,state); |
|
|
|
return this.processInstanceMapper.loadNextProcess4Serial(code, state); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void deleteCommandWithCheck(int commandId) { |
|
|
|
|
|
|
|
int delete = this.commandMapper.deleteById(commandId); |
|
|
|
|
|
|
|
if (delete != 1) { |
|
|
|
|
|
|
|
throw new ServiceException("delete command fail, id:" + commandId); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|