From 31188ffca0061c2336742201e29bdef73139dd35 Mon Sep 17 00:00:00 2001 From: JinyLeeChina <42576980+JinyLeeChina@users.noreply.github.com> Date: Sun, 11 Apr 2021 16:52:19 +0800 Subject: [PATCH] [Feature][JsonSplit] Fix taskInstance (#5246) * Fix dependency failure * Fix taskInstance * task instance list page * code review * fix logger path Co-authored-by: JinyLeeChina <297062848@qq.com> --- .../common/utils/LoggerUtils.java | 7 +-- .../common/utils/LoggerUtilsTest.java | 2 +- .../dao/entity/TaskInstance.java | 47 +------------- .../dao/mapper/TaskInstanceMapper.java | 6 +- .../dao/mapper/TaskInstanceMapper.xml | 13 ++-- .../dao/mapper/TaskInstanceMapperTest.java | 6 +- .../server/entity/TaskExecutionContext.java | 61 +++++++++++++------ .../consumer/TaskPriorityQueueConsumer.java | 4 +- .../runner/ConditionsTaskExecThread.java | 12 ++-- .../runner/DependentTaskExecThread.java | 6 +- .../runner/MasterBaseTaskExecThread.java | 3 +- .../master/runner/MasterExecThread.java | 2 - .../server/utils/LogUtils.java | 18 ++---- .../processor/TaskExecuteProcessor.java | 1 - .../server/master/ConditionsTaskTest.java | 1 - .../server/master/DependentTaskTest.java | 2 - .../server/master/SubProcessTaskTest.java | 1 - .../TaskPriorityQueueConsumerTest.java | 11 ---- .../server/utils/LogUtilsTest.java | 15 ++--- .../processor/TaskExecuteProcessorTest.java | 1 - .../worker/runner/TaskExecuteThreadTest.java | 1 - .../runner/WorkerManagerThreadTest.java | 1 - .../server/worker/sql/SqlExecutorTest.java | 25 ++++---- .../server/worker/task/TaskManagerTest.java | 1 - .../service/process/ProcessService.java | 20 +++--- .../service/process/ProcessServiceTest.java | 3 - sql/dolphinscheduler_mysql.sql | 2 - sql/dolphinscheduler_postgre.sql | 1 - 28 files changed, 106 insertions(+), 167 deletions(-) diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java index c9e4ebf434..c9145bdcd5 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java @@ -67,20 +67,15 @@ public class LoggerUtils { * build job id * * @param affix Task Logger's prefix - * @param processDefId process define id * @param processInstId process instance id * @param taskId task id * @return task id format */ public static String buildTaskId(String affix, - int processDefId, int processInstId, int taskId) { // - [taskAppId=TASK_79_4084_15210] - return String.format(" - %s%s-%s-%s-%s]", TASK_APPID_LOG_FORMAT, affix, - processDefId, - processInstId, - taskId); + return String.format(" - %s%s-%s-%s]", TASK_APPID_LOG_FORMAT, affix, processInstId, taskId); } /** diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/LoggerUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/LoggerUtilsTest.java index 811dff5895..209e3a5f49 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/LoggerUtilsTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/LoggerUtilsTest.java @@ -42,7 +42,7 @@ public class LoggerUtilsTest { @Test public void buildTaskId() { - String taskId = LoggerUtils.buildTaskId(LoggerUtils.TASK_LOGGER_INFO_PREFIX, 79, 4084, 15210); + String taskId = LoggerUtils.buildTaskId(LoggerUtils.TASK_LOGGER_INFO_PREFIX, 4084, 15210); Assert.assertEquals(" - [taskAppId=TASK-79-4084-15210]", taskId); } 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 00f2b9a91b..a2de601916 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 @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.model.TaskNode; import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; import org.apache.dolphinscheduler.common.utils.JSONUtils; @@ -58,13 +57,6 @@ public class TaskInstance implements Serializable { */ private String taskType; - /** - * process definition id - * TODO delete - */ - @TableField(exist = false) - private int processDefinitionId; - /** * process instance id */ @@ -75,11 +67,6 @@ public class TaskInstance implements Serializable { */ private long taskCode; - /** - * process definition code - */ - private long processDefinitionCode; - /** * task defintion version */ @@ -91,13 +78,6 @@ public class TaskInstance implements Serializable { @TableField(exist = false) private String processInstanceName; - /** - * task json - * TODO delete - */ - @TableField(exist = false) - private String taskJson; - /** * state */ @@ -255,6 +235,7 @@ public class TaskInstance implements Serializable { /** * task params */ + @TableField(exist = false) private String taskParams; public void init(String host, Date startTime, String executePath) { @@ -311,14 +292,6 @@ public class TaskInstance implements Serializable { this.taskType = taskType; } - public int getProcessDefinitionId() { - return processDefinitionId; - } - - public void setProcessDefinitionId(int processDefinitionId) { - this.processDefinitionId = processDefinitionId; - } - public int getProcessInstanceId() { return processInstanceId; } @@ -327,14 +300,6 @@ public class TaskInstance implements Serializable { this.processInstanceId = processInstanceId; } - public String getTaskJson() { - return taskJson; - } - - public void setTaskJson(String taskJson) { - this.taskJson = taskJson; - } - public ExecutionStatus getState() { return state; } @@ -593,10 +558,8 @@ public class TaskInstance implements Serializable { + "id=" + id + ", name='" + name + '\'' + ", taskType='" + taskType + '\'' - + ", processDefinitionId=" + processDefinitionId + ", processInstanceId=" + processInstanceId + ", processInstanceName='" + processInstanceName + '\'' - + ", taskJson='" + taskJson + '\'' + ", state=" + state + ", firstSubmitTime=" + firstSubmitTime + ", submitTime=" + submitTime @@ -634,14 +597,6 @@ public class TaskInstance implements Serializable { this.taskCode = taskCode; } - public long getProcessDefinitionCode() { - return processDefinitionCode; - } - - public void setProcessDefinitionCode(long processDefinitionCode) { - this.processDefinitionCode = processDefinitionCode; - } - public int getTaskDefinitionVersion() { return taskDefinitionVersion; } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java index 833827bca3..898708e888 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java @@ -51,12 +51,10 @@ public interface TaskInstanceMapper extends BaseMapper { TaskInstance queryByInstanceIdAndName(@Param("processInstanceId") int processInstanceId, @Param("name") String name); - Integer countTask( - @Param("projectCodes") Long[] projectCodes, + Integer countTask(@Param("projectCodes") Long[] projectCodes, @Param("taskIds") int[] taskIds); - List countTaskInstanceStateByUser( - @Param("startTime") Date startTime, + List countTaskInstanceStateByUser(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("projectCodes") Long[] projectCodes); diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml index defccace58..96ec4bb3eb 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml @@ -19,13 +19,13 @@ - id, name, task_type, process_instance_id, task_code, task_definition_version, process_definition_code, state, submit_time, + id, name, task_type, process_instance_id, task_code, task_definition_version, state, submit_time, start_time, end_time, host, execute_path, log_path, alert_flag, retry_times, pid, app_link, flag, retry_interval, max_retry_times, task_instance_priority, worker_group, executor_id, first_submit_time, delay_time, var_pool - ${alias}.id, ${alias}.name, ${alias}.task_type, ${alias}.task_code, ${alias}.task_definition_version, ${alias}.process_definition_code, ${alias}.process_instance_id, ${alias}.state, ${alias}.submit_time, + ${alias}.id, ${alias}.name, ${alias}.task_type, ${alias}.task_code, ${alias}.task_definition_version, ${alias}.process_instance_id, ${alias}.state, ${alias}.submit_time, ${alias}.start_time, ${alias}.end_time, ${alias}.host, ${alias}.execute_path, ${alias}.log_path, ${alias}.alert_flag, ${alias}.retry_times, ${alias}.pid, ${alias}.app_link, ${alias}.flag, ${alias}.retry_interval, ${alias}.max_retry_times, ${alias}.task_instance_priority, ${alias}.worker_group, ${alias}.executor_id, ${alias}.first_submit_time, ${alias}.delay_time, ${alias}.var_pool @@ -72,7 +72,7 @@