This is an automated email from the ASF dual-hosted git repository.

zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 177a001392 Remove unused dependentResult in TaskInstance (#16236)
177a001392 is described below

commit 177a001392467dd6eb6f1a2aa1175b0a5a3ef221
Author: Wenjun Ruan <[email protected]>
AuthorDate: Sun Jun 30 18:56:53 2024 +0800

    Remove unused dependentResult in TaskInstance (#16236)
---
 .../api/service/ProcessInstanceService.java        |  3 --
 .../service/impl/ProcessInstanceServiceImpl.java   | 63 +---------------------
 .../api/service/ProcessInstanceServiceTest.java    | 18 -------
 .../dolphinscheduler/dao/entity/TaskInstance.java  |  6 ---
 .../dao/utils/TaskInstanceUtils.java               |  1 -
 5 files changed, 1 insertion(+), 90 deletions(-)

diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
index 7bf49e0016..4df7a69da5 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
@@ -25,7 +25,6 @@ import org.apache.dolphinscheduler.api.utils.Result;
 import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
 import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
 import org.apache.dolphinscheduler.dao.entity.User;
-import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult;
 
 import java.io.IOException;
 import java.util.List;
@@ -122,8 +121,6 @@ public interface ProcessInstanceService {
                                                  long projectCode,
                                                  Integer processId) throws 
IOException;
 
-    Map<String, DependResult> parseLogForDependentResult(String log) throws 
IOException;
-
     /**
      * query sub process instance detail info by task id
      *
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
index 5e5d703017..11ff034bb6 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
@@ -21,7 +21,6 @@ import static 
org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationCon
 import static 
org.apache.dolphinscheduler.api.enums.Status.PROCESS_INSTANCE_NOT_EXIST;
 import static 
org.apache.dolphinscheduler.api.enums.Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR;
 import static org.apache.dolphinscheduler.common.constants.Constants.DATA_LIST;
-import static 
org.apache.dolphinscheduler.common.constants.Constants.DEPENDENT_SPLIT;
 import static 
org.apache.dolphinscheduler.common.constants.Constants.GLOBAL_PARAMS;
 import static 
org.apache.dolphinscheduler.common.constants.Constants.LOCAL_PARAMS;
 import static 
org.apache.dolphinscheduler.common.constants.Constants.PROCESS_INSTANCE_STATE;
@@ -59,7 +58,6 @@ import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
 import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog;
 import org.apache.dolphinscheduler.dao.entity.Project;
 import org.apache.dolphinscheduler.dao.entity.RelationSubWorkflow;
-import org.apache.dolphinscheduler.dao.entity.ResponseTaskLog;
 import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
 import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
 import org.apache.dolphinscheduler.dao.entity.TaskInstance;
@@ -76,7 +74,6 @@ import 
org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
 import org.apache.dolphinscheduler.dao.repository.ProcessInstanceMapDao;
 import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
 import org.apache.dolphinscheduler.dao.utils.WorkflowUtils;
-import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult;
 import org.apache.dolphinscheduler.plugin.task.api.model.Property;
 import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
 import org.apache.dolphinscheduler.plugin.task.api.utils.TaskTypeUtils;
@@ -86,11 +83,6 @@ import 
org.apache.dolphinscheduler.service.process.ProcessService;
 
 import org.apache.commons.lang3.StringUtils;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -446,11 +438,10 @@ public class ProcessInstanceServiceImpl extends 
BaseServiceImpl implements Proce
      * @param projectCode project code
      * @param processId   process instance id
      * @return task list for the process instance
-     * @throws IOException io exception
      */
     @Override
     public Map<String, Object> queryTaskListByProcessId(User loginUser, long 
projectCode,
-                                                        Integer processId) 
throws IOException {
+                                                        Integer processId) {
         Project project = projectMapper.queryByCode(projectCode);
         // check user access for project
         Map<String, Object> result =
@@ -471,7 +462,6 @@ public class ProcessInstanceServiceImpl extends 
BaseServiceImpl implements Proce
         }
         List<TaskInstance> taskInstanceList =
                 
taskInstanceDao.queryValidTaskListByWorkflowInstanceId(processId, 
processInstance.getTestFlag());
-        addDependResultForTaskList(loginUser, taskInstanceList);
         Map<String, Object> resultMap = new HashMap<>();
         resultMap.put(PROCESS_INSTANCE_STATE, 
processInstance.getState().toString());
         resultMap.put(TASK_LIST, taskInstanceList);
@@ -541,57 +531,6 @@ public class ProcessInstanceServiceImpl extends 
BaseServiceImpl implements Proce
         return allDynamicSubWorkflowDtos;
     }
 
-    /**
-     * add dependent result for dependent task
-     */
-    private void addDependResultForTaskList(User loginUser, List<TaskInstance> 
taskInstanceList) throws IOException {
-        for (TaskInstance taskInstance : taskInstanceList) {
-            if (TaskTypeUtils.isDependentTask(taskInstance.getTaskType())) {
-                log.info("DEPENDENT type task instance need to set dependent 
result, taskCode:{}, taskInstanceId:{}",
-                        taskInstance.getTaskCode(), taskInstance.getId());
-                // TODO The result of dependent item should not be obtained 
from the log, waiting for optimization.
-                Result<ResponseTaskLog> logResult = 
loggerService.queryLog(loginUser,
-                        taskInstance.getId(), 
Constants.LOG_QUERY_SKIP_LINE_NUMBER, Constants.LOG_QUERY_LIMIT);
-                if (logResult.getCode() == Status.SUCCESS.ordinal()) {
-                    String log = logResult.getData().getMessage();
-                    Map<String, DependResult> resultMap = 
parseLogForDependentResult(log);
-                    
taskInstance.setDependentResult(JSONUtils.toJsonString(resultMap));
-                }
-            }
-        }
-    }
-
-    @Override
-    public Map<String, DependResult> parseLogForDependentResult(String 
content) throws IOException {
-        Map<String, DependResult> resultMap = new HashMap<>();
-        if (StringUtils.isEmpty(content)) {
-            log.warn("Log content is empty.");
-            return resultMap;
-        }
-
-        BufferedReader br = new BufferedReader(new InputStreamReader(new 
ByteArrayInputStream(content.getBytes(
-                StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
-        String line;
-        while ((line = br.readLine()) != null) {
-            if (line.contains(DEPENDENT_SPLIT)) {
-                String[] tmpStringArray = line.split(":\\|\\|");
-                if (tmpStringArray.length != 2) {
-                    continue;
-                }
-                String dependResultString = tmpStringArray[1];
-                String[] dependStringArray = dependResultString.split(",");
-                if (dependStringArray.length != 3) {
-                    continue;
-                }
-                String key = dependStringArray[0].trim().split(":")[1].trim();
-                String result = 
dependStringArray[1].trim().split(":")[1].trim();
-                DependResult dependResult = DependResult.valueOf(result);
-                resultMap.put(key, dependResult);
-            }
-        }
-        return resultMap;
-    }
-
     /**
      * query sub process instance detail info by task id
      *
diff --git 
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java
 
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java
index 208d880fc1..26bbc95412 100644
--- 
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java
+++ 
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java
@@ -64,7 +64,6 @@ import 
org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
 import org.apache.dolphinscheduler.dao.repository.ProcessInstanceMapDao;
 import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
 import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
-import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult;
 import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
 import org.apache.dolphinscheduler.service.expand.CuringParamsService;
 import org.apache.dolphinscheduler.service.model.TaskNode;
@@ -481,23 +480,6 @@ public class ProcessInstanceServiceTest {
         Assertions.assertEquals(Status.SUCCESS, 
successRes.get(Constants.STATUS));
     }
 
-    @Test
-    public void testParseLogForDependentResult() throws IOException {
-        String logString =
-                "[INFO] 2019-03-19 17:11:08.475 
org.apache.dolphinscheduler.server.worker.log.TaskLogger:[172]"
-                        + " - [taskAppId=TASK_223_10739_452334] dependent item 
complete, :|| dependentKey: 223-ALL-day-last1Day, result: SUCCESS, 
dependentDate: Wed Mar 19 17:10:36 CST 2019\n"
-                        + "[INFO] 2019-03-19 17:11:08.476 
org.apache.dolphinscheduler.server.worker.runner.TaskScheduleThread:[172]"
-                        + " - task : 223_10739_452334 exit status code : 0\n"
-                        + "[root@node2 current]# ";
-        Map<String, DependResult> resultMap =
-                processInstanceService.parseLogForDependentResult(logString);
-        Assertions.assertEquals(1, resultMap.size());
-
-        resultMap.clear();
-        resultMap = processInstanceService.parseLogForDependentResult("");
-        Assertions.assertEquals(0, resultMap.size());
-    }
-
     @Test
     public void testQuerySubProcessInstanceByTaskId() {
         long projectCode = 1L;
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 629cfe9aea..81b99c1588 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
@@ -201,12 +201,6 @@ public class TaskInstance implements Serializable {
     @TableField(exist = false)
     private Priority processInstancePriority;
 
-    /**
-     * dependent state
-     */
-    @TableField(exist = false)
-    private String dependentResult;
-
     /**
      * workerGroup
      */
diff --git 
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java
 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java
index e23fcb97b5..6c1c7f03a3 100644
--- 
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java
+++ 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java
@@ -62,7 +62,6 @@ public class TaskInstanceUtils {
         target.setMaxRetryTimes(source.getMaxRetryTimes());
         target.setRetryInterval(source.getRetryInterval());
         target.setTaskInstancePriority(source.getTaskInstancePriority());
-        target.setDependentResult(source.getDependentResult());
         target.setWorkerGroup(source.getWorkerGroup());
         target.setEnvironmentCode(source.getEnvironmentCode());
         target.setEnvironmentConfig(source.getEnvironmentConfig());

Reply via email to