Browse Source

transform taskCode from long to string (#5174)

Co-authored-by: JinyLeeChina <297062848@qq.com>
pull/3/MERGE
JinyLeeChina 4 years ago committed by GitHub
parent
commit
689106d114
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/ProcessDefinitionServiceImpl.java
  2. 6
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
  3. 13
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
  4. 6
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

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

@ -1400,7 +1400,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
List<TaskNode> taskNodeList = processData.getTasks();
taskNodeList.forEach(taskNode -> {
taskNode.setName(taskNode.getName() + "_copy_" + DateUtils.getCurrentTimeStamp());
taskNode.setCode(0L);
taskNode.setCode("0");
});
processData.setTasks(taskNodeList);
String processDefinitionJson = JSONUtils.toJsonString(processData);

6
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java

@ -42,7 +42,7 @@ public class TaskNode {
/**
* task node code
*/
private Long code;
private String code;
/**
* task node version
@ -327,11 +327,11 @@ public class TaskNode {
this.delayTime = delayTime;
}
public Long getCode() {
public String getCode() {
return code;
}
public void setCode(Long code) {
public void setCode(String code) {
this.code = code;
}

13
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java

@ -439,8 +439,8 @@ public class DagHelper {
List<ProcessTaskRelation> processTaskRelations) {
Map<Long, TaskNode> taskNodeMap = new HashMap<>();
taskNodeList.stream().forEach(taskNode -> {
taskNodeMap.putIfAbsent(taskNode.getCode(), taskNode);
taskNodeList.forEach(taskNode -> {
taskNodeMap.putIfAbsent(Long.parseLong(taskNode.getCode()), taskNode);
});
List<TaskNodeRelation> taskNodeRelations = new ArrayList<>();
@ -485,12 +485,9 @@ public class DagHelper {
/**
* is there have conditions after the parent node
*/
public static boolean haveConditionsAfterNode(String parentNodeName,
List<TaskNode> taskNodes
) {
boolean result = false;
public static boolean haveConditionsAfterNode(String parentNodeName, List<TaskNode> taskNodes) {
if (CollectionUtils.isEmpty(taskNodes)) {
return result;
return false;
}
for (TaskNode taskNode : taskNodes) {
List<String> preTasksList = JSONUtils.toList(taskNode.getPreTasks(), String.class);
@ -498,6 +495,6 @@ public class DagHelper {
return true;
}
}
return result;
return false;
}
}

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

@ -2340,7 +2340,7 @@ public class ProcessService {
List<TaskNode> taskNodeList = (processData.getTasks() == null) ? new ArrayList<>() : processData.getTasks();
Map<String, TaskDefinition> taskNameAndCode = new HashMap<>();
for (TaskNode taskNode : taskNodeList) {
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionCode(taskNode.getCode());
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionCode(Long.parseLong(taskNode.getCode()));
if (taskDefinition == null) {
try {
long code = SnowFlakeUtils.getInstance().nextId();
@ -2484,7 +2484,7 @@ public class ProcessService {
taskNodeMap.compute(processTaskRelation.getPostTaskCode(), (k, v) -> {
if (v == null) {
v = new TaskNode();
v.setCode(processTaskRelation.getPostTaskCode());
v.setCode(processTaskRelation.getPostTaskCode() + "");
v.setVersion(processTaskRelation.getPostTaskVersion());
v.setConditionResult(processTaskRelation.getConditionParams());
List<PreviousTaskNode> preTaskNodeList = new ArrayList<>();
@ -2504,7 +2504,7 @@ public class ProcessService {
taskNodeMap.forEach((k, v) -> {
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(k);
v.setId(locationMap.get(taskDefinitionLog.getName()));
v.setCode(taskDefinitionLog.getCode());
v.setCode(taskDefinitionLog.getCode() + "");
v.setName(taskDefinitionLog.getName());
v.setDesc(taskDefinitionLog.getDescription());
v.setType(taskDefinitionLog.getTaskType().getDescp().toUpperCase());

Loading…
Cancel
Save