caishunfeng commented on code in PR #13948:
URL: 
https://github.com/apache/dolphinscheduler/pull/13948#discussion_r1173329989


##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java:
##########
@@ -321,6 +321,7 @@ public void setDependency(DependentParameters dependency) {
     }
 
     public SwitchParameters getSwitchDependency() {
+        // todo: Why we don't directly use Jackson...... shit

Review Comment:
   :rofl:  While this code may look bad, but I think we shouldn't leave 
personal comments.



##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/ProcessInstanceDao.java:
##########
@@ -87,4 +87,6 @@ public interface ProcessInstanceDao {
      * @return process instance
      */
     ProcessInstance 
queryFirstStartProcessInstance(@Param("processDefinitionCode") Long 
definitionCode);
+
+    ProcessInstance findSubProcessInstanceByParentId(int processInstanceId, 
int taskInstanceId);

Review Comment:
   It's better to use `Integer`
   ```suggestion
       ProcessInstance findSubProcessInstanceByParentId(Integer 
processInstanceId, Integer taskInstanceId);
   ```



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java:
##########
@@ -2078,21 +2063,27 @@ private boolean isNewProcessInstance() {
     }
 
     public void resubmit(long taskCode) throws Exception {
-        ITaskProcessor taskProcessor = activeTaskProcessorMaps.get(taskCode);
-        if (taskProcessor != null) {
-            taskProcessor.action(TaskAction.RESUBMIT);
-            log.debug("RESUBMIT: task code:{}", taskCode);
-        } else {
-            throw new Exception("resubmit error, taskProcessor is null, task 
code: " + taskCode);
-        }
+        // todo: resubmit
+        // taskExecuteRunnableMap.get(taskCode).resubmit();
+        // ITaskProcessor taskProcessor = 
activeTaskProcessorMaps.get(taskCode);
+        // if (taskProcessor != null) {
+        // taskProcessor.action(TaskAction.RESUBMIT);
+        // log.debug("RESUBMIT: task code:{}", taskCode);
+        // } else {
+        // throw new Exception("resubmit error, taskProcessor is null, task 
code: " + taskCode);
+        // }
     }
 
     public Map<Long, Integer> getCompleteTaskMap() {
         return completeTaskMap;
     }
 
-    public Map<Long, ITaskProcessor> getActiveTaskProcessMap() {
-        return activeTaskProcessorMaps;
+    // public Map<Long, ITaskProcessor> getActiveTaskProcessMap() {

Review Comment:
   It seems that many commented places have not been deleted, and need to be 
checked completely.



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java:
##########
@@ -377,12 +385,14 @@ public ProcessInstance getProcessInstance() {
     }
 
     public boolean checkForceStartAndWakeUp(StateEvent stateEvent) {
-        TaskGroupQueue taskGroupQueue = 
this.processService.loadTaskGroupQueue(stateEvent.getTaskInstanceId());
+        TaskGroupQueue taskGroupQueue = 
processService.loadTaskGroupQueue(stateEvent.getTaskInstanceId());
         if (taskGroupQueue.getForceStart() == Flag.YES.getCode()) {
             log.info("Begin to force start taskGroupQueue: {}", 
taskGroupQueue.getId());
-            TaskInstance taskInstance = 
this.taskInstanceDao.findTaskInstanceById(stateEvent.getTaskInstanceId());
-            ITaskProcessor taskProcessor = 
activeTaskProcessorMaps.get(taskInstance.getTaskCode());
-            taskProcessor.action(TaskAction.DISPATCH);
+            TaskInstance taskInstance = 
taskInstanceDao.findTaskInstanceById(stateEvent.getTaskInstanceId());
+
+            taskExecuteRunnableMap.get(taskInstance.getTaskCode()).dispatch();
+            // ITaskProcessor taskProcessor = 
activeTaskProcessorMaps.get(taskInstance.getTaskCode());
+            // taskProcessor.action(TaskAction.DISPATCH);

Review Comment:
   remove?
   ```suggestion
   ```



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/BaseTaskDispatcher.java:
##########
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.server.master.runner;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.apache.dolphinscheduler.common.enums.TaskEventType;
+import org.apache.dolphinscheduler.common.utils.DateUtils;
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.task.TaskDispatchRequest;
+import org.apache.dolphinscheduler.remote.command.task.TaskDispatchResponse;
+import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
+import org.apache.dolphinscheduler.remote.utils.Host;
+import org.apache.dolphinscheduler.server.master.config.MasterConfig;
+import 
org.apache.dolphinscheduler.server.master.dispatch.exceptions.WorkerGroupNotFoundException;
+import 
org.apache.dolphinscheduler.server.master.exception.TaskDispatchException;
+import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
+import 
org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService;
+import org.apache.dolphinscheduler.server.master.rpc.MasterRpcClient;
+import 
org.apache.dolphinscheduler.server.master.runner.dispatcher.TaskDispatcher;
+import 
org.apache.dolphinscheduler.server.master.runner.execute.TaskExecuteRunnable;
+
+import java.util.Date;
+import java.util.Optional;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public abstract class BaseTaskDispatcher implements TaskDispatcher {
+
+    protected final TaskEventService taskEventService;
+    protected final MasterConfig masterConfig;
+    protected final MasterRpcClient masterRpcClient;
+
+    protected BaseTaskDispatcher(TaskEventService taskEventService,
+                                 MasterConfig masterConfig,
+                                 MasterRpcClient masterRpcClient) {
+        this.taskEventService = checkNotNull(taskEventService);
+        this.masterConfig = checkNotNull(masterConfig);
+        this.masterRpcClient = checkNotNull(masterRpcClient);
+    }
+
+    @Override
+    public void dispatchTask(TaskExecuteRunnable taskExecuteRunnable) throws 
TaskDispatchException {
+        Host taskInstanceDispatchHost;
+        try {
+            taskInstanceDispatchHost = 
getTaskInstanceDispatchHost(taskExecuteRunnable)
+                    .orElseThrow(() -> new TaskDispatchException("Cannot find 
the host to execute task."));
+        } catch (WorkerGroupNotFoundException workerGroupNotFoundException) {
+            log.error("Dispatch task: {} failed, worker group not found.",
+                    
taskExecuteRunnable.getTaskExecutionContext().getTaskName(), 
workerGroupNotFoundException);
+            addDispatchFailedEvent(taskExecuteRunnable);
+            return;
+        }
+        // todo: why we need to add field host to taskExecutionContext?
+        // it's better to make the dispatch in sync, then we can get the host 
from dispatch response.

Review Comment:
   +1



##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/TaskInstanceDaoImpl.java:
##########
@@ -77,15 +77,16 @@ public boolean updateTaskInstance(TaskInstance 
taskInstance) {
         return count > 0;
     }
 
+    // todo: remove the result

Review Comment:
   Remove if done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to