|
|
@ -62,6 +62,7 @@ import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; |
|
|
|
import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; |
|
|
|
import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; |
|
|
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; |
|
|
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; |
|
|
|
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
|
|
|
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; |
|
|
|
import org.apache.dolphinscheduler.remote.command.HostUpdateCommand; |
|
|
|
import org.apache.dolphinscheduler.remote.command.HostUpdateCommand; |
|
|
|
import org.apache.dolphinscheduler.remote.utils.Host; |
|
|
|
import org.apache.dolphinscheduler.remote.utils.Host; |
|
|
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig; |
|
|
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig; |
|
|
@ -341,23 +342,33 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> { |
|
|
|
public boolean checkForceStartAndWakeUp(StateEvent stateEvent) { |
|
|
|
public boolean checkForceStartAndWakeUp(StateEvent stateEvent) { |
|
|
|
TaskGroupQueue taskGroupQueue = this.processService.loadTaskGroupQueue(stateEvent.getTaskInstanceId()); |
|
|
|
TaskGroupQueue taskGroupQueue = this.processService.loadTaskGroupQueue(stateEvent.getTaskInstanceId()); |
|
|
|
if (taskGroupQueue.getForceStart() == Flag.YES.getCode()) { |
|
|
|
if (taskGroupQueue.getForceStart() == Flag.YES.getCode()) { |
|
|
|
|
|
|
|
logger.info("Begin to force start taskGroupQueue: {}", taskGroupQueue.getId()); |
|
|
|
TaskInstance taskInstance = this.processService.findTaskInstanceById(stateEvent.getTaskInstanceId()); |
|
|
|
TaskInstance taskInstance = this.processService.findTaskInstanceById(stateEvent.getTaskInstanceId()); |
|
|
|
ITaskProcessor taskProcessor = activeTaskProcessorMaps.get(taskInstance.getTaskCode()); |
|
|
|
ITaskProcessor taskProcessor = activeTaskProcessorMaps.get(taskInstance.getTaskCode()); |
|
|
|
taskProcessor.action(TaskAction.DISPATCH); |
|
|
|
taskProcessor.action(TaskAction.DISPATCH); |
|
|
|
this.processService.updateTaskGroupQueueStatus(taskGroupQueue.getTaskId(), |
|
|
|
this.processService.updateTaskGroupQueueStatus(taskGroupQueue.getTaskId(), |
|
|
|
TaskGroupQueueStatus.ACQUIRE_SUCCESS.getCode()); |
|
|
|
TaskGroupQueueStatus.ACQUIRE_SUCCESS.getCode()); |
|
|
|
|
|
|
|
logger.info("Success force start taskGroupQueue: {}", taskGroupQueue.getId()); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (taskGroupQueue.getInQueue() == Flag.YES.getCode()) { |
|
|
|
if (taskGroupQueue.getInQueue() == Flag.YES.getCode()) { |
|
|
|
|
|
|
|
logger.info("Begin to wake up taskGroupQueue: {}", taskGroupQueue.getId()); |
|
|
|
boolean acquireTaskGroup = processService.robTaskGroupResource(taskGroupQueue); |
|
|
|
boolean acquireTaskGroup = processService.robTaskGroupResource(taskGroupQueue); |
|
|
|
if (acquireTaskGroup) { |
|
|
|
if (acquireTaskGroup) { |
|
|
|
TaskInstance taskInstance = this.processService.findTaskInstanceById(stateEvent.getTaskInstanceId()); |
|
|
|
TaskInstance taskInstance = this.processService.findTaskInstanceById(stateEvent.getTaskInstanceId()); |
|
|
|
ITaskProcessor taskProcessor = activeTaskProcessorMaps.get(taskInstance.getTaskCode()); |
|
|
|
ITaskProcessor taskProcessor = activeTaskProcessorMaps.get(taskInstance.getTaskCode()); |
|
|
|
taskProcessor.action(TaskAction.DISPATCH); |
|
|
|
taskProcessor.action(TaskAction.DISPATCH); |
|
|
|
|
|
|
|
logger.info("Success wake up taskGroupQueue: {}", taskGroupQueue.getId()); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
logger.warn("Failed to wake up taskGroupQueue, taskGroupQueueId: {}", taskGroupQueue.getId()); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
logger.info( |
|
|
|
|
|
|
|
"Failed to wake up the taskGroupQueue: {}, since the taskGroupQueue is not in queue, will no need to wake up.", |
|
|
|
|
|
|
|
taskGroupQueue); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void processTimeout() { |
|
|
|
public void processTimeout() { |
|
|
@ -425,7 +436,6 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> { |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void releaseTaskGroup(TaskInstance taskInstance) { |
|
|
|
public void releaseTaskGroup(TaskInstance taskInstance) { |
|
|
|
logger.info("Release task group"); |
|
|
|
|
|
|
|
if (taskInstance.getTaskGroupId() > 0) { |
|
|
|
if (taskInstance.getTaskGroupId() > 0) { |
|
|
|
TaskInstance nextTaskInstance = this.processService.releaseTaskGroup(taskInstance); |
|
|
|
TaskInstance nextTaskInstance = this.processService.releaseTaskGroup(taskInstance); |
|
|
|
if (nextTaskInstance != null) { |
|
|
|
if (nextTaskInstance != null) { |
|
|
@ -1765,19 +1775,24 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> { |
|
|
|
if (taskInstanceId == null || taskInstanceId.equals(0)) { |
|
|
|
if (taskInstanceId == null || taskInstanceId.equals(0)) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
TaskInstance taskInstance = processService.findTaskInstanceById(taskInstanceId); |
|
|
|
LogUtils.setWorkflowAndTaskInstanceIDMDC(processInstance.getId(), taskInstanceId); |
|
|
|
if (taskInstance == null || taskInstance.getState().isFinished()) { |
|
|
|
try { |
|
|
|
continue; |
|
|
|
TaskInstance taskInstance = processService.findTaskInstanceById(taskInstanceId); |
|
|
|
} |
|
|
|
if (taskInstance == null || taskInstance.getState().isFinished()) { |
|
|
|
taskProcessor.action(TaskAction.STOP); |
|
|
|
continue; |
|
|
|
if (taskProcessor.taskInstance().getState().isFinished()) { |
|
|
|
} |
|
|
|
TaskStateEvent taskStateEvent = TaskStateEvent.builder() |
|
|
|
taskProcessor.action(TaskAction.STOP); |
|
|
|
.processInstanceId(processInstance.getId()) |
|
|
|
if (taskProcessor.taskInstance().getState().isFinished()) { |
|
|
|
.taskInstanceId(taskInstance.getId()) |
|
|
|
TaskStateEvent taskStateEvent = TaskStateEvent.builder() |
|
|
|
.status(taskProcessor.taskInstance().getState()) |
|
|
|
.processInstanceId(processInstance.getId()) |
|
|
|
.type(StateEventType.TASK_STATE_CHANGE) |
|
|
|
.taskInstanceId(taskInstance.getId()) |
|
|
|
.build(); |
|
|
|
.status(taskProcessor.taskInstance().getState()) |
|
|
|
this.addStateEvent(taskStateEvent); |
|
|
|
.type(StateEventType.TASK_STATE_CHANGE) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
this.addStateEvent(taskStateEvent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
LogUtils.removeWorkflowAndTaskInstanceIdMDC(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|