|
|
@ -17,13 +17,18 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.apache.dolphinscheduler.service.process; |
|
|
|
package org.apache.dolphinscheduler.service.process; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import static java.util.stream.Collectors.toSet; |
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; |
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_EMPTY_SUB_PROCESS; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_FATHER_PARAMS; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; |
|
|
|
import org.apache.commons.lang.math.NumberUtils; |
|
|
|
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.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.CommandType; |
|
|
|
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.quartz.cron.CronUtils; |
|
|
|
import org.apache.dolphinscheduler.service.task.TaskPluginManager; |
|
|
|
import org.apache.dolphinscheduler.service.task.TaskPluginManager; |
|
|
|
import org.apache.dolphinscheduler.spi.enums.ResourceType; |
|
|
|
import org.apache.dolphinscheduler.spi.enums.ResourceType; |
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.apache.commons.lang.math.NumberUtils; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
@ -143,17 +147,16 @@ import java.util.Objects; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import static java.util.stream.Collectors.toSet; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_EMPTY_SUB_PROCESS; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_FATHER_PARAMS; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; |
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID; |
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.LOCAL_PARAMS; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* process relative dao that some mappers in this. |
|
|
|
* 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 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.DISPATCH.ordinal(), |
|
|
|
ExecutionStatus.RUNNING_EXECUTION.ordinal(), |
|
|
|
ExecutionStatus.RUNNING_EXECUTION.ordinal(), |
|
|
|
ExecutionStatus.DELAY_EXECUTION.ordinal(), |
|
|
|
ExecutionStatus.DELAY_EXECUTION.ordinal(), |
|
|
@ -1123,8 +1126,8 @@ public class ProcessServiceImpl implements ProcessService { |
|
|
|
if (StringUtils.isNotEmpty(parentInstanceId)) { |
|
|
|
if (StringUtils.isNotEmpty(parentInstanceId)) { |
|
|
|
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())); |
|
|
|
subProcessInstance.setVarPool(joinVarPool(parentInstance.getVarPool(), subProcessInstance.getVarPool())); |
|
|
|
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); |
|
|
@ -1167,6 +1170,26 @@ public class ProcessServiceImpl implements ProcessService { |
|
|
|
return JSONUtils.toJsonString(parentParams); |
|
|
|
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 |
|
|
|
* initialize task instance |
|
|
|
* |
|
|
|
* |
|
|
@ -2387,7 +2410,7 @@ public class ProcessServiceImpl implements ProcessService { |
|
|
|
stream() |
|
|
|
stream() |
|
|
|
.filter(t -> t.getId() != 0) |
|
|
|
.filter(t -> t.getId() != 0) |
|
|
|
.map(ResourceInfo::getId) |
|
|
|
.map(ResourceInfo::getId) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(toSet()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(resourceIds)) { |
|
|
|
if (CollectionUtils.isEmpty(resourceIds)) { |
|
|
|
return StringUtils.EMPTY; |
|
|
|
return StringUtils.EMPTY; |
|
|
@ -2549,7 +2572,7 @@ public class ProcessServiceImpl implements ProcessService { |
|
|
|
Set<Long> processDefinitionCodes = processTaskRelationList |
|
|
|
Set<Long> processDefinitionCodes = processTaskRelationList |
|
|
|
.stream() |
|
|
|
.stream() |
|
|
|
.map(ProcessTaskRelation::getProcessDefinitionCode) |
|
|
|
.map(ProcessTaskRelation::getProcessDefinitionCode) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(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) { |
|
|
|