diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/StateEvent.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/StateEvent.java index f3a9a6579e..82676241b9 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/StateEvent.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/StateEvent.java @@ -31,7 +31,7 @@ public interface StateEvent { int getProcessInstanceId(); - int getTaskInstanceId(); + Integer getTaskInstanceId(); @NonNull StateEventType getType(); diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEvent.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEvent.java index 1ad96b9346..43a409a0d9 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEvent.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEvent.java @@ -35,7 +35,7 @@ public class TaskStateEvent implements StateEvent { // todo: use wrapper type private int processInstanceId; - private int taskInstanceId; + private Integer taskInstanceId; private long taskCode; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/WorkflowStateEvent.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/WorkflowStateEvent.java index 3267108228..6af2dd9e4c 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/WorkflowStateEvent.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/WorkflowStateEvent.java @@ -34,7 +34,7 @@ public class WorkflowStateEvent implements StateEvent { /** * Some event may contains taskInstanceId */ - private int taskInstanceId; + private Integer taskInstanceId; private WorkflowExecutionStatus status; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StateWheelExecuteThread.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StateWheelExecuteThread.java index 47d4dc62c9..760c722971 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StateWheelExecuteThread.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StateWheelExecuteThread.java @@ -208,8 +208,8 @@ public class StateWheelExecuteThread extends BaseDaemonThread { return; } taskInstanceRetryCheckList.add(taskInstanceKey); - logger.info("[WorkflowInstance-{}][TaskInstance-{}] Added task instance into retry check list", - processInstance.getId(), taskInstance.getId()); + logger.info("[WorkflowInstance-{}][TaskInstanceKey-{}:{}] Added task instance into retry check list", + processInstance.getId(), taskInstance.getTaskCode(), taskInstance.getTaskDefinitionVersion()); } public void removeTask4RetryCheck(@NonNull ProcessInstance processInstance, @NonNull TaskInstance taskInstance) { @@ -341,8 +341,8 @@ public class StateWheelExecuteThread extends BaseDaemonThread { // reset taskInstance endTime and state // todo relative funtion: TaskInstance.retryTaskIntervalOverTime, // WorkflowExecuteThread.cloneRetryTaskInstance - logger.info("[TaskInstance-{}]The task instance can retry, will retry this task instance", - taskInstance.getId()); + logger.info("[TaskInstanceKey-{}:{}]The task instance can retry, will retry this task instance", + taskInstance.getTaskCode(), taskInstance.getTaskDefinitionVersion()); taskInstance.setEndTime(null); taskInstance.setState(TaskExecutionStatus.SUBMITTED_SUCCESS); diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java index 42ff983a14..bfe6903213 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java @@ -523,7 +523,7 @@ public class WorkflowExecuteRunnable implements Callable { * check if task instance exist by state event */ public void checkTaskInstanceByStateEvent(TaskStateEvent stateEvent) throws StateEventHandleError { - if (stateEvent.getTaskInstanceId() == 0) { + if (stateEvent.getTaskInstanceId() == null || stateEvent.getTaskInstanceId() == 0) { throw new StateEventHandleError("The taskInstanceId is 0"); } @@ -546,10 +546,7 @@ public class WorkflowExecuteRunnable implements Callable { * get task instance from memory */ public Optional getTaskInstance(int taskInstanceId) { - if (taskInstanceMap.containsKey(taskInstanceId)) { - return Optional.ofNullable(taskInstanceMap.get(taskInstanceId)); - } - return Optional.empty(); + return Optional.ofNullable(taskInstanceMap.get(taskInstanceId)); } public Optional getTaskInstance(long taskCode) { diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/utils/LoggerUtils.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/utils/LoggerUtils.java index 2fa3d05a1d..1d68dfbb53 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/utils/LoggerUtils.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/utils/LoggerUtils.java @@ -79,16 +79,16 @@ public class LoggerUtils { return ""; } - public static void setWorkflowAndTaskInstanceIDMDC(int workflowInstanceId, int taskInstanceId) { + public static void setWorkflowAndTaskInstanceIDMDC(Integer workflowInstanceId, Integer taskInstanceId) { setWorkflowInstanceIdMDC(workflowInstanceId); setTaskInstanceIdMDC(taskInstanceId); } - public static void setWorkflowInstanceIdMDC(int workflowInstanceId) { + public static void setWorkflowInstanceIdMDC(Integer workflowInstanceId) { MDC.put(Constants.WORKFLOW_INSTANCE_ID_MDC_KEY, String.valueOf(workflowInstanceId)); } - public static void setTaskInstanceIdMDC(int taskInstanceId) { + public static void setTaskInstanceIdMDC(Integer taskInstanceId) { MDC.put(Constants.TASK_INSTANCE_ID_MDC_KEY, String.valueOf(taskInstanceId)); }