Browse Source

[Feature][JsonSplit] Fix save process bug (#5001)

* modify checkDAGRing and ProcessService method

* merge

* modify dagRing

* modify process instance for project home page

* fix save process bug

* codeStyle

Co-authored-by: JinyLeeChina <297062848@qq.com>
pull/3/MERGE
JinyLeeChina 4 years ago committed by GitHub
parent
commit
7f0678d3be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
  2. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskType.java
  3. 39
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelation.java
  4. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java
  5. 31
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java
  6. 4
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java
  7. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapper.java
  8. 1
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapper.xml
  9. 2
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapper.xml
  10. 4
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapperTest.java
  11. 19
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java

@ -285,7 +285,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
taskDefinition.setFailRetryTimes(taskDefinitionLog.getFailRetryTimes());
taskDefinition.setFailRetryInterval(taskDefinitionLog.getFailRetryInterval());
taskDefinition.setTimeoutFlag(taskDefinitionLog.getTimeoutFlag());
taskDefinition.setTaskTimeoutStrategy(taskDefinitionLog.getTaskTimeoutStrategy());
taskDefinition.setTimeoutNotifyStrategy(taskDefinitionLog.getTimeoutNotifyStrategy());
taskDefinition.setTimeout(taskDefinitionLog.getTimeout());
taskDefinition.setUpdateTime(new Date());
taskDefinition.setResourceIds(taskDefinitionLog.getResourceIds());

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskType.java

@ -87,6 +87,7 @@ public enum TaskType {
}
public static TaskType of(String descp) {
descp = descp.toLowerCase();
if (TASK_TYPE_MAP.containsKey(descp)) {
return TASK_TYPE_MAP.get(descp);
}

39
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelation.java

@ -95,18 +95,6 @@ public class ProcessTaskRelation {
*/
private String conditionParams;
/**
* condition parameter list
*/
@TableField(exist = false)
private List<Property> conditionParamList;
/**
* condition parameter map
*/
@TableField(exist = false)
private Map<String, String> conditionParamMap;
/**
* create time
*/
@ -181,36 +169,9 @@ public class ProcessTaskRelation {
}
public void setConditionParams(String conditionParams) {
if (conditionParams == null) {
this.conditionParamList = new ArrayList<>();
} else {
this.conditionParamList = JSONUtils.toList(conditionParams, Property.class);
}
this.conditionParams = conditionParams;
}
public List<Property> getConditionParamList() {
return conditionParamList;
}
public void setConditionParamList(List<Property> conditionParamList) {
this.conditionParams = JSONUtils.toJsonString(conditionParamList);
this.conditionParamList = conditionParamList;
}
public Map<String, String> getConditionParamMap() {
if (conditionParamMap == null && StringUtils.isNotEmpty(conditionParams)) {
List<Property> propList = JSONUtils.toList(conditionParams, Property.class);
conditionParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
}
return conditionParamMap;
}
public void setConditionParamMap(Map<String, String> conditionParamMap) {
this.conditionParamMap = conditionParamMap;
}
public int getProcessDefinitionVersion() {
return processDefinitionVersion;
}

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java

@ -56,8 +56,6 @@ public class ProcessTaskRelationLog extends ProcessTaskRelation {
this.setPostTaskVersion(processTaskRelation.getPostTaskVersion());
this.setConditionType(processTaskRelation.getConditionType());
this.setConditionParams(processTaskRelation.getConditionParams());
this.setConditionParamList(processTaskRelation.getConditionParamList());
this.setConditionParamMap(processTaskRelation.getConditionParamMap());
this.setCreateTime(processTaskRelation.getCreateTime());
this.setUpdateTime(processTaskRelation.getUpdateTime());
}

31
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java

@ -146,7 +146,7 @@ public class TaskDefinition {
/**
* timeout notify strategy
*/
private TaskTimeoutStrategy taskTimeoutStrategy;
private TaskTimeoutStrategy timeoutNotifyStrategy;
/**
* task warning time out. unit: minute
@ -247,36 +247,25 @@ public class TaskDefinition {
}
public void setTaskParams(String taskParams) {
if (taskParams == null) {
this.taskParamList = new ArrayList<>();
} else {
this.taskParamList = JSONUtils.toList(taskParams, Property.class);
}
this.taskParams = taskParams;
}
public List<Property> getTaskParamList() {
return taskParamList;
}
List<Property> propList = JSONUtils.toList(JSONUtils.parseObject(taskParams).findValue("localParams").toString(),
Property.class);
return taskParamList = propList;
public void setTaskParamList(List<Property> taskParamList) {
this.taskParams = JSONUtils.toJsonString(taskParamList);
this.taskParamList = taskParamList;
}
public Map<String, String> getTaskParamMap() {
if (taskParamMap == null && StringUtils.isNotEmpty(taskParams)) {
List<Property> propList = JSONUtils.toList(taskParams, Property.class);
List<Property> propList = JSONUtils.toList(JSONUtils.parseObject(taskParams).findValue("localParams").toString(),
Property.class);
taskParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
}
return taskParamMap;
}
public void setTaskParamMap(Map<String, String> taskParamMap) {
this.taskParamMap = taskParamMap;
}
public int getTimeout() {
return timeout;
}
@ -357,12 +346,12 @@ public class TaskDefinition {
this.failRetryInterval = failRetryInterval;
}
public TaskTimeoutStrategy getTaskTimeoutStrategy() {
return taskTimeoutStrategy;
public TaskTimeoutStrategy getTimeoutNotifyStrategy() {
return timeoutNotifyStrategy;
}
public void setTaskTimeoutStrategy(TaskTimeoutStrategy taskTimeoutStrategy) {
this.taskTimeoutStrategy = taskTimeoutStrategy;
public void setTimeoutNotifyStrategy(TaskTimeoutStrategy timeoutNotifyStrategy) {
this.timeoutNotifyStrategy = timeoutNotifyStrategy;
}
public TimeoutFlag getTimeoutFlag() {

4
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java

@ -57,10 +57,8 @@ public class TaskDefinitionLog extends TaskDefinition {
this.setProjectName(taskDefinition.getProjectName());
this.setResourceIds(taskDefinition.getResourceIds());
this.setTaskParams(taskDefinition.getTaskParams());
this.setTaskParamList(taskDefinition.getTaskParamList());
this.setTaskParamMap(taskDefinition.getTaskParamMap());
this.setTaskPriority(taskDefinition.getTaskPriority());
this.setTaskTimeoutStrategy(taskDefinition.getTaskTimeoutStrategy());
this.setTimeoutNotifyStrategy(taskDefinition.getTimeoutNotifyStrategy());
this.setTaskType(taskDefinition.getTaskType());
this.setTimeout(taskDefinition.getTimeout());
this.setTimeoutFlag(taskDefinition.getTimeoutFlag());

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapper.java

@ -53,7 +53,7 @@ public interface ProcessDefinitionLogMapper extends BaseMapper<ProcessDefinition
/**
* query max version for definition
*/
int queryMaxVersionForDefinition(@Param("processDefinitionCode") long processDefinitionCode);
Integer queryMaxVersionForDefinition(@Param("processDefinitionCode") long processDefinitionCode);
/**
* query the certain process definition version info by process definition code and version number

1
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapper.xml

@ -54,7 +54,6 @@
select max(version)
from t_ds_process_definition_log
where code = #{processDefinitionCode}
</select>
<select id="queryProcessDefinitionVersionsPaging"

2
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapper.xml

@ -27,7 +27,7 @@
select
<include refid="baseSql"/>
from t_ds_task_definition
WHERE projectCode = #{projectCode}
WHERE project_code = #{projectCode}
and `name` = #{taskDefinitionName}
</select>
<select id="queryAllDefinitionList" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinition">

4
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapperTest.java

@ -151,8 +151,8 @@ public class ProcessDefinitionLogMapperTest {
ProcessDefinitionLog processDefinitionLog = insertOne();
ProcessDefinitionLog processDefinitionLog1 = insertTwo();
int version = processDefinitionLogMapper.queryMaxVersionForDefinition(1L);
Assert.assertEquals(2, version);
Integer version = processDefinitionLogMapper.queryMaxVersionForDefinition(1L);
Assert.assertEquals(2, version == null ? 1 : version);
}
@Test

19
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

@ -2193,7 +2193,7 @@ public class ProcessService {
taskDefinition.setFailRetryTimes(taskNode.getMaxRetryTimes());
taskDefinition.setFailRetryInterval(taskNode.getRetryInterval());
taskDefinition.setTimeoutFlag(taskNode.getTaskTimeoutParameter().getEnable() ? TimeoutFlag.OPEN : TimeoutFlag.CLOSE);
taskDefinition.setTaskTimeoutStrategy(taskNode.getTaskTimeoutParameter().getStrategy());
taskDefinition.setTimeoutNotifyStrategy(taskNode.getTaskTimeoutParameter().getStrategy());
taskDefinition.setTimeout(taskNode.getTaskTimeoutParameter().getInterval());
taskDefinition.setResourceIds(getResourceIds(taskDefinition));
}
@ -2207,7 +2207,7 @@ public class ProcessService {
public String getResourceIds(TaskDefinition taskDefinition) {
Set<Integer> resourceIds = null;
// TODO modify taskDefinition.getTaskType()
AbstractParameters params = TaskParametersUtils.getParameters(taskDefinition.getTaskType().getDescp(), taskDefinition.getTaskParams());
AbstractParameters params = TaskParametersUtils.getParameters(taskDefinition.getTaskType().getDescp().toUpperCase(), taskDefinition.getTaskParams());
if (params != null && CollectionUtils.isNotEmpty(params.getResourceFilesList())) {
resourceIds = params.getResourceFilesList().
@ -2240,9 +2240,9 @@ public class ProcessService {
ProcessData processData, Project project,
String desc, String locations, String connects) {
ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog();
int version = processDefineLogMapper.queryMaxVersionForDefinition(processDefinitionLog.getCode());
Integer version = processDefineLogMapper.queryMaxVersionForDefinition(processDefinitionCode);
processDefinitionLog.setCode(processDefinitionCode);
processDefinitionLog.setVersion(version);
processDefinitionLog.setVersion(version == null || version == 0 ? 1 : version);
processDefinitionLog.setName(processDefinitionName);
processDefinitionLog.setReleaseState(ReleaseState.OFFLINE);
processDefinitionLog.setProjectCode(project.getCode());
@ -2252,9 +2252,10 @@ public class ProcessService {
processDefinitionLog.setTimeout(processData.getTimeout());
processDefinitionLog.setTenantId(processData.getTenantId());
processDefinitionLog.setOperator(operator.getId());
Date updateTime = new Date();
processDefinitionLog.setOperateTime(updateTime);
processDefinitionLog.setUpdateTime(updateTime);
Date now = new Date();
processDefinitionLog.setOperateTime(now);
processDefinitionLog.setUpdateTime(now);
processDefinitionLog.setCreateTime(now);
//custom global params
List<Property> globalParamsList = new ArrayList<>();
@ -2443,7 +2444,7 @@ public class ProcessService {
v.setCode(taskDefinitionLog.getCode());
v.setName(taskDefinitionLog.getName());
v.setDesc(taskDefinitionLog.getDescription());
v.setType(taskDefinitionLog.getTaskType().getDescp());
v.setType(taskDefinitionLog.getTaskType().getDescp().toUpperCase());
v.setRunFlag(taskDefinitionLog.getFlag() == Flag.YES ? Constants.FLOWNODE_RUN_FLAG_FORBIDDEN : "NORMAL");
v.setMaxRetryTimes(taskDefinitionLog.getFailRetryTimes());
v.setRetryInterval(taskDefinitionLog.getFailRetryInterval());
@ -2451,7 +2452,7 @@ public class ProcessService {
v.setTaskInstancePriority(taskDefinitionLog.getTaskPriority());
v.setWorkerGroup(taskDefinitionLog.getWorkerGroup());
v.setTimeout(JSONUtils.toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN,
taskDefinitionLog.getTaskTimeoutStrategy(),
taskDefinitionLog.getTimeoutNotifyStrategy(),
taskDefinitionLog.getTimeout())));
// TODO name will be remove
v.getPreTaskNodeList().forEach(task -> task.setName(taskDefinitionLogMap.get(task.getCode()).getName()));

Loading…
Cancel
Save