This is an automated email from the ASF dual-hosted git repository.
SbloodyS 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 45c274941d [Improvement-18443][API&DAO] Optimize
WorkflowInstanceMapper to exclude large text fields from list queries (#18444)
45c274941d is described below
commit 45c274941d2b1f05aec969ad1fed919871d9d36d
Author: suyc <[email protected]>
AuthorDate: Wed Aug 26 11:01:10 2026 +0800
[Improvement-18443][API&DAO] Optimize WorkflowInstanceMapper to exclude
large text fields from list queries (#18444)
---
docs/docs/en/guide/upgrade/incompatible.md | 35 ++--
docs/docs/zh/guide/upgrade/incompatible.md | 35 ++--
.../api/controller/WorkflowInstanceController.java | 49 ++---
.../api/service/WorkflowInstanceService.java | 52 ++---
.../api/service/impl/TenantServiceImpl.java | 6 +-
.../api/service/impl/WorkerGroupServiceImpl.java | 6 +-
.../impl/WorkflowDefinitionServiceImpl.java | 15 +-
.../service/impl/WorkflowInstanceServiceImpl.java | 74 ++++---
.../api/vo/WorkflowInstanceSummaryVO.java | 219 +++++++++++++++++++++
.../controller/WorkflowInstanceControllerTest.java | 122 +++++++++++-
.../api/service/TenantServiceTest.java | 8 +-
.../api/service/WorkerGroupServiceTest.java | 6 +-
.../api/service/WorkflowInstanceServiceTest.java | 30 ++-
.../dao/mapper/WorkflowInstanceMapper.java | 77 ++++----
.../dao/model/WorkflowInstanceSummaryDto.java | 107 ++++++++++
.../dao/repository/WorkflowInstanceDao.java | 51 ++---
.../repository/impl/WorkflowInstanceDaoImpl.java | 52 ++---
.../dolphinscheduler/dao/utils/WorkflowUtils.java | 15 ++
.../dao/mapper/WorkflowInstanceMapper.xml | 66 ++++---
.../dao/mapper/WorkflowInstanceMapperTest.java | 16 +-
.../master/failover/FailoverCoordinator.java | 10 +-
.../server/master/failover/WorkflowFailover.java | 4 +-
.../server/master/utils/DependentExecute.java | 3 +-
23 files changed, 790 insertions(+), 268 deletions(-)
diff --git a/docs/docs/en/guide/upgrade/incompatible.md
b/docs/docs/en/guide/upgrade/incompatible.md
index 55bc8a6041..968891bcbe 100644
--- a/docs/docs/en/guide/upgrade/incompatible.md
+++ b/docs/docs/en/guide/upgrade/incompatible.md
@@ -22,31 +22,36 @@ This document records the incompatible updates between each
version. You need to
## 3.3.0
-* Remove the `udf-manage` function from the `resource center`
([#16209])(https://github.com/apache/dolphinscheduler/pull/16209)
-* Remove the `Pigeon` from the `Task Plugin`
([#16218])(https://github.com/apache/dolphinscheduler/pull/16218)
-* Uniformly name `process` in code as `workflow`
([#16515])(https://github.com/apache/dolphinscheduler/pull/16515)
-* Deprecated upgrade code of 1.x and 2.x
([#16543])(https://github.com/apache/dolphinscheduler/pull/16543)
-* Remove the `Data Quality` module
([#16794])(https://github.com/apache/dolphinscheduler/pull/16794)
-* Remove the `registry-disconnect-strategy` in `application.yaml`
([#16821])(https://github.com/apache/dolphinscheduler/pull/16821)
-* Remove `exec-threads` in worker's `application.yaml`, please use
`physical-task-config`;Remove `master-async-task-executor-thread-pool-size` in
master's `application.yaml`, please use `logic-task-config`
([#16790])(https://github.com/apache/dolphinscheduler/pull/16790)
-* Drop unused column `other_params_json` in `t_ds_worker_group`
([#16860])(https://github.com/apache/dolphinscheduler/pull/16860)
-* Remove the `Dynamic` from the `Task Plugin`
([#16482])(https://github.com/apache/dolphinscheduler/pull/16842)
+* Remove the `udf-manage` function from the `resource center`
([#16209](https://github.com/apache/dolphinscheduler/pull/16209))
+* Remove the `Pigeon` from the `Task Plugin`
([#16218](https://github.com/apache/dolphinscheduler/pull/16218))
+* Uniformly name `process` in code as `workflow`
([#16515](https://github.com/apache/dolphinscheduler/pull/16515))
+* Deprecated upgrade code of 1.x and 2.x
([#16543](https://github.com/apache/dolphinscheduler/pull/16543))
+* Remove the `Data Quality` module
([#16794](https://github.com/apache/dolphinscheduler/pull/16794))
+* Remove the `registry-disconnect-strategy` in `application.yaml`
([#16821](https://github.com/apache/dolphinscheduler/pull/16821))
+* Remove `exec-threads` in worker's `application.yaml`, please use
`physical-task-config`;Remove `master-async-task-executor-thread-pool-size` in
master's `application.yaml`, please use `logic-task-config`
([#16790](https://github.com/apache/dolphinscheduler/pull/16790))
+* Drop unused column `other_params_json` in `t_ds_worker_group`
([#16860](https://github.com/apache/dolphinscheduler/pull/16860))
+* Remove the `Dynamic` from the `Task Plugin`
([#16482](https://github.com/apache/dolphinscheduler/pull/16842))
## 3.4.0
-* Renamed the publicKey field to privateKey in the SSH connection parameters
under the datasource configuration.
([#17666])(https://github.com/apache/dolphinscheduler/pull/17666)
-* Add table t_ds_serial_command.
([#17531])(https://github.com/apache/dolphinscheduler/pull/17531)
-* Remove the default value of `python-gateway.auth-token` at
`api-server/application.yaml`.
([#17801])(https://github.com/apache/dolphinscheduler/pull/17801)
-* Refactor the task plugins which use ShellCommandExecutor
([#17790])(https://github.com/apache/dolphinscheduler/pull/17790)
-* Remove the `Pytorch` from the `Task Plugin`
([#17808])(https://github.com/apache/dolphinscheduler/pull/17808), if you are
still using this task type, please delete the data with `task_type = 'PYTORCH'`
in `t_ds_task_definition` and `t_ds_task_definition_log` before upgrading.
+* Renamed the publicKey field to privateKey in the SSH connection parameters
under the datasource configuration.
([#17666](https://github.com/apache/dolphinscheduler/pull/17666))
+* Add table t_ds_serial_command.
([#17531](https://github.com/apache/dolphinscheduler/pull/17531))
+* Remove the default value of `python-gateway.auth-token` at
`api-server/application.yaml`.
([#17801](https://github.com/apache/dolphinscheduler/pull/17801))
+* Refactor the task plugins which use ShellCommandExecutor
([#17790](https://github.com/apache/dolphinscheduler/pull/17790))
+* Remove the `Pytorch` from the `Task Plugin`
([#17808](https://github.com/apache/dolphinscheduler/pull/17808)), if you are
still using this task type, please delete the data with `task_type = 'PYTORCH'`
in `t_ds_task_definition` and `t_ds_task_definition_log` before upgrading.
## 3.4.1
-* Remove import and export of workflow definition.
([#17940])(https://github.com/apache/dolphinscheduler/issues/17940)
+* Remove import and export of workflow definition.
([#17940](https://github.com/apache/dolphinscheduler/issues/17940))
## 3.5.0
* Add the `missed_fire_policy` column to `t_ds_schedules`. Existing schedules
default to `FIRE_ALL_MISSED` to preserve the previous Quartz `IgnoreMisfires`
behavior. ([#18464](https://github.com/apache/dolphinscheduler/pull/18464))
* Remove the obsolete Dynamic Task query API.
([#18556](https://github.com/apache/dolphinscheduler/issues/18556))
* Remove the obsolete task update-with-upstream API `PUT
/projects/{projectCode}/task-definition/{code}/with-upstream`.
([#18568](https://github.com/apache/dolphinscheduler/issues/18568))
+* The workflow instance list APIs (`GET
/projects/{projectCode}/workflow-instances`, `GET
/projects/{projectCode}/workflow-instances/top-n`, `GET
/projects/{projectCode}/workflow-instances/trigger`) no longer return the
following properties in the response body:
+ * **Removed heavy fields**: `commandParam`, `globalParams`, `historyCmd`,
`varPool`, `stateHistory`
+ * **Removed transient fields**: `stateDescList`, `workflowDefinition`,
`dagData`, `queue`, `locations`, `dependenceScheduleTimes`
+ * **Removed derived properties**: `cmdTypeIfComplement`, `complementData`
(related to complement-data executions; use the detail API to obtain them)
+ * To obtain any of these fields, use the detail API `GET
/projects/{projectCode}/workflow-instances/{id}` instead, which continues to
return the full `WorkflowInstance` object.
([#18444](https://github.com/apache/dolphinscheduler/pull/18444))
diff --git a/docs/docs/zh/guide/upgrade/incompatible.md
b/docs/docs/zh/guide/upgrade/incompatible.md
index ba52dd5fe8..5c6870fad6 100644
--- a/docs/docs/zh/guide/upgrade/incompatible.md
+++ b/docs/docs/zh/guide/upgrade/incompatible.md
@@ -22,31 +22,36 @@
## 3.3.0
-* 从 `资源中心` 中移除 `udf-manage` 功能
([#16209])(https://github.com/apache/dolphinscheduler/pull/16209)
-* 从 `任务插件` 中移除 `Pigeon` 类型
([#16218])(https://github.com/apache/dolphinscheduler/pull/16218)
-* 统一代码中的 `process` 为 `workflow`
([#16515])(https://github.com/apache/dolphinscheduler/pull/16515)
-* 废弃从 1.x 至 2.x 的升级代码
([#16543])(https://github.com/apache/dolphinscheduler/pull/16543)
-* 移除 `数据质量` 模块
([#16794])(https://github.com/apache/dolphinscheduler/pull/16794)
-* 在`application.yaml`中移除`registry-disconnect-strategy`配置
([#16821])(https://github.com/apache/dolphinscheduler/pull/16821)
-* 在 `worker` 的 `application.yaml` 中移除
`exec-threads`,使用`physical-task-config`替代;在master的`application.yaml`中移除`master-async-task-executor-thread-pool-size`使用`logic-task-config`替代
([#16790])(https://github.com/apache/dolphinscheduler/pull/16790)
-* 在 `t_ds_worker_group` 表中移除 无用的 `other_params_json` 字段
([#16860])(https://github.com/apache/dolphinscheduler/pull/16860)
-* 从 `任务插件` 中移除 `Dynamic` 类型
([#16482])(https://github.com/apache/dolphinscheduler/pull/16842)
+* 从 `资源中心` 中移除 `udf-manage` 功能
([#16209](https://github.com/apache/dolphinscheduler/pull/16209))
+* 从 `任务插件` 中移除 `Pigeon` 类型
([#16218](https://github.com/apache/dolphinscheduler/pull/16218))
+* 统一代码中的 `process` 为 `workflow`
([#16515](https://github.com/apache/dolphinscheduler/pull/16515))
+* 废弃从 1.x 至 2.x 的升级代码
([#16543](https://github.com/apache/dolphinscheduler/pull/16543))
+* 移除 `数据质量` 模块
([#16794](https://github.com/apache/dolphinscheduler/pull/16794))
+* 在`application.yaml`中移除`registry-disconnect-strategy`配置
([#16821](https://github.com/apache/dolphinscheduler/pull/16821))
+* 在 `worker` 的 `application.yaml` 中移除
`exec-threads`,使用`physical-task-config`替代;在master的`application.yaml`中移除`master-async-task-executor-thread-pool-size`使用`logic-task-config`替代
([#16790](https://github.com/apache/dolphinscheduler/pull/16790))
+* 在 `t_ds_worker_group` 表中移除 无用的 `other_params_json` 字段
([#16860](https://github.com/apache/dolphinscheduler/pull/16860))
+* 从 `任务插件` 中移除 `Dynamic` 类型
([#16482](https://github.com/apache/dolphinscheduler/pull/16842))
## 3.4.0
-* 将数据源配置下SSH连接参数中的publicKey字段重命名为privateKey。
([#17666])(https://github.com/apache/dolphinscheduler/pull/17666)
-* 添加数据表 t_ds_serial_command。
([#17531])(https://github.com/apache/dolphinscheduler/pull/17531)
-* 移除 `api-server/application.yaml` 中 `python-gateway.auth-token` 的默认值。
([#17801])(https://github.com/apache/dolphinscheduler/pull/17801)
-* 重构使用 ShellCommandExecutor 的任务插件
([#17790])(https://github.com/apache/dolphinscheduler/pull/17790)
-* 从 `任务插件` 中移除 `Pytorch` 类型
([#17808])(https://github.com/apache/dolphinscheduler/pull/17808),如果您仍在使用该任务类型,请在升级前删除
`t_ds_task_definition` 和 `t_ds_task_definition_log` 中 `task_type = 'PYTORCH'`
的数据。
+* 将数据源配置下SSH连接参数中的publicKey字段重命名为privateKey。
([#17666](https://github.com/apache/dolphinscheduler/pull/17666))
+* 添加数据表 t_ds_serial_command。
([#17531](https://github.com/apache/dolphinscheduler/pull/17531))
+* 移除 `api-server/application.yaml` 中 `python-gateway.auth-token` 的默认值。
([#17801](https://github.com/apache/dolphinscheduler/pull/17801))
+* 重构使用 ShellCommandExecutor 的任务插件
([#17790](https://github.com/apache/dolphinscheduler/pull/17790))
+* 从 `任务插件` 中移除 `Pytorch` 类型
([#17808](https://github.com/apache/dolphinscheduler/pull/17808)),如果您仍在使用该任务类型,请在升级前删除
`t_ds_task_definition` 和 `t_ds_task_definition_log` 中 `task_type = 'PYTORCH'`
的数据。
## 3.4.1
-* 移除导入导出工作流([#17940])(https://github.com/apache/dolphinscheduler/issues/17940)
+* 移除导入导出工作流([#17940](https://github.com/apache/dolphinscheduler/issues/17940))
## 3.5.0
* 为 `t_ds_schedules` 表新增 `missed_fire_policy` 字段。现有定时默认使用
`FIRE_ALL_MISSED`,以保持原有 Quartz `IgnoreMisfires`
行为。([#18464](https://github.com/apache/dolphinscheduler/pull/18464))
* 移除已废弃的 Dynamic Task
查询接口。([#18556](https://github.com/apache/dolphinscheduler/issues/18556))
* 移除已废弃的任务及其上游关系更新接口 `PUT
/projects/{projectCode}/task-definition/{code}/with-upstream`。([#18568](https://github.com/apache/dolphinscheduler/issues/18568))
+* 工作流实例列表接口(`GET /projects/{projectCode}/workflow-instances`、`GET
/projects/{projectCode}/workflow-instances/top-n`、`GET
/projects/{projectCode}/workflow-instances/trigger`)的响应体不再返回以下属性:
+ *
**移除的大字段**:`commandParam`、`globalParams`、`historyCmd`、`varPool`、`stateHistory`
+ *
**移除的非数据库字段**:`stateDescList`、`workflowDefinition`、`dagData`、`queue`、`locations`、`dependenceScheduleTimes`
+ * **移除的派生属性**:`cmdTypeIfComplement`、`complementData`(补数执行相关,如需获取请使用详情接口)
+ * 如需获取这些字段,请使用详情接口 `GET
/projects/{projectCode}/workflow-instances/{id}`,该接口仍返回完整的 `WorkflowInstance`
对象 ([#18444](https://github.com/apache/dolphinscheduler/pull/18444))
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceController.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceController.java
index c99c2aaf36..20b450dd3d 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceController.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceController.java
@@ -27,7 +27,9 @@ import
org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceVari
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.WorkflowInstanceService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.api.vo.WorkflowInstanceSummaryVO;
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.dao.entity.User;
@@ -103,18 +105,18 @@ public class WorkflowInstanceController extends
BaseController {
@GetMapping()
@ResponseStatus(HttpStatus.OK)
@ApiException(Status.QUERY_WORKFLOW_INSTANCE_LIST_PAGING_ERROR)
- public Result queryWorkflowInstanceList(@Parameter(hidden = true)
@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
- @Parameter(name = "projectCode",
description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
- @RequestParam(value =
"workflowDefinitionCode", required = false, defaultValue = "0") long
workflowDefinitionCode,
- @RequestParam(value = "searchVal",
required = false) String searchVal,
- @RequestParam(value =
"executorName", required = false) String executorName,
- @RequestParam(value = "stateType",
required = false) WorkflowExecutionStatus stateType,
- @RequestParam(value = "host",
required = false) String host,
- @RequestParam(value = "startDate",
required = false) String startTime,
- @RequestParam(value = "endDate",
required = false) String endTime,
- @RequestParam(value =
"otherParamsJson", required = false) String otherParamsJson,
- @RequestParam("pageNo") Integer
pageNo,
- @RequestParam("pageSize") Integer
pageSize) {
+ public Result<PageInfo<WorkflowInstanceSummaryVO>>
queryWorkflowInstanceList(@Parameter(hidden = true) @RequestAttribute(value =
Constants.SESSION_USER) User loginUser,
+
@Parameter(name = "projectCode", description = "PROJECT_CODE", required =
true) @PathVariable long projectCode,
+
@RequestParam(value = "workflowDefinitionCode", required = false,
defaultValue = "0") long workflowDefinitionCode,
+
@RequestParam(value = "searchVal", required = false) String searchVal,
+
@RequestParam(value = "executorName", required = false) String executorName,
+
@RequestParam(value = "stateType", required = false) WorkflowExecutionStatus
stateType,
+
@RequestParam(value = "host", required = false) String host,
+
@RequestParam(value = "startDate", required = false) String startTime,
+
@RequestParam(value = "endDate", required = false) String endTime,
+
@RequestParam(value = "otherParamsJson", required = false) String
otherParamsJson,
+
@RequestParam("pageNo") Integer pageNo,
+
@RequestParam("pageSize") Integer pageSize) {
checkPageParams(pageNo, pageSize);
searchVal = ParameterUtils.handleEscapes(searchVal);
@@ -232,13 +234,14 @@ public class WorkflowInstanceController extends
BaseController {
@GetMapping(value = "/top-n")
@ResponseStatus(HttpStatus.OK)
@ApiException(Status.QUERY_WORKFLOW_INSTANCE_BY_ID_ERROR)
- public Result<List<WorkflowInstance>>
queryTopNLongestRunningWorkflowInstance(@Parameter(hidden = true)
@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
-
@Parameter(name = "projectCode", description = "PROJECT_CODE", required =
true) @PathVariable long projectCode,
-
@RequestParam("size") Integer size,
-
@RequestParam(value = "startTime", required = true) String startTime,
-
@RequestParam(value = "endTime", required = true) String endTime) {
- List<WorkflowInstance> workflowInstances =
workflowInstanceService.queryTopNLongestRunningWorkflowInstance(
- loginUser, projectCode, size, startTime, endTime);
+ public Result<List<WorkflowInstanceSummaryVO>>
queryTopNLongestRunningWorkflowInstance(@Parameter(hidden = true)
@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+
@Parameter(name = "projectCode", description = "PROJECT_CODE",
required = true) @PathVariable long projectCode,
+
@RequestParam("size") Integer size,
+
@RequestParam(value = "startTime", required = true) String
startTime,
+
@RequestParam(value = "endTime", required = true) String endTime) {
+ List<WorkflowInstanceSummaryVO> workflowInstances =
+
workflowInstanceService.queryTopNLongestRunningWorkflowInstance(
+ loginUser, projectCode, size, startTime, endTime);
return Result.success(workflowInstances);
}
@@ -410,10 +413,10 @@ public class WorkflowInstanceController extends
BaseController {
@GetMapping("/trigger")
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_WORKFLOW_INSTANCE_LIST_PAGING_ERROR)
- public Result<List<WorkflowInstance>>
queryWorkflowInstancesByTriggerCode(@RequestAttribute(value =
Constants.SESSION_USER) User loginUser,
-
@PathVariable long projectCode,
-
@RequestParam(value = "triggerCode") Long triggerCode) {
- List<WorkflowInstance> workflowInstances =
+ public Result<List<WorkflowInstanceSummaryVO>>
queryWorkflowInstancesByTriggerCode(@RequestAttribute(value =
Constants.SESSION_USER) User loginUser,
+
@PathVariable long projectCode,
+
@RequestParam(value = "triggerCode") Long triggerCode) {
+ List<WorkflowInstanceSummaryVO> workflowInstances =
workflowInstanceService.queryByTriggerCode(loginUser,
projectCode, triggerCode);
return Result.success(workflowInstances);
}
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceService.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceService.java
index c38d01ac55..b86d576acf 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceService.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceService.java
@@ -22,10 +22,12 @@ import
org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceTask
import
org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceVariablesDTO;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.api.vo.WorkflowInstanceSummaryVO;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import java.util.List;
import java.util.Map;
@@ -35,11 +37,11 @@ public interface WorkflowInstanceService {
/**
* return top n SUCCESS workflow instance order by running time which
started between startTime and endTime
*/
- List<WorkflowInstance> queryTopNLongestRunningWorkflowInstance(User
loginUser,
- long
projectCode,
- int size,
- String
startTime,
- String
endTime);
+ List<WorkflowInstanceSummaryVO>
queryTopNLongestRunningWorkflowInstance(User loginUser,
+
long projectCode,
+
int size,
+
String startTime,
+
String endTime);
/**
* query workflow instance by id
@@ -69,18 +71,18 @@ public interface WorkflowInstanceService {
* @param otherParamsJson otherParamsJson handle other params
* @return workflow instance list
*/
- Result<PageInfo<WorkflowInstance>> queryWorkflowInstanceList(User
loginUser,
- long
projectCode,
- long
workflowDefinitionCode,
- String
startDate,
- String
endDate,
- String
searchVal,
- String
executorName,
-
WorkflowExecutionStatus stateType,
- String host,
- String
otherParamsJson,
- Integer
pageNo,
- Integer
pageSize);
+ Result<PageInfo<WorkflowInstanceSummaryVO>> queryWorkflowInstanceList(User
loginUser,
+ long
projectCode,
+ long
workflowDefinitionCode,
+
String startDate,
+
String endDate,
+
String searchVal,
+
String executorName,
+
WorkflowExecutionStatus stateType,
+
String host,
+
String otherParamsJson,
+
Integer pageNo,
+
Integer pageSize);
/**
* query task list by workflow instance id
@@ -181,8 +183,8 @@ public interface WorkflowInstanceService {
* @param states states array
* @return workflow instance list
*/
- List<WorkflowInstance> queryByWorkflowDefinitionCodeAndStatus(Long
workflowDefinitionCode,
- int[]
states);
+ List<WorkflowInstanceSummaryDto>
queryByWorkflowDefinitionCodeAndStatus(Long workflowDefinitionCode,
+
int[] states);
/**
* query workflow instance by workflowDefinitionCode and stateArray
@@ -192,9 +194,9 @@ public interface WorkflowInstanceService {
* @param states states array
* @return workflow instance list
*/
- List<WorkflowInstance> queryByWorkflowCodeVersionStatus(Long
workflowDefinitionCode,
- int
workflowDefinitionVersion,
- int[] states);
+ List<WorkflowInstanceSummaryDto> queryByWorkflowCodeVersionStatus(Long
workflowDefinitionCode,
+ int
workflowDefinitionVersion,
+ int[]
states);
/**
* query workflow instance by workflowDefinitionCode
@@ -203,8 +205,8 @@ public interface WorkflowInstanceService {
* @param size size
* @return workflow instance list
*/
- List<WorkflowInstance> queryByWorkflowDefinitionCode(Long
workflowDefinitionCode,
- int size);
+ List<WorkflowInstanceSummaryDto> queryByWorkflowDefinitionCode(Long
workflowDefinitionCode,
+ int size);
/**
* query workflow instance list by trigger code
@@ -214,7 +216,7 @@ public interface WorkflowInstanceService {
* @param triggerCode trigger code (nullable)
* @return workflow instances triggered by the given trigger code
*/
- List<WorkflowInstance> queryByTriggerCode(User loginUser, long
projectCode, Long triggerCode);
+ List<WorkflowInstanceSummaryVO> queryByTriggerCode(User loginUser, long
projectCode, Long triggerCode);
void deleteWorkflowInstanceByWorkflowDefinitionCode(long
workflowDefinitionCode);
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
index bcdbc5a90c..85f8536335 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
@@ -35,7 +35,7 @@ import org.apache.dolphinscheduler.dao.entity.Queue;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.User;
-import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.ScheduleDao;
import org.apache.dolphinscheduler.dao.repository.TenantDao;
import org.apache.dolphinscheduler.dao.repository.UserDao;
@@ -225,7 +225,7 @@ public class TenantServiceImpl extends BaseServiceImpl
implements TenantService
throw new ServiceException(Status.TENANT_NOT_EXIST);
}
- List<WorkflowInstance> workflowInstances =
getWorkflowInstancesByTenant(tenant);
+ List<WorkflowInstanceSummaryDto> workflowInstances =
getWorkflowInstancesByTenant(tenant);
if (CollectionUtils.isNotEmpty(workflowInstances)) {
throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL,
workflowInstances.size());
}
@@ -247,7 +247,7 @@ public class TenantServiceImpl extends BaseServiceImpl
implements TenantService
workflowInstanceDao.updateWorkflowInstanceByTenantCode(tenant.getTenantCode(),
Constants.DEFAULT);
}
- private List<WorkflowInstance> getWorkflowInstancesByTenant(Tenant tenant)
{
+ private List<WorkflowInstanceSummaryDto>
getWorkflowInstancesByTenant(Tenant tenant) {
return workflowInstanceDao.queryByTenantCodeAndStatus(
tenant.getTenantCode(),
WorkflowExecutionStatus.NOT_TERMINAL_STATES);
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
index ea7cc151cc..2cd8a8869d 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
@@ -40,8 +40,8 @@ import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
import org.apache.dolphinscheduler.dao.entity.WorkerGroupPageDetail;
-import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import
org.apache.dolphinscheduler.dao.mapper.EnvironmentWorkerGroupRelationMapper;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.ScheduleDao;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
import org.apache.dolphinscheduler.dao.repository.WorkerGroupDao;
@@ -321,12 +321,12 @@ public class WorkerGroupServiceImpl extends
BaseServiceImpl implements WorkerGro
log.error("Worker group does not exist, workerGroupId:{}.", id);
throw new ServiceException(Status.DELETE_WORKER_GROUP_NOT_EXIST);
}
- List<WorkflowInstance> workflowInstances =
workflowInstanceDao.queryByWorkerGroupNameAndStatus(
+ List<WorkflowInstanceSummaryDto> workflowInstances =
workflowInstanceDao.queryByWorkerGroupNameAndStatus(
workerGroup.getName(),
WorkflowExecutionStatus.NOT_TERMINAL_STATES);
if (CollectionUtils.isNotEmpty(workflowInstances)) {
List<Integer> workflowInstanceIds =
-
workflowInstances.stream().map(WorkflowInstance::getId).collect(Collectors.toList());
+
workflowInstances.stream().map(WorkflowInstanceSummaryDto::getId).collect(Collectors.toList());
log.warn(
"Delete worker group failed because there are {}
workflowInstances are using it, workflowInstanceIds:{}.",
workflowInstances.size(), workflowInstanceIds);
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
index 538a35160f..cf035ff938 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
@@ -71,7 +71,6 @@ import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.UserWithWorkflowDefinitionCode;
import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition;
import org.apache.dolphinscheduler.dao.entity.WorkflowDefinitionLog;
-import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.entity.WorkflowTaskLineage;
import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelation;
import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelationLog;
@@ -79,6 +78,7 @@ import
org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
import org.apache.dolphinscheduler.dao.mapper.WorkflowDefinitionLogMapper;
import org.apache.dolphinscheduler.dao.mapper.WorkflowTaskRelationLogMapper;
import org.apache.dolphinscheduler.dao.model.PageListingResult;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.ProjectDao;
import org.apache.dolphinscheduler.dao.repository.ScheduleDao;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
@@ -844,8 +844,9 @@ public class WorkflowDefinitionServiceImpl extends
BaseServiceImpl implements Wo
}
// check workflow instances is already running
- List<WorkflowInstance> workflowInstances =
workflowInstanceService.queryByWorkflowDefinitionCodeAndStatus(
- workflowDefinition.getCode(),
WorkflowExecutionStatus.NOT_TERMINAL_STATES);
+ List<WorkflowInstanceSummaryDto> workflowInstances =
+ workflowInstanceService.queryByWorkflowDefinitionCodeAndStatus(
+ workflowDefinition.getCode(),
WorkflowExecutionStatus.NOT_TERMINAL_STATES);
if (CollectionUtils.isNotEmpty(workflowInstances)) {
throw new
ServiceException(Status.DELETE_WORKFLOW_DEFINITION_EXECUTING_FAIL,
workflowInstances.size());
}
@@ -1120,7 +1121,7 @@ public class WorkflowDefinitionServiceImpl extends
BaseServiceImpl implements Wo
Map<Long, List<TreeViewDto>> waitingRunningNodeMap = new
ConcurrentHashMap<>();
// List of workflow instances
- List<WorkflowInstance> workflowInstanceList =
+ List<WorkflowInstanceSummaryDto> workflowInstanceList =
workflowInstanceService.queryByWorkflowDefinitionCode(code,
limit);
workflowInstanceList.forEach(workflowInstance -> workflowInstance
.setDuration(
@@ -1143,7 +1144,7 @@ public class WorkflowDefinitionServiceImpl extends
BaseServiceImpl implements Wo
parentTreeViewDto.setCode(0L);
// Specify the workflow definition, because it is a TreeView for a
workflow definition
for (int i = limit - 1; i >= 0; i--) {
- WorkflowInstance workflowInstance = workflowInstanceList.get(i);
+ WorkflowInstanceSummaryDto workflowInstance =
workflowInstanceList.get(i);
Date endTime = workflowInstance.getEndTime() == null ? new Date()
: workflowInstance.getEndTime();
parentTreeViewDto.getInstances()
.add(new Instance(workflowInstance.getId(),
workflowInstance.getName(),
@@ -1175,7 +1176,7 @@ public class WorkflowDefinitionServiceImpl extends
BaseServiceImpl implements Wo
treeViewDto.setName(taskNode.getName());
// set treeViewDto instances
for (int i = limit - 1; i >= 0; i--) {
- WorkflowInstance workflowInstance =
workflowInstanceList.get(i);
+ WorkflowInstanceSummaryDto workflowInstance =
workflowInstanceList.get(i);
TaskInstance taskInstance =
taskInstanceDao.queryByWorkflowInstanceIdAndTaskCode(workflowInstance.getId(),
nodeCode);
if (taskInstance == null) {
@@ -1730,7 +1731,7 @@ public class WorkflowDefinitionServiceImpl extends
BaseServiceImpl implements Wo
throw new ServiceException(Status.MAIN_TABLE_USING_VERSION);
}
// check whether there exist running workflow instance under the
workflow definition
- List<WorkflowInstance> workflowInstances =
workflowInstanceService.queryByWorkflowCodeVersionStatus(
+ List<WorkflowInstanceSummaryDto> workflowInstances =
workflowInstanceService.queryByWorkflowCodeVersionStatus(
code,
version,
WorkflowExecutionStatus.NOT_TERMINAL_STATES);
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java
index 7c79613da0..babe68aaa7 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java
@@ -40,6 +40,7 @@ import
org.apache.dolphinscheduler.api.service.WorkflowDefinitionService;
import org.apache.dolphinscheduler.api.service.WorkflowInstanceService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.api.vo.WorkflowInstanceSummaryVO;
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.ContextType;
import org.apache.dolphinscheduler.common.enums.Flag;
@@ -63,6 +64,7 @@ import
org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelationLog;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
import org.apache.dolphinscheduler.dao.mapper.WorkflowDefinitionLogMapper;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.ProjectDao;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
import org.apache.dolphinscheduler.dao.repository.TaskInstanceContextDao;
@@ -165,8 +167,9 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
private TaskDatasourcePermissionChecker taskDatasourcePermissionChecker;
@Override
- public List<WorkflowInstance> queryTopNLongestRunningWorkflowInstance(User
loginUser, long projectCode, int size,
-
String startTime, String endTime) {
+ public List<WorkflowInstanceSummaryVO>
queryTopNLongestRunningWorkflowInstance(User loginUser, long projectCode,
+
int size,
+
String startTime, String endTime) {
Project project = projectDao.queryByCode(projectCode);
// check user access for project
projectService.checkProjectAndAuthThrowException(loginUser, project,
WORKFLOW_INSTANCE);
@@ -190,7 +193,10 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
}
return workflowInstanceDao.queryTopNWorkflowInstance(size, start, end,
WorkflowExecutionStatus.SUCCESS,
- projectCode);
+ projectCode)
+ .stream()
+ .map(WorkflowInstanceSummaryVO::fromSummaryDto)
+ .collect(Collectors.toList());
}
@Override
@@ -216,18 +222,18 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
}
@Override
- public Result<PageInfo<WorkflowInstance>> queryWorkflowInstanceList(User
loginUser,
- long
projectCode,
- long
workflowDefinitionCode,
- String
startDate,
- String
endDate,
- String
searchVal,
- String
executorName,
-
WorkflowExecutionStatus stateType,
- String
host,
- String
otherParamsJson,
-
Integer pageNo,
-
Integer pageSize) {
+ public Result<PageInfo<WorkflowInstanceSummaryVO>>
queryWorkflowInstanceList(User loginUser,
+
long projectCode,
+
long workflowDefinitionCode,
+
String startDate,
+
String endDate,
+
String searchVal,
+
String executorName,
+
WorkflowExecutionStatus stateType,
+
String host,
+
String otherParamsJson,
+
Integer pageNo,
+
Integer pageSize) {
Result result = new Result();
// check user access for project
@@ -242,10 +248,10 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
Date start = checkAndParseDateParameters(startDate);
Date end = checkAndParseDateParameters(endDate);
- Page<WorkflowInstance> page = new Page<>(pageNo, pageSize);
- PageInfo<WorkflowInstance> pageInfo = new PageInfo<>(pageNo, pageSize);
+ Page<WorkflowInstanceSummaryDto> page = new Page<>(pageNo, pageSize);
+ PageInfo<WorkflowInstanceSummaryVO> pageInfo = new PageInfo<>(pageNo,
pageSize);
- IPage<WorkflowInstance> workflowInstanceList =
workflowInstanceDao.queryWorkflowInstanceListPaging(
+ IPage<WorkflowInstanceSummaryDto> workflowInstanceList =
workflowInstanceDao.queryWorkflowInstanceListPaging(
page,
projectCode,
workflowDefinitionCode,
@@ -256,10 +262,11 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
start,
end);
- List<WorkflowInstance> workflowInstances =
workflowInstanceList.getRecords();
+ List<WorkflowInstanceSummaryDto> workflowInstances =
workflowInstanceList.getRecords();
List<Integer> userIds = Collections.emptyList();
if (CollectionUtils.isNotEmpty(workflowInstances)) {
- userIds =
workflowInstances.stream().map(WorkflowInstance::getExecutorId).collect(Collectors.toList());
+ userIds =
workflowInstances.stream().map(WorkflowInstanceSummaryDto::getExecutorId)
+ .collect(Collectors.toList());
}
List<User> users = usersService.queryUser(userIds);
Map<Integer, User> idToUserMap = Collections.emptyMap();
@@ -267,7 +274,7 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
idToUserMap = users.stream().collect(Collectors.toMap(User::getId,
Function.identity()));
}
- for (WorkflowInstance workflowInstance : workflowInstances) {
+ for (WorkflowInstanceSummaryDto workflowInstance : workflowInstances) {
workflowInstance.setDuration(WorkflowUtils.getWorkflowInstanceDuration(workflowInstance));
User executor = idToUserMap.get(workflowInstance.getExecutorId());
if (null != executor) {
@@ -276,7 +283,9 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
}
pageInfo.setTotal((int) workflowInstanceList.getTotal());
- pageInfo.setTotalList(workflowInstances);
+ pageInfo.setTotalList(workflowInstances.stream()
+ .map(WorkflowInstanceSummaryVO::fromSummaryDto)
+ .collect(Collectors.toList()));
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
@@ -697,24 +706,26 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
}
@Override
- public List<WorkflowInstance> queryByWorkflowDefinitionCodeAndStatus(Long
workflowDefinitionCode, int[] states) {
+ public List<WorkflowInstanceSummaryDto>
queryByWorkflowDefinitionCodeAndStatus(Long workflowDefinitionCode,
+
int[] states) {
return
workflowInstanceDao.queryByWorkflowDefinitionCodeAndStatus(workflowDefinitionCode,
states);
}
@Override
- public List<WorkflowInstance> queryByWorkflowCodeVersionStatus(Long
workflowDefinitionCode,
- int
workflowDefinitionVersion, int[] states) {
+ public List<WorkflowInstanceSummaryDto>
queryByWorkflowCodeVersionStatus(Long workflowDefinitionCode,
+
int workflowDefinitionVersion,
+
int[] states) {
return
workflowInstanceDao.queryByWorkflowCodeVersionStatus(workflowDefinitionCode,
workflowDefinitionVersion,
states);
}
@Override
- public List<WorkflowInstance> queryByWorkflowDefinitionCode(Long
workflowDefinitionCode, int size) {
+ public List<WorkflowInstanceSummaryDto> queryByWorkflowDefinitionCode(Long
workflowDefinitionCode, int size) {
return
workflowInstanceDao.queryByWorkflowDefinitionCode(workflowDefinitionCode, size);
}
@Override
- public List<WorkflowInstance> queryByTriggerCode(User loginUser, long
projectCode, Long triggerCode) {
+ public List<WorkflowInstanceSummaryVO> queryByTriggerCode(User loginUser,
long projectCode, Long triggerCode) {
Project project = projectDao.queryByCode(projectCode);
// check user access for project
@@ -723,19 +734,22 @@ public class WorkflowInstanceServiceImpl extends
BaseServiceImpl implements Work
if (triggerCode == null) {
return Collections.emptyList();
}
- return workflowInstanceDao.queryByTriggerCode(triggerCode);
+ return workflowInstanceDao.queryByTriggerCode(triggerCode)
+ .stream()
+ .map(WorkflowInstanceSummaryVO::fromSummaryDto)
+ .collect(Collectors.toList());
}
@Override
public void deleteWorkflowInstanceByWorkflowDefinitionCode(long
workflowDefinitionCode) {
while (true) {
- List<WorkflowInstance> workflowInstances =
+ List<WorkflowInstanceSummaryDto> workflowInstances =
workflowInstanceDao.queryByWorkflowDefinitionCode(workflowDefinitionCode, 100);
if (CollectionUtils.isEmpty(workflowInstances)) {
break;
}
log.info("Begin to delete workflow instance, workflow definition
code: {}", workflowDefinitionCode);
- for (WorkflowInstance workflowInstance : workflowInstances) {
+ for (WorkflowInstanceSummaryDto workflowInstance :
workflowInstances) {
if (!workflowInstance.getState().isFinalState()) {
log.warn("Workflow instance is not finished cannot delete,
workflow instance id:{}",
workflowInstance.getId());
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowInstanceSummaryVO.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowInstanceSummaryVO.java
new file mode 100644
index 0000000000..4dbfcf8b6c
--- /dev/null
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowInstanceSummaryVO.java
@@ -0,0 +1,219 @@
+/*
+ * 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.api.vo;
+
+import org.apache.dolphinscheduler.common.enums.CommandType;
+import org.apache.dolphinscheduler.common.enums.FailureStrategy;
+import org.apache.dolphinscheduler.common.enums.Flag;
+import org.apache.dolphinscheduler.common.enums.Priority;
+import org.apache.dolphinscheduler.common.enums.TaskDependType;
+import org.apache.dolphinscheduler.common.enums.WarningType;
+import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
+import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
+
+import java.util.Date;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import io.swagger.v3.oas.annotations.media.Schema;
+
+/**
+ * Lightweight response VO for workflow instance list / top-N / trigger
queries.
+ *
+ * <p>Unlike {@link WorkflowInstance}, this VO intentionally omits heavy
columns
+ * that are only needed for detail views or internal processing. This allows
the
+ * corresponding DAO queries to use the optimized {@code listSql} projection
+ * instead of the full {@code baseSql}.
+ *
+ * <p><b>Incompatible API change (documented):</b> The following properties
that
+ * were previously present in list/topN/trigger API responses are no longer
+ * returned:
+ *
+ * <p><b>Heavy DB-backed fields removed from the SQL projection:</b>
+ * <ul>
+ * <li>{@code commandParam}</li>
+ * <li>{@code globalParams}</li>
+ * <li>{@code historyCmd}</li>
+ * <li>{@code varPool}</li>
+ * <li>{@code stateHistory}</li>
+ * </ul>
+ *
+ * <p><b>Transient (non-DB) fields removed from the entity that were always
+ * {@code null} in list responses:</b>
+ * <ul>
+ * <li>{@code stateDescList}</li>
+ * <li>{@code workflowDefinition} (deprecated)</li>
+ * <li>{@code dagData}</li>
+ * <li>{@code queue}</li>
+ * <li>{@code locations}</li>
+ * <li>{@code dependenceScheduleTimes}</li>
+ * </ul>
+ *
+ * <p><b>Derived getter properties removed:</b>
+ * <ul>
+ * <li>{@code cmdTypeIfComplement} — previously returned
+ * {@link CommandType#COMPLEMENT_DATA} for complement-data executions;
+ * consumers should inspect {@code commandType} on the detail endpoint
+ * instead</li>
+ * <li>{@code complementData} — previously returned {@code true} for
+ * complement-data executions; no longer available in list responses</li>
+ * </ul>
+ *
+ * <p>Consumers that require any of these fields should call the detail
endpoint
+ * {@code GET /projects/{projectCode}/workflow-instances/{id}} instead, which
+ * continues to return the full {@link WorkflowInstance}.
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Schema(name = "WORKFLOW_INSTANCE_QUERY_RESPONSE")
+public class WorkflowInstanceSummaryVO {
+
+ @Schema(description = "workflow instance id")
+ private Integer id;
+
+ @Schema(description = "workflow definition code")
+ private Long workflowDefinitionCode;
+
+ @Schema(description = "workflow definition version")
+ private int workflowDefinitionVersion;
+
+ @Schema(description = "project code")
+ private Long projectCode;
+
+ @Schema(description = "workflow execution status")
+ private WorkflowExecutionStatus state;
+
+ @Schema(description = "recovery flag")
+ private Flag recovery;
+
+ @Schema(description = "start time")
+ private Date startTime;
+
+ @Schema(description = "end time")
+ private Date endTime;
+
+ @Schema(description = "run times")
+ private int runTimes;
+
+ @Schema(description = "workflow instance name")
+ private String name;
+
+ @Schema(description = "host")
+ private String host;
+
+ @Schema(description = "command type")
+ private CommandType commandType;
+
+ @Schema(description = "task depend type")
+ private TaskDependType taskDependType;
+
+ @Schema(description = "max try times")
+ private int maxTryTimes;
+
+ @Schema(description = "failure strategy")
+ private FailureStrategy failureStrategy;
+
+ @Schema(description = "warning type")
+ private WarningType warningType;
+
+ @Schema(description = "warning group id")
+ private Integer warningGroupId;
+
+ @Schema(description = "schedule time")
+ private Date scheduleTime;
+
+ @Schema(description = "command start time")
+ private Date commandStartTime;
+
+ @Schema(description = "is sub workflow")
+ private Flag isSubWorkflow;
+
+ @Schema(description = "executor id")
+ private int executorId;
+
+ @Schema(description = "executor name")
+ private String executorName;
+
+ @Schema(description = "workflow instance priority")
+ private Priority workflowInstancePriority;
+
+ @Schema(description = "worker group")
+ private String workerGroup;
+
+ @Schema(description = "environment code")
+ private Long environmentCode;
+
+ @Schema(description = "timeout")
+ private int timeout;
+
+ @Schema(description = "tenant code")
+ private String tenantCode;
+
+ @Schema(description = "dry run")
+ private int dryRun;
+
+ @Schema(description = "next workflow instance id")
+ private int nextWorkflowInstanceId;
+
+ @Schema(description = "restart time")
+ private Date restartTime;
+
+ @Schema(description = "duration string, e.g. 1h 2m 3s")
+ private String duration;
+
+ /**
+ * Create a {@link WorkflowInstanceSummaryVO} from a {@link
WorkflowInstanceSummaryDto} DAO DTO.
+ */
+ public static WorkflowInstanceSummaryVO
fromSummaryDto(WorkflowInstanceSummaryDto dto) {
+ return new WorkflowInstanceSummaryVO(
+ dto.getId(),
+ dto.getWorkflowDefinitionCode(),
+ dto.getWorkflowDefinitionVersion(),
+ dto.getProjectCode(),
+ dto.getState(),
+ dto.getRecovery(),
+ dto.getStartTime(),
+ dto.getEndTime(),
+ dto.getRunTimes(),
+ dto.getName(),
+ dto.getHost(),
+ dto.getCommandType(),
+ dto.getTaskDependType(),
+ dto.getMaxTryTimes(),
+ dto.getFailureStrategy(),
+ dto.getWarningType(),
+ dto.getWarningGroupId(),
+ dto.getScheduleTime(),
+ dto.getCommandStartTime(),
+ dto.getIsSubWorkflow(),
+ dto.getExecutorId(),
+ dto.getExecutorName(),
+ dto.getWorkflowInstancePriority(),
+ dto.getWorkerGroup(),
+ dto.getEnvironmentCode(),
+ dto.getTimeout(),
+ dto.getTenantCode(),
+ dto.getDryRun(),
+ dto.getNextWorkflowInstanceId(),
+ dto.getRestartTime(),
+ dto.getDuration());
+ }
+}
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceControllerTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceControllerTest.java
index ada5e70e92..b783aabdd0 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceControllerTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceControllerTest.java
@@ -28,14 +28,18 @@ import
org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceVari
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.WorkflowInstanceService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.api.vo.WorkflowInstanceSummaryVO;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -51,10 +55,33 @@ public class WorkflowInstanceControllerTest extends
AbstractControllerTest {
@MockBean
private WorkflowInstanceService workflowInstanceService;
+ /**
+ * All properties that were present on {@link WorkflowInstance} but are
+ * intentionally removed from {@link WorkflowInstanceSummaryVO} and thus
from
+ * the list/topN/trigger API response. This list must stay in sync with the
+ * incompatible-change documentation in incompatible.md (version 3.5.0).
+ */
+ private static final List<String> REMOVED_RESPONSE_PROPERTIES =
java.util.Arrays.asList(
+ // Heavy DB-backed fields removed from the SQL projection
+ "commandParam", "globalParams", "historyCmd", "varPool",
"stateHistory",
+ // Transient (non-DB) fields that were always null in list
responses
+ "stateDescList", "workflowDefinition", "dagData", "queue",
+ "locations", "dependenceScheduleTimes",
+ // Derived getter properties
+ "cmdTypeIfComplement", "complementData");
+
@Test
public void testQueryWorkflowInstanceList() throws Exception {
- Result mockResult = new Result<>();
+ WorkflowInstanceSummaryVO dto = new WorkflowInstanceSummaryVO();
+ dto.setId(1);
+ dto.setName("test-workflow");
+ PageInfo<WorkflowInstanceSummaryVO> pageInfo = new PageInfo<>(1, 10);
+ pageInfo.setTotalList(java.util.Collections.singletonList(dto));
+ pageInfo.setTotal(1);
+
+ Result<PageInfo<WorkflowInstanceSummaryVO>> mockResult = new
Result<>();
mockResult.setCode(Status.SUCCESS.getCode());
+ mockResult.setData(pageInfo);
Mockito.when(workflowInstanceService
.queryWorkflowInstanceList(Mockito.any(), Mockito.anyLong(),
Mockito.anyLong(), Mockito.any(),
Mockito.any(), Mockito.any(), Mockito.any(),
Mockito.any(), Mockito.any(), Mockito.any(),
@@ -77,9 +104,44 @@ public class WorkflowInstanceControllerTest extends
AbstractControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
- Result result =
JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(),
Result.class);
+ String responseBody = mvcResult.getResponse().getContentAsString();
+ Result result = JSONUtils.parseObject(responseBody, Result.class);
Assertions.assertNotNull(result);
Assertions.assertEquals(Status.SUCCESS.getCode(),
result.getCode().intValue());
+
+ // Parse the JSON tree and navigate to the DTO object in the response
+ com.fasterxml.jackson.databind.node.ObjectNode root =
JSONUtils.parseObject(responseBody);
+ com.fasterxml.jackson.databind.JsonNode dtoNode =
+ root.path("data").path("totalList").path(0);
+ Assertions.assertTrue(dtoNode.isObject(),
+ "Response data.totalList[0] should be a JSON object (the
DTO)");
+ java.util.Set<String> jsonKeys = new java.util.HashSet<>();
+ dtoNode.fieldNames().forEachRemaining(jsonKeys::add);
+
+ // Verify that none of the removed properties appear in the serialized
response
+ for (String removed : REMOVED_RESPONSE_PROPERTIES) {
+ Assertions.assertFalse(jsonKeys.contains(removed),
+ "List endpoint response JSON should not contain key '" +
removed
+ + "' — it is removed from
WorkflowInstanceSummaryVO");
+ }
+
+ // Positive assertion: verify all expected DTO fields are present in
the response.
+ // This catches accidental omission of fields that should be retained.
+ java.util.Set<String> expectedKeys = new
java.util.HashSet<>(java.util.Arrays.asList(
+ "id", "name", "workflowDefinitionCode",
"workflowDefinitionVersion",
+ "projectCode", "state", "recovery", "startTime", "endTime",
+ "runTimes", "host", "commandType", "taskDependType",
+ "maxTryTimes", "failureStrategy", "warningType",
"warningGroupId",
+ "scheduleTime", "commandStartTime",
+ "isSubWorkflow", "executorId", "workflowInstancePriority",
+ "workerGroup", "environmentCode", "timeout", "tenantCode",
+ "dryRun", "nextWorkflowInstanceId", "restartTime", "duration",
+ "executorName"));
+ for (String expected : expectedKeys) {
+ Assertions.assertTrue(jsonKeys.contains(expected),
+ "List endpoint response JSON should contain key '" +
expected
+ + "' — it is a required DTO field");
+ }
}
@Test
@@ -254,4 +316,60 @@ public class WorkflowInstanceControllerTest extends
AbstractControllerTest {
Assertions.assertNotNull(result);
Assertions.assertEquals(Status.SUCCESS.getCode(),
result.getCode().intValue());
}
+
+ @Test
+ public void testWorkflowInstanceSummaryVO_omitsRemovedProperties() {
+ // Verify via reflection that WorkflowInstanceSummaryVO does NOT
declare
+ // the 5 heavy DB-backed fields removed from the list API response
contract.
+ List<String> heavyFields = java.util.Arrays.asList(
+ "commandParam", "globalParams", "historyCmd", "varPool",
"stateHistory");
+ for (String field : heavyFields) {
+ Assertions.assertThrows(NoSuchFieldException.class,
+ () ->
WorkflowInstanceSummaryVO.class.getDeclaredField(field),
+ "WorkflowInstanceSummaryVO should NOT declare field '" +
field
+ + "' — it was intentionally removed from the list
API response contract");
+ }
+ }
+
+ @Test
+ public void testWorkflowInstanceSummaryVO_includesRequiredFields() {
+ // Verify that all fields present in listSql are also declared in the
DTO.
+ List<String> requiredFields = java.util.Arrays.asList(
+ "id", "name", "workflowDefinitionCode",
"workflowDefinitionVersion",
+ "projectCode", "state", "recovery", "startTime", "endTime",
+ "runTimes", "host", "commandType", "taskDependType",
+ "maxTryTimes", "failureStrategy", "warningType",
"warningGroupId",
+ "scheduleTime", "commandStartTime",
+ "isSubWorkflow", "executorId", "workflowInstancePriority",
+ "workerGroup", "environmentCode", "timeout", "tenantCode",
+ "dryRun", "nextWorkflowInstanceId", "restartTime", "duration",
+ "executorName");
+ for (String field : requiredFields) {
+ Assertions.assertDoesNotThrow(() ->
WorkflowInstanceSummaryVO.class.getDeclaredField(field),
+ "WorkflowInstanceSummaryVO should declare field '" + field
+ + "' — it must be present in the list API response
contract");
+ }
+ }
+
+ @Test
+ public void testFromSummaryDto_MapsAllFields() {
+ WorkflowInstanceSummaryDto dto = new WorkflowInstanceSummaryDto();
+ dto.setId(1);
+ dto.setName("test-workflow");
+ dto.setWorkflowDefinitionCode(123456L);
+ dto.setWorkflowDefinitionVersion(1);
+ dto.setProjectCode(789L);
+ dto.setState(WorkflowExecutionStatus.SUCCESS);
+ dto.setExecutorName("admin");
+ dto.setDuration("1h 2m");
+
+ WorkflowInstanceSummaryVO result =
WorkflowInstanceSummaryVO.fromSummaryDto(dto);
+
+ Assertions.assertEquals(1, result.getId());
+ Assertions.assertEquals("test-workflow", result.getName());
+ Assertions.assertEquals(123456L, result.getWorkflowDefinitionCode());
+ Assertions.assertEquals(WorkflowExecutionStatus.SUCCESS,
result.getState());
+ Assertions.assertEquals("admin", result.getExecutorName());
+ Assertions.assertEquals("1h 2m", result.getDuration());
+ }
}
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java
index 96baa93fb6..7fb5dd4c84 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java
@@ -37,7 +37,7 @@ import org.apache.dolphinscheduler.dao.entity.Queue;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.User;
-import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.ScheduleDao;
import org.apache.dolphinscheduler.dao.repository.TenantDao;
import org.apache.dolphinscheduler.dao.repository.UserDao;
@@ -289,9 +289,9 @@ public class TenantServiceTest {
return userList;
}
- private List<WorkflowInstance> getInstanceList() {
- List<WorkflowInstance> workflowInstances = new ArrayList<>();
- WorkflowInstance workflowInstance = new WorkflowInstance();
+ private List<WorkflowInstanceSummaryDto> getInstanceList() {
+ List<WorkflowInstanceSummaryDto> workflowInstances = new ArrayList<>();
+ WorkflowInstanceSummaryDto workflowInstance = new
WorkflowInstanceSummaryDto();
workflowInstances.add(workflowInstance);
return workflowInstances;
}
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
index e2ba1b7e6a..fed8fe383f 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
@@ -34,8 +34,8 @@ import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
-import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import
org.apache.dolphinscheduler.dao.mapper.EnvironmentWorkerGroupRelationMapper;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.ScheduleDao;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
import org.apache.dolphinscheduler.dao.repository.WorkerGroupDao;
@@ -229,9 +229,9 @@ public class WorkerGroupServiceTest {
baseServiceLogger)).thenReturn(true);
WorkerGroup workerGroup = getWorkerGroup(1);
when(workerGroupDao.queryById(1)).thenReturn(workerGroup);
- WorkflowInstance workflowInstance = new WorkflowInstance();
+ WorkflowInstanceSummaryDto workflowInstance = new
WorkflowInstanceSummaryDto();
workflowInstance.setId(1);
- List<WorkflowInstance> workflowInstances = new
ArrayList<WorkflowInstance>();
+ List<WorkflowInstanceSummaryDto> workflowInstances = new
ArrayList<WorkflowInstanceSummaryDto>();
workflowInstances.add(workflowInstance);
when(workflowInstanceDao.queryByWorkerGroupNameAndStatus(workerGroup.getName(),
WorkflowExecutionStatus.NOT_TERMINAL_STATES))
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceServiceTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceServiceTest.java
index aa694aa4ca..742fcf39b8 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceServiceTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceServiceTest.java
@@ -34,6 +34,7 @@ import
org.apache.dolphinscheduler.api.service.impl.LoggerServiceImpl;
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
import
org.apache.dolphinscheduler.api.service.impl.WorkflowInstanceServiceImpl;
import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.api.vo.WorkflowInstanceSummaryVO;
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.ContextType;
@@ -58,6 +59,7 @@ import
org.apache.dolphinscheduler.dao.entity.WorkflowDefinition;
import org.apache.dolphinscheduler.dao.entity.WorkflowDefinitionLog;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.mapper.WorkflowDefinitionLogMapper;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.ProjectDao;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
import org.apache.dolphinscheduler.dao.repository.TaskInstanceContextDao;
@@ -214,9 +216,10 @@ public class WorkflowInstanceServiceTest {
Date start = DateUtils.stringToDate("2020-01-01 00:00:00");
Date end = DateUtils.stringToDate("2020-01-02 00:00:00");
WorkflowInstance workflowInstance = getProcessInstance();
- List<WorkflowInstance> workflowInstanceList = new ArrayList<>();
- Page<WorkflowInstance> pageReturn = new Page<>(1, 10);
- workflowInstanceList.add(workflowInstance);
+ WorkflowInstanceSummaryDto summaryDto =
getWorkflowInstanceSummaryDto();
+ List<WorkflowInstanceSummaryDto> workflowInstanceList = new
ArrayList<>();
+ Page<WorkflowInstanceSummaryDto> pageReturn = new Page<>(1, 10);
+ workflowInstanceList.add(summaryDto);
pageReturn.setRecords(workflowInstanceList);
// data parameter check
@@ -313,12 +316,13 @@ public class WorkflowInstanceServiceTest {
// project auth success, trigger code null returns empty list
Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(loginUser,
project,
WORKFLOW_INSTANCE);
- List<WorkflowInstance> nullTriggerRes =
+ List<WorkflowInstanceSummaryVO> nullTriggerRes =
workflowInstanceService.queryByTriggerCode(loginUser,
projectCode, null);
Assertions.assertTrue(nullTriggerRes.isEmpty());
when(workflowInstanceDao.queryByTriggerCode(999L)).thenReturn(new
ArrayList<>());
- List<WorkflowInstance> emptyRes =
workflowInstanceService.queryByTriggerCode(loginUser, projectCode, 999L);
+ List<WorkflowInstanceSummaryVO> emptyRes =
+ workflowInstanceService.queryByTriggerCode(loginUser,
projectCode, 999L);
Assertions.assertTrue(emptyRes.isEmpty());
}
@@ -347,8 +351,9 @@ public class WorkflowInstanceServiceTest {
when(workflowInstanceDao.queryTopNWorkflowInstance(Mockito.eq(size),
Mockito.any(), Mockito.any(),
Mockito.eq(WorkflowExecutionStatus.SUCCESS),
Mockito.eq(projectCode)))
.thenReturn(new ArrayList<>());
- List<WorkflowInstance> successRes =
workflowInstanceService.queryTopNLongestRunningWorkflowInstance(loginUser,
- projectCode, size, startTime, endTime);
+ List<WorkflowInstanceSummaryVO> successRes =
+
workflowInstanceService.queryTopNLongestRunningWorkflowInstance(loginUser,
+ projectCode, size, startTime, endTime);
Assertions.assertNotNull(successRes);
}
@@ -981,6 +986,17 @@ public class WorkflowInstanceServiceTest {
return workflowInstance;
}
+ private WorkflowInstanceSummaryDto getWorkflowInstanceSummaryDto() {
+ WorkflowInstanceSummaryDto dto = new WorkflowInstanceSummaryDto();
+ dto.setId(1);
+ dto.setName("test_process_instance");
+ dto.setWorkflowDefinitionCode(46L);
+ dto.setWorkflowDefinitionVersion(1);
+ dto.setStartTime(new Date());
+ dto.setEndTime(new Date());
+ return dto;
+ }
+
/**
* get mock processDefinition
*
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.java
index aa88680ae7..929632c1a2 100644
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.java
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.java
@@ -21,6 +21,7 @@ import
org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.model.WorkflowInstanceStatusCountDto;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.ibatis.annotations.Param;
@@ -50,8 +51,8 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @param stateArray stateArray
* @return workflow instance list
*/
- List<WorkflowInstance> queryByHostAndStatus(@Param("host") String host,
- @Param("states") int[]
stateArray);
+ List<WorkflowInstanceSummaryDto> queryByHostAndStatus(@Param("host")
String host,
+ @Param("states")
int[] stateArray);
/**
* query workflow instance host by stateArray
@@ -68,16 +69,16 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @param states states array
* @return workflow instance list
*/
- List<WorkflowInstance> queryByTenantCodeAndStatus(@Param("tenantCode")
String tenantCode,
- @Param("states") int[]
states);
+ List<WorkflowInstanceSummaryDto>
queryByTenantCodeAndStatus(@Param("tenantCode") String tenantCode,
+
@Param("states") int[] states);
/**
* @param workerGroupName workerGroupName
* @param states states array
* @return workflow instance list
*/
- List<WorkflowInstance>
queryByWorkerGroupNameAndStatus(@Param("workerGroupName") String
workerGroupName,
- @Param("states")
int[] states);
+ List<WorkflowInstanceSummaryDto>
queryByWorkerGroupNameAndStatus(@Param("workerGroupName") String
workerGroupName,
+
@Param("states") int[] states);
/**
* workflow instance page
@@ -107,15 +108,15 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @param endTime endTime
* @return workflow instance page
*/
- IPage<WorkflowInstance>
queryWorkflowInstanceListPaging(Page<WorkflowInstance> page,
-
@Param("projectCode") Long projectCode,
-
@Param("workflowDefinitionCode") Long workflowDefinitionCode,
-
@Param("searchVal") String searchVal,
-
@Param("executorName") String executorName,
- @Param("states")
int[] statusArray,
- @Param("host")
String host,
-
@Param("startTime") Date startTime,
- @Param("endTime")
Date endTime);
+ IPage<WorkflowInstanceSummaryDto>
queryWorkflowInstanceListPaging(Page<WorkflowInstanceSummaryDto> page,
+
@Param("projectCode") Long projectCode,
+
@Param("workflowDefinitionCode") Long workflowDefinitionCode,
+
@Param("searchVal") String searchVal,
+
@Param("executorName") String executorName,
+
@Param("states") int[] statusArray,
+
@Param("host") String host,
+
@Param("startTime") Date startTime,
+
@Param("endTime") Date endTime);
/**
* set failover by host and state array
@@ -179,8 +180,8 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @param size size
* @return workflow instance list
*/
- List<WorkflowInstance>
queryByWorkflowDefinitionCode(@Param("workflowDefinitionCode") Long
workflowDefinitionCode,
- @Param("size") int
size);
+ List<WorkflowInstanceSummaryDto>
queryByWorkflowDefinitionCode(@Param("workflowDefinitionCode") Long
workflowDefinitionCode,
+
@Param("size") int size);
/**
* query last scheduler workflow instance
@@ -221,7 +222,7 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @param workflowDefinitionCode workflowDefinitionCode
* @return workflow instance
*/
- WorkflowInstance
queryFirstScheduleWorkflowInstance(@Param("workflowDefinitionCode") Long
workflowDefinitionCode);
+ WorkflowInstanceSummaryDto
queryFirstScheduleWorkflowInstance(@Param("workflowDefinitionCode") Long
workflowDefinitionCode);
/**
* query first manual workflow instance
@@ -229,7 +230,7 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @param workflowDefinitionCode workflowDefinitionCode
* @return workflow instance
*/
- WorkflowInstance
queryFirstStartWorkflowInstance(@Param("workflowDefinitionCode") Long
workflowDefinitionCode);
+ WorkflowInstanceSummaryDto
queryFirstStartWorkflowInstance(@Param("workflowDefinitionCode") Long
workflowDefinitionCode);
/**
* query top n workflow instance order by running duration
@@ -242,11 +243,11 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @return ProcessInstance list
*/
- List<WorkflowInstance> queryTopNWorkflowInstance(@Param("size") int size,
- @Param("startTime") Date
startTime,
- @Param("endTime") Date
endTime,
- @Param("status")
WorkflowExecutionStatus status,
- @Param("projectCode")
long projectCode);
+ List<WorkflowInstanceSummaryDto> queryTopNWorkflowInstance(@Param("size")
int size,
+
@Param("startTime") Date startTime,
+
@Param("endTime") Date endTime,
+
@Param("status") WorkflowExecutionStatus status,
+
@Param("projectCode") long projectCode);
/**
* query workflow instance by workflowDefinitionCode and stateArray
@@ -256,12 +257,12 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @return workflow instance list
*/
- List<WorkflowInstance>
queryByWorkflowDefinitionCodeAndStatus(@Param("workflowDefinitionCode") Long
workflowDefinitionCode,
-
@Param("states") int[] states);
+ List<WorkflowInstanceSummaryDto>
queryByWorkflowDefinitionCodeAndStatus(@Param("workflowDefinitionCode") Long
workflowDefinitionCode,
+
@Param("states") int[] states);
- List<WorkflowInstance>
queryByWorkflowCodeVersionStatus(@Param("workflowDefinitionCode") long
workflowDefinitionCode,
-
@Param("workflowDefinitionVersion") int workflowDefinitionVersion,
- @Param("states")
int[] states);
+ List<WorkflowInstanceSummaryDto>
queryByWorkflowCodeVersionStatus(@Param("workflowDefinitionCode") long
workflowDefinitionCode,
+
@Param("workflowDefinitionVersion") int workflowDefinitionVersion,
+
@Param("states") int[] states);
/**
* Filter workflow instance
@@ -274,14 +275,14 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @param endTime endTime
* @return workflow instance IPage
*/
- IPage<WorkflowInstance>
queryWorkflowInstanceListV2Paging(Page<WorkflowInstance> page,
-
@Param("projectCode") Long projectCode,
-
@Param("workflowDefinitionCode") Long workflowDefinitionCode,
- @Param("name")
String name,
-
@Param("startTime") String startTime,
-
@Param("endTime") String endTime,
- @Param("state")
Integer state,
- @Param("host")
String host);
+ IPage<WorkflowInstanceSummaryDto>
queryWorkflowInstanceListV2Paging(Page<WorkflowInstanceSummaryDto> page,
+
@Param("projectCode") Long projectCode,
+
@Param("workflowDefinitionCode") Long workflowDefinitionCode,
+
@Param("name") String name,
+
@Param("startTime") String startTime,
+
@Param("endTime") String endTime,
+
@Param("state") Integer state,
+
@Param("host") String host);
/**
* Statistics workflow instance state v2
@@ -310,5 +311,5 @@ public interface WorkflowInstanceMapper extends
BaseMapper<WorkflowInstance> {
* @param triggerCode
* @return
*/
- List<WorkflowInstance> queryByTriggerCode(@Param("triggerCode") Long
triggerCode);
+ List<WorkflowInstanceSummaryDto> queryByTriggerCode(@Param("triggerCode")
Long triggerCode);
}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/model/WorkflowInstanceSummaryDto.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/model/WorkflowInstanceSummaryDto.java
new file mode 100644
index 0000000000..e6748c6ba9
--- /dev/null
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/model/WorkflowInstanceSummaryDto.java
@@ -0,0 +1,107 @@
+/*
+ * 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.dao.model;
+
+import org.apache.dolphinscheduler.common.enums.CommandType;
+import org.apache.dolphinscheduler.common.enums.FailureStrategy;
+import org.apache.dolphinscheduler.common.enums.Flag;
+import org.apache.dolphinscheduler.common.enums.Priority;
+import org.apache.dolphinscheduler.common.enums.TaskDependType;
+import org.apache.dolphinscheduler.common.enums.WarningType;
+import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
+
+import java.util.Date;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class WorkflowInstanceSummaryDto {
+
+ private Integer id;
+
+ private String name;
+
+ private int workflowDefinitionVersion;
+
+ private Long workflowDefinitionCode;
+
+ private Long projectCode;
+
+ private WorkflowExecutionStatus state;
+
+ private Flag recovery;
+
+ private Date startTime;
+
+ private Date endTime;
+
+ private int runTimes;
+
+ private String host;
+
+ private CommandType commandType;
+
+ private TaskDependType taskDependType;
+
+ private int maxTryTimes;
+
+ private FailureStrategy failureStrategy;
+
+ private WarningType warningType;
+
+ private Integer warningGroupId;
+
+ private Date scheduleTime;
+
+ private Date commandStartTime;
+
+ private Flag isSubWorkflow;
+
+ private int executorId;
+
+ private Priority workflowInstancePriority;
+
+ private String workerGroup;
+
+ private Long environmentCode;
+
+ private int timeout;
+
+ private String tenantCode;
+
+ private int dryRun;
+
+ private int nextWorkflowInstanceId;
+
+ private Date restartTime;
+
+ /**
+ * Executor name, populated by the application layer (not a DB column in
the listSql projection).
+ */
+ private String executorName;
+
+ /**
+ * Workflow execution duration, e.g. "1h 2m 3s", populated by the
application layer.
+ */
+ private String duration;
+
+}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/WorkflowInstanceDao.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/WorkflowInstanceDao.java
index 248391aa45..e329644721 100644
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/WorkflowInstanceDao.java
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/WorkflowInstanceDao.java
@@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.dao.repository;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.model.WorkflowInstanceStatusCountDto;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval;
import java.util.Collection;
@@ -76,7 +77,7 @@ public interface WorkflowInstanceDao extends
IDao<WorkflowInstance> {
* @param definitionCode definitionCode
* @return workflow instance
*/
- WorkflowInstance queryFirstScheduleWorkflowInstance(Long definitionCode);
+ WorkflowInstanceSummaryDto queryFirstScheduleWorkflowInstance(Long
definitionCode);
/**
* query first manual workflow instance
@@ -84,20 +85,20 @@ public interface WorkflowInstanceDao extends
IDao<WorkflowInstance> {
* @param definitionCode definitionCode
* @return workflow instance
*/
- WorkflowInstance queryFirstStartWorkflowInstance(Long definitionCode);
+ WorkflowInstanceSummaryDto queryFirstStartWorkflowInstance(Long
definitionCode);
WorkflowInstance querySubWorkflowInstanceByParentId(Integer
workflowInstanceId, Integer taskInstanceId);
- List<WorkflowInstance> queryByWorkflowCodeVersionStatus(Long
workflowDefinitionCode,
- int
workflowDefinitionVersion,
- int[] states);
+ List<WorkflowInstanceSummaryDto> queryByWorkflowCodeVersionStatus(Long
workflowDefinitionCode,
+ int
workflowDefinitionVersion,
+ int[]
states);
List<String> queryNeedFailoverMasters();
/**
* Query the workflow instances under the master that need to be failover.
*/
- List<WorkflowInstance> queryNeedFailoverWorkflowInstances(String
masterAddress);
+ List<WorkflowInstanceSummaryDto> queryNeedFailoverWorkflowInstances(String
masterAddress);
WorkflowInstance queryDetailById(int id);
@@ -109,29 +110,29 @@ public interface WorkflowInstanceDao extends
IDao<WorkflowInstance> {
int updateWorkflowInstanceByWorkerGroupName(String originWorkerGroupName,
String destWorkerGroupName);
- List<WorkflowInstance> queryByTenantCodeAndStatus(String tenantCode, int[]
states);
+ List<WorkflowInstanceSummaryDto> queryByTenantCodeAndStatus(String
tenantCode, int[] states);
- List<WorkflowInstance> queryByWorkerGroupNameAndStatus(String
workerGroupName, int[] states);
+ List<WorkflowInstanceSummaryDto> queryByWorkerGroupNameAndStatus(String
workerGroupName, int[] states);
- List<WorkflowInstance> queryTopNWorkflowInstance(int size,
- Date startTime,
- Date endTime,
- WorkflowExecutionStatus
status,
- long projectCode);
+ List<WorkflowInstanceSummaryDto> queryTopNWorkflowInstance(int size,
+ Date startTime,
+ Date endTime,
+
WorkflowExecutionStatus status,
+ long
projectCode);
- IPage<WorkflowInstance>
queryWorkflowInstanceListPaging(Page<WorkflowInstance> page,
- Long projectCode,
- Long
workflowDefinitionCode,
- String searchVal,
- String
executorName,
- int[] statusArray,
- String host,
- Date startTime,
- Date endTime);
+ IPage<WorkflowInstanceSummaryDto>
queryWorkflowInstanceListPaging(Page<WorkflowInstanceSummaryDto> page,
+ Long
projectCode,
+ Long
workflowDefinitionCode,
+ String
searchVal,
+ String
executorName,
+ int[]
statusArray,
+ String
host,
+ Date
startTime,
+ Date
endTime);
- List<WorkflowInstance> queryByWorkflowDefinitionCodeAndStatus(Long
workflowDefinitionCode, int[] states);
+ List<WorkflowInstanceSummaryDto>
queryByWorkflowDefinitionCodeAndStatus(Long workflowDefinitionCode, int[]
states);
- List<WorkflowInstance> queryByWorkflowDefinitionCode(Long
workflowDefinitionCode, int size);
+ List<WorkflowInstanceSummaryDto> queryByWorkflowDefinitionCode(Long
workflowDefinitionCode, int size);
- List<WorkflowInstance> queryByTriggerCode(Long triggerCode);
+ List<WorkflowInstanceSummaryDto> queryByTriggerCode(Long triggerCode);
}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/WorkflowInstanceDaoImpl.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/WorkflowInstanceDaoImpl.java
index 9d8772d6c7..661c97816f 100644
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/WorkflowInstanceDaoImpl.java
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/WorkflowInstanceDaoImpl.java
@@ -23,6 +23,7 @@ import
org.apache.dolphinscheduler.dao.entity.WorkflowInstanceRelation;
import org.apache.dolphinscheduler.dao.mapper.WorkflowInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.WorkflowInstanceRelationMapper;
import org.apache.dolphinscheduler.dao.model.WorkflowInstanceStatusCountDto;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.BaseDao;
import org.apache.dolphinscheduler.dao.repository.WorkflowInstanceDao;
import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval;
@@ -135,7 +136,7 @@ public class WorkflowInstanceDaoImpl extends
BaseDao<WorkflowInstance, WorkflowI
* @return process instance
*/
@Override
- public WorkflowInstance queryFirstScheduleWorkflowInstance(Long
definitionCode) {
+ public WorkflowInstanceSummaryDto queryFirstScheduleWorkflowInstance(Long
definitionCode) {
return
mybatisMapper.queryFirstScheduleWorkflowInstance(definitionCode);
}
@@ -146,7 +147,7 @@ public class WorkflowInstanceDaoImpl extends
BaseDao<WorkflowInstance, WorkflowI
* @return process instance
*/
@Override
- public WorkflowInstance queryFirstStartWorkflowInstance(Long
definitionCode) {
+ public WorkflowInstanceSummaryDto queryFirstStartWorkflowInstance(Long
definitionCode) {
return mybatisMapper.queryFirstStartWorkflowInstance(definitionCode);
}
@@ -163,9 +164,9 @@ public class WorkflowInstanceDaoImpl extends
BaseDao<WorkflowInstance, WorkflowI
}
@Override
- public List<WorkflowInstance> queryByWorkflowCodeVersionStatus(Long
workflowDefinitionCode,
- int
workflowDefinitionVersion,
- int[]
states) {
+ public List<WorkflowInstanceSummaryDto>
queryByWorkflowCodeVersionStatus(Long workflowDefinitionCode,
+
int workflowDefinitionVersion,
+
int[] states) {
return
mybatisMapper.queryByWorkflowCodeVersionStatus(workflowDefinitionCode,
workflowDefinitionVersion,
states);
}
@@ -177,7 +178,7 @@ public class WorkflowInstanceDaoImpl extends
BaseDao<WorkflowInstance, WorkflowI
}
@Override
- public List<WorkflowInstance> queryNeedFailoverWorkflowInstances(String
masterAddress) {
+ public List<WorkflowInstanceSummaryDto>
queryNeedFailoverWorkflowInstances(String masterAddress) {
return mybatisMapper.queryByHostAndStatus(masterAddress,
WorkflowExecutionStatus.NEED_FAILOVER_STATES);
}
@@ -205,50 +206,51 @@ public class WorkflowInstanceDaoImpl extends
BaseDao<WorkflowInstance, WorkflowI
}
@Override
- public List<WorkflowInstance> queryByTenantCodeAndStatus(String
tenantCode, int[] states) {
+ public List<WorkflowInstanceSummaryDto> queryByTenantCodeAndStatus(String
tenantCode, int[] states) {
return mybatisMapper.queryByTenantCodeAndStatus(tenantCode, states);
}
@Override
- public List<WorkflowInstance> queryByWorkerGroupNameAndStatus(String
workerGroupName, int[] states) {
+ public List<WorkflowInstanceSummaryDto>
queryByWorkerGroupNameAndStatus(String workerGroupName, int[] states) {
return mybatisMapper.queryByWorkerGroupNameAndStatus(workerGroupName,
states);
}
@Override
- public List<WorkflowInstance> queryTopNWorkflowInstance(int size,
- Date startTime,
- Date endTime,
-
WorkflowExecutionStatus status,
- long projectCode) {
+ public List<WorkflowInstanceSummaryDto> queryTopNWorkflowInstance(int size,
+ Date
startTime,
+ Date
endTime,
+
WorkflowExecutionStatus status,
+ long
projectCode) {
return mybatisMapper.queryTopNWorkflowInstance(size, startTime,
endTime, status, projectCode);
}
@Override
- public IPage<WorkflowInstance>
queryWorkflowInstanceListPaging(Page<WorkflowInstance> page,
- Long
projectCode,
- Long
workflowDefinitionCode,
- String
searchVal,
- String
executorName,
- int[]
statusArray,
- String host,
- Date
startTime,
- Date
endTime) {
+ public IPage<WorkflowInstanceSummaryDto>
queryWorkflowInstanceListPaging(Page<WorkflowInstanceSummaryDto> page,
+
Long projectCode,
+
Long workflowDefinitionCode,
+
String searchVal,
+
String executorName,
+
int[] statusArray,
+
String host,
+
Date startTime,
+
Date endTime) {
return mybatisMapper.queryWorkflowInstanceListPaging(page,
projectCode, workflowDefinitionCode, searchVal,
executorName, statusArray, host, startTime, endTime);
}
@Override
- public List<WorkflowInstance> queryByWorkflowDefinitionCodeAndStatus(Long
workflowDefinitionCode, int[] states) {
+ public List<WorkflowInstanceSummaryDto>
queryByWorkflowDefinitionCodeAndStatus(Long workflowDefinitionCode,
+
int[] states) {
return
mybatisMapper.queryByWorkflowDefinitionCodeAndStatus(workflowDefinitionCode,
states);
}
@Override
- public List<WorkflowInstance> queryByWorkflowDefinitionCode(Long
workflowDefinitionCode, int size) {
+ public List<WorkflowInstanceSummaryDto> queryByWorkflowDefinitionCode(Long
workflowDefinitionCode, int size) {
return
mybatisMapper.queryByWorkflowDefinitionCode(workflowDefinitionCode, size);
}
@Override
- public List<WorkflowInstance> queryByTriggerCode(Long triggerCode) {
+ public List<WorkflowInstanceSummaryDto> queryByTriggerCode(Long
triggerCode) {
return mybatisMapper.queryByTriggerCode(triggerCode);
}
}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/WorkflowUtils.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/WorkflowUtils.java
index aacac6a013..0b26b0e53b 100644
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/WorkflowUtils.java
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/WorkflowUtils.java
@@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.dao.utils;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import java.util.Date;
@@ -37,4 +38,18 @@ public class WorkflowUtils {
: DateUtils.format2Duration(workflowInstance.getStartTime(),
new Date());
}
+ /**
+ * get workflow duration from a {@link WorkflowInstanceSummaryDto}
+ *
+ * @param workflowInstanceSummaryDto workflow instance summary dto
+ * @return workflow duration
+ */
+ public static String
getWorkflowInstanceDuration(WorkflowInstanceSummaryDto
workflowInstanceSummaryDto) {
+ return workflowInstanceSummaryDto.getState() != null
+ && workflowInstanceSummaryDto.getState().isFinalState()
+ ?
DateUtils.format2Duration(workflowInstanceSummaryDto.getStartTime(),
+ workflowInstanceSummaryDto.getEndTime())
+ :
DateUtils.format2Duration(workflowInstanceSummaryDto.getStartTime(), new
Date());
+ }
+
}
diff --git
a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.xml
b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.xml
index 906e72137f..f470089429 100644
---
a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.xml
+++
b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.xml
@@ -27,6 +27,20 @@
workflow_instance_priority, worker_group,environment_code, timeout,
tenant_code, var_pool,
dry_run, next_workflow_instance_id, restart_time, state_history
</sql>
+ <!--
+ Lightweight column projection for list/scan queries (internal + API).
+ Intentionally omits: commandParam, globalParams, historyCmd, varPool,
stateHistory.
+ These 5 columns are large and only needed for detail views or internal
processing.
+ -->
+ <sql id="listSql">
+ id
+ , name, workflow_definition_version, workflow_definition_code,
project_code, state, recovery, start_time, end_time, run_times,host,
+ command_type, task_depend_type, max_try_times, failure_strategy,
warning_type,
+ warning_group_id, schedule_time, command_start_time, flag,
+ update_time, is_sub_workflow, executor_id,
+ workflow_instance_priority, worker_group,environment_code, timeout,
tenant_code,
+ dry_run, next_workflow_instance_id, restart_time
+ </sql>
<select id="queryDetailById"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
select
@@ -34,9 +48,9 @@
from t_ds_workflow_instance
where id = #{id}
</select>
- <select id="queryByHostAndStatus"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryByHostAndStatus"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where 1=1
<if test="host != null and host != ''">
@@ -61,9 +75,9 @@
</if>
</select>
- <select id="queryTopNWorkflowInstance"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryTopNWorkflowInstance"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where state = #{status}
<if test="projectCode != 0">
@@ -75,9 +89,9 @@
limit #{size}
</select>
- <select id="queryByTenantCodeAndStatus"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryByTenantCodeAndStatus"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where 1=1
<if test="tenantCode != ''">
@@ -91,10 +105,9 @@
</if>
order by id asc
</select>
-
- <select id="queryByWorkerGroupNameAndStatus"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryByWorkerGroupNameAndStatus"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where 1=1
<if test="workerGroupName != ''">
@@ -109,9 +122,9 @@
order by id asc
</select>
- <select id="queryWorkflowInstanceListPaging"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryWorkflowInstanceListPaging"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where is_sub_workflow=0
and project_code = #{projectCode}
@@ -193,9 +206,9 @@
group by state
</select>
- <select id="queryByWorkflowDefinitionCode"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryByWorkflowDefinitionCode"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where workflow_definition_code=#{workflowDefinitionCode}
order by start_time desc limit #{size}
@@ -254,28 +267,26 @@
</if>
order by start_time desc limit 1
</select>
-
- <select id="queryFirstScheduleWorkflowInstance"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryFirstScheduleWorkflowInstance"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where workflow_definition_code = #{workflowDefinitionCode} and
schedule_time is not null
order by schedule_time
limit 1
</select>
-
- <select id="queryFirstStartWorkflowInstance"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryFirstStartWorkflowInstance"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where workflow_definition_code = #{workflowDefinitionCode} and
start_time is not null
order by start_time
limit 1
</select>
- <select id="queryByWorkflowDefinitionCodeAndStatus"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryByWorkflowDefinitionCodeAndStatus"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where workflow_definition_code=#{workflowDefinitionCode}
<if test="states != null and states.length != 0">
@@ -286,10 +297,9 @@
</if>
order by id asc
</select>
-
- <select id="queryByWorkflowCodeVersionStatus"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryByWorkflowCodeVersionStatus"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance
where workflow_definition_code=#{workflowDefinitionCode}
and workflow_definition_version = #{workflowDefinitionVersion}
@@ -301,9 +311,9 @@
</if>
</select>
- <select id="queryWorkflowInstanceListV2Paging"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryWorkflowInstanceListV2Paging"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
SELECT
- <include refid="baseSql"/>
+ <include refid="listSql"/>
FROM t_ds_workflow_instance
where is_sub_workflow=0
<if test="projectCode != 0">
@@ -355,9 +365,9 @@
</select>
<!-- There are some columns with the same names in both tables, we use a
sub-query here to avoid ambiguity-->
- <select id="queryByTriggerCode"
resultType="org.apache.dolphinscheduler.dao.entity.WorkflowInstance">
+ <select id="queryByTriggerCode"
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto">
select
- <include refid="baseSql"/>
+ <include refid="listSql"/>
from t_ds_workflow_instance a
join
(select trigger_type, job_id, trigger_code from
t_ds_trigger_relation) b
diff --git
a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapperTest.java
b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapperTest.java
index 952c3480e5..61b0cadac1 100644
---
a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapperTest.java
+++
b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapperTest.java
@@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.model.WorkflowInstanceStatusCountDto;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import java.util.Date;
@@ -145,7 +146,8 @@ public class WorkflowInstanceMapperTest extends BaseDaoTest
{
TaskExecutionStatus.RUNNING_EXECUTION.getCode(),
TaskExecutionStatus.SUCCESS.getCode()};
- List<WorkflowInstance> workflowInstances =
workflowInstanceMapper.queryByHostAndStatus(null, stateArray);
+ List<WorkflowInstanceSummaryDto> workflowInstances =
+ workflowInstanceMapper.queryByHostAndStatus(null, stateArray);
workflowInstanceMapper.deleteById(workflowInstance.getId());
Assertions.assertNotEquals(0, workflowInstances.size());
@@ -178,9 +180,9 @@ public class WorkflowInstanceMapperTest extends BaseDaoTest
{
workflowInstanceMapper.updateById(workflowInstance);
- Page<WorkflowInstance> page = new Page(1, 3);
+ Page<WorkflowInstanceSummaryDto> page = new Page(1, 3);
- IPage<WorkflowInstance> processInstanceIPage =
workflowInstanceMapper.queryWorkflowInstanceListPaging(
+ IPage<WorkflowInstanceSummaryDto> processInstanceIPage =
workflowInstanceMapper.queryWorkflowInstanceListPaging(
page,
workflowDefinition.getProjectCode(),
workflowInstance.getWorkflowDefinitionCode(),
@@ -242,7 +244,7 @@ public class WorkflowInstanceMapperTest extends BaseDaoTest
{
WorkflowInstance workflowInstance = insertOne();
WorkflowInstance workflowInstance1 = insertOne();
- List<WorkflowInstance> workflowInstances =
+ List<WorkflowInstanceSummaryDto> workflowInstances =
workflowInstanceMapper.queryByWorkflowDefinitionCode(workflowInstance.getWorkflowDefinitionCode(),
1);
Assertions.assertEquals(1, workflowInstances.size());
@@ -301,7 +303,7 @@ public class WorkflowInstanceMapperTest extends BaseDaoTest
{
/**
* test whether it is in descending order by running duration
*/
- private boolean isSortedByDuration(List<WorkflowInstance>
workflowInstances) {
+ private boolean isSortedByDuration(List<WorkflowInstanceSummaryDto>
workflowInstances) {
for (int i = 1; i < workflowInstances.size(); i++) {
long d1 =
workflowInstances.get(i).getEndTime().getTime() -
workflowInstances.get(i).getStartTime().getTime();
@@ -330,11 +332,11 @@ public class WorkflowInstanceMapperTest extends
BaseDaoTest {
WorkflowInstance workflowInstance3 = insertOne(startTime3, endTime3);
Date start = new Date(2020, 1, 1, 1, 1, 1);
Date end = new Date(2021, 1, 1, 1, 1, 1);
- List<WorkflowInstance> workflowInstances =
+ List<WorkflowInstanceSummaryDto> workflowInstances =
workflowInstanceMapper.queryTopNWorkflowInstance(2, start,
end, WorkflowExecutionStatus.SUCCESS, 0L);
Assertions.assertEquals(2, workflowInstances.size());
Assertions.assertTrue(isSortedByDuration(workflowInstances));
- for (WorkflowInstance workflowInstance : workflowInstances) {
+ for (WorkflowInstanceSummaryDto workflowInstance : workflowInstances) {
Assertions.assertTrue(workflowInstance.getState().isSuccess());
}
workflowInstanceMapper.deleteById(workflowInstance1.getId());
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/FailoverCoordinator.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/FailoverCoordinator.java
index 500ef75856..51a38c848f 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/FailoverCoordinator.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/FailoverCoordinator.java
@@ -18,7 +18,7 @@
package org.apache.dolphinscheduler.server.master.failover;
import org.apache.dolphinscheduler.common.constants.Constants;
-import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.WorkflowInstanceDao;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.registry.api.RegistryClient;
@@ -152,7 +152,7 @@ public class FailoverCoordinator implements
IFailoverCoordinator {
masterFailoverNodePath);
return;
}
- final List<WorkflowInstance> needFailoverWorkflows =
+ final List<WorkflowInstanceSummaryDto> needFailoverWorkflows =
getFailoverWorkflowsForMaster(masterAddress, new
Date(workflowFailoverDeadline));
needFailoverWorkflows.forEach(workflowFailover::failoverWorkflow);
registryClient.persist(masterFailoverNodePath,
String.valueOf(workflowFailoverDeadline));
@@ -164,10 +164,10 @@ public class FailoverCoordinator implements
IFailoverCoordinator {
}
}
- private List<WorkflowInstance> getFailoverWorkflowsForMaster(final String
masterAddress,
- final Date
masterCrashTime) {
+ private List<WorkflowInstanceSummaryDto>
getFailoverWorkflowsForMaster(final String masterAddress,
+
final Date masterCrashTime) {
// todo: use page query
- final List<WorkflowInstance> workflowInstances =
+ final List<WorkflowInstanceSummaryDto> workflowInstances =
workflowInstanceDao.queryNeedFailoverWorkflowInstances(masterAddress);
return workflowInstances.stream()
.filter(workflowInstance -> {
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/WorkflowFailover.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/WorkflowFailover.java
index 24c4dde255..1bf31d3630 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/WorkflowFailover.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/WorkflowFailover.java
@@ -21,7 +21,7 @@ import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.Command;
-import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.CommandDao;
import org.apache.dolphinscheduler.dao.repository.WorkflowInstanceDao;
import
org.apache.dolphinscheduler.extract.master.command.WorkflowFailoverCommandParam;
@@ -44,7 +44,7 @@ public class WorkflowFailover {
private CommandDao commandDao;
@Transactional
- public void failoverWorkflow(final WorkflowInstance workflowInstance) {
+ public void failoverWorkflow(final WorkflowInstanceSummaryDto
workflowInstance) {
workflowInstanceDao.updateWorkflowInstanceState(
workflowInstance.getId(),
workflowInstance.getState(),
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
index 50ec9a46e4..638e4f7c0e 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
@@ -27,6 +27,7 @@ import
org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelation;
+import org.apache.dolphinscheduler.dao.model.WorkflowInstanceSummaryDto;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
@@ -452,7 +453,7 @@ public class DependentExecute {
* query the first workflowInstance by scheduleTime(or startTime if
scheduleTime is null)
*/
public boolean isFirstWorkflowInstance(DependentItem dependentItem) {
- WorkflowInstance firstWorkflowInstance =
+ WorkflowInstanceSummaryDto firstWorkflowInstance =
workflowInstanceDao.queryFirstScheduleWorkflowInstance(dependentItem.getDefinitionCode());
if (firstWorkflowInstance == null) {
firstWorkflowInstance =