|
|
|
@ -17,13 +17,18 @@
|
|
|
|
|
|
|
|
|
|
package org.apache.dolphinscheduler.service.process; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.apache.commons.lang.math.NumberUtils; |
|
|
|
|
import static java.util.stream.Collectors.toSet; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_EMPTY_SUB_PROCESS; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_FATHER_PARAMS; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.LOCAL_PARAMS; |
|
|
|
|
import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID; |
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.CommandType; |
|
|
|
@ -124,11 +129,10 @@ import org.apache.dolphinscheduler.service.log.LogClientService;
|
|
|
|
|
import org.apache.dolphinscheduler.service.quartz.cron.CronUtils; |
|
|
|
|
import org.apache.dolphinscheduler.service.task.TaskPluginManager; |
|
|
|
|
import org.apache.dolphinscheduler.spi.enums.ResourceType; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.apache.commons.lang.math.NumberUtils; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
@ -143,17 +147,16 @@ import java.util.Objects;
|
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import static java.util.stream.Collectors.toSet; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_EMPTY_SUB_PROCESS; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_FATHER_PARAMS; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.LOCAL_PARAMS; |
|
|
|
|
import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* process relative dao that some mappers in this. |
|
|
|
@ -163,7 +166,7 @@ public class ProcessServiceImpl implements ProcessService {
|
|
|
|
|
|
|
|
|
|
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.DISPATCH.ordinal(), |
|
|
|
|
ExecutionStatus.RUNNING_EXECUTION.ordinal(), |
|
|
|
|
ExecutionStatus.DELAY_EXECUTION.ordinal(), |
|
|
|
@ -1123,8 +1126,8 @@ public class ProcessServiceImpl implements ProcessService {
|
|
|
|
|
if (StringUtils.isNotEmpty(parentInstanceId)) { |
|
|
|
|
ProcessInstance parentInstance = findProcessInstanceDetailById(Integer.parseInt(parentInstanceId)); |
|
|
|
|
if (parentInstance != null) { |
|
|
|
|
subProcessInstance.setGlobalParams( |
|
|
|
|
joinGlobalParams(parentInstance.getGlobalParams(), subProcessInstance.getGlobalParams())); |
|
|
|
|
subProcessInstance.setGlobalParams(joinGlobalParams(parentInstance.getGlobalParams(), subProcessInstance.getGlobalParams())); |
|
|
|
|
subProcessInstance.setVarPool(joinVarPool(parentInstance.getVarPool(), subProcessInstance.getVarPool())); |
|
|
|
|
this.saveProcessInstance(subProcessInstance); |
|
|
|
|
} else { |
|
|
|
|
logger.error("sub process command params error, cannot find parent instance: {} ", cmdParam); |
|
|
|
@ -1167,6 +1170,26 @@ public class ProcessServiceImpl implements ProcessService {
|
|
|
|
|
return JSONUtils.toJsonString(parentParams); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* join parent var pool params into sub process. |
|
|
|
|
* only the keys doesn't in sub process global would be joined. |
|
|
|
|
* |
|
|
|
|
* @param parentValPool |
|
|
|
|
* @param subValPool |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private String joinVarPool(String parentValPool, String subValPool) { |
|
|
|
|
List<Property> parentValPools = Lists.newArrayList(JSONUtils.toList(parentValPool, Property.class)); |
|
|
|
|
parentValPools = parentValPools.stream().filter(valPool -> valPool.getDirect() == Direct.OUT).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
List<Property> subValPools = Lists.newArrayList(JSONUtils.toList(subValPool, Property.class)); |
|
|
|
|
|
|
|
|
|
Set<String> parentValPoolKeys = parentValPools.stream().map(Property::getProp).collect(toSet()); |
|
|
|
|
List<Property> extraSubValPools = subValPools.stream().filter(sub -> !parentValPoolKeys.contains(sub.getProp())).collect(Collectors.toList()); |
|
|
|
|
parentValPools.addAll(extraSubValPools); |
|
|
|
|
return JSONUtils.toJsonString(parentValPools); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* initialize task instance |
|
|
|
|
* |
|
|
|
@ -2387,7 +2410,7 @@ public class ProcessServiceImpl implements ProcessService {
|
|
|
|
|
stream() |
|
|
|
|
.filter(t -> t.getId() != 0) |
|
|
|
|
.map(ResourceInfo::getId) |
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
.collect(toSet()); |
|
|
|
|
} |
|
|
|
|
if (CollectionUtils.isEmpty(resourceIds)) { |
|
|
|
|
return StringUtils.EMPTY; |
|
|
|
@ -2549,7 +2572,7 @@ public class ProcessServiceImpl implements ProcessService {
|
|
|
|
|
Set<Long> processDefinitionCodes = processTaskRelationList |
|
|
|
|
.stream() |
|
|
|
|
.map(ProcessTaskRelation::getProcessDefinitionCode) |
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
.collect(toSet()); |
|
|
|
|
List<ProcessDefinition> processDefinitionList = processDefineMapper.queryByCodes(processDefinitionCodes); |
|
|
|
|
// check process definition is already online
|
|
|
|
|
for (ProcessDefinition processDefinition : processDefinitionList) { |
|
|
|
|