diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java index db3cd14326..148df29cc0 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java @@ -789,6 +789,8 @@ public final class Constants { public static final String SUBPROCESS_INSTANCE_ID = "subProcessInstanceId"; public static final String PROCESS_INSTANCE_STATE = "processInstanceState"; public static final String PARENT_WORKFLOW_INSTANCE = "parentWorkflowInstance"; + public static final String CONDITION_RESULT = "conditionResult"; + public static final String DEPENDENCE = "dependence"; public static final String TASK_TYPE = "taskType"; public static final String TASK_LIST = "taskList"; public static final String RWXR_XR_X = "rwxr-xr-x"; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java index 89efe2edfc..b9c5a282ff 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java @@ -25,7 +25,9 @@ import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.StringUtils; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -371,6 +373,24 @@ public class TaskNode { this.preTaskNodeList = preTaskNodeList; } + public String getTaskParams() { + Map taskParams = JSONUtils.toMap(this.params, String.class, Object.class); + if (taskParams == null) { + taskParams = new HashMap<>(); + } + taskParams.put(Constants.CONDITION_RESULT, this.conditionResult); + taskParams.put(Constants.DEPENDENCE, this.dependence); + return JSONUtils.toJsonString(taskParams); + } + + public Map taskParamsToJsonObj(String taskParams) { + Map taskParamsMap = JSONUtils.toMap(taskParams, String.class, Object.class); + if (taskParamsMap == null) { + taskParamsMap = new HashMap<>(); + } + return taskParamsMap; + } + @Override public String toString() { return "TaskNode{" diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/VarPoolUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/VarPoolUtils.java index 3d4f65ab50..cd300e3f03 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/VarPoolUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/VarPoolUtils.java @@ -39,8 +39,7 @@ public class VarPoolUtils { */ public static void setTaskNodeLocalParams(TaskNode taskNode, Map propToValue) { String taskParamsJson = taskNode.getParams(); - Map taskParams = JSONUtils.parseObject(taskParamsJson, HashMap.class); - + Map taskParams = JSONUtils.toMap(taskParamsJson, String.class, Object.class); Object localParamsObject = taskParams.get(LOCALPARAMS); if (null != localParamsObject && null != propToValue && propToValue.size() > 0) { ArrayList localParams = (ArrayList)localParamsObject; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java index e757ea30ea..f4ef1a9b75 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java @@ -152,6 +152,11 @@ public class TaskDefinition { */ private int timeout; + /** + * delay execution time. + */ + private int delayTime; + /** * resource ids */ @@ -381,6 +386,14 @@ public class TaskDefinition { this.resourceIds = resourceIds; } + public int getDelayTime() { + return delayTime; + } + + public void setDelayTime(int delayTime) { + this.delayTime = delayTime; + } + @Override public String toString() { return "TaskDefinition{" @@ -405,6 +418,7 @@ public class TaskDefinition { + ", timeoutFlag=" + timeoutFlag + ", timeoutNotifyStrategy=" + timeoutNotifyStrategy + ", timeout=" + timeout + + ", delayTime=" + delayTime + ", resourceIds='" + resourceIds + '\'' + ", createTime=" + createTime + ", updateTime=" + updateTime diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java index dfade537ce..96851cc7b8 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java @@ -63,6 +63,7 @@ public class TaskDefinitionLog extends TaskDefinition { this.setTimeoutNotifyStrategy(taskDefinition.getTimeoutNotifyStrategy()); this.setTaskType(taskDefinition.getTaskType()); this.setTimeout(taskDefinition.getTimeout()); + this.setDelayTime(taskDefinition.getDelayTime()); this.setTimeoutFlag(taskDefinition.getTimeoutFlag()); this.setUpdateTime(taskDefinition.getUpdateTime()); this.setCreateTime(taskDefinition.getCreateTime()); diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java index b417d2f96f..3733c6d58a 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java @@ -17,6 +17,7 @@ package org.apache.dolphinscheduler.dao.entity; +import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; @@ -415,7 +416,8 @@ public class TaskInstance implements Serializable { public DependentParameters getDependency() { if (this.dependency == null) { - this.dependency = JSONUtils.parseObject(this.getTaskParams(), DependentParameters.class); + Map taskParamsMap = JSONUtils.toMap(this.getTaskParams(), String.class, Object.class); + this.dependency = JSONUtils.parseObject((String) taskParamsMap.get(Constants.DEPENDENCE), DependentParameters.class); } return this.dependency; } diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapper.xml index 673a266bc2..7f31843b9d 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapper.xml @@ -20,13 +20,13 @@ id, code, `name`, version, description, project_code, user_id, task_type, task_params, flag, task_priority, - worker_group, fail_retry_times, fail_retry_interval, timeout_flag, timeout_notify_strategy, timeout, + worker_group, fail_retry_times, fail_retry_interval, timeout_flag, timeout_notify_strategy, timeout, delay_time, resource_ids, operator, operate_time, create_time, update_time @@ -63,8 +63,8 @@