Skip to content

Commit

Permalink
Fix home page workflow instance miss status (#15193)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanwenjun authored Nov 22, 2023
1 parent 7308888 commit df656a7
Show file tree
Hide file tree
Showing 56 changed files with 862 additions and 817 deletions.
2 changes: 1 addition & 1 deletion docs/docs/zh/guide/homepage.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 首页

Apache DolphinScheduler 首页可让您查看用户所有项目的任务状态统计、工作流状态统计和项目统计。 这是观察整个系统状态以及深入各个进程以检查任务和任务日志的每个状态的最佳方式。
Apache DolphinScheduler 首页可让您查看用户所有项目的任务实例状态统计、工作流实例状态统计和项目统计。 这是观察整个系统状态以及深入各个进程以检查任务和任务日志的每个状态的最佳方式。

![homepage](../../../img/new_ui/dev/homepage/homepage.png)
6 changes: 3 additions & 3 deletions docs/docs/zh/guide/project/project-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

## 项目首页

在项目管理页面点击项目名称链接,进入项目首页,如下图所示,项目首页包含该项目的任务状态统计、流程状态统计、工作流定义统计。这几个指标的说明如下
在项目管理页面点击项目名称链接,进入项目首页,如下图所示,项目首页包含该项目的任务实例状态统计、工作流实例状态统计、工作流定义统计。这几个指标的说明如下

- **任务状态统计**:在指定时间范围内,统计任务实例中状态为提交成功、正在运行、准备暂停、暂停、准备停止、停止、失败、成功、需要容错、kill、等待线程的个数
- **流程状态统计**:在指定时间范围内,统计工作流实例中状态为提交成功、正在运行、准备暂停、暂停、准备停止、停止、失败、成功、需要容错、kill、等待线程的个数
- **任务实例状态统计**:在指定时间范围内,统计任务实例中状态为提交成功、正在运行、准备暂停、暂停、准备停止、停止、失败、成功、需要容错、kill、等待线程的个数
- **工作流实例状态统计**:在指定时间范围内,统计工作流实例中状态为提交成功、正在运行、准备暂停、暂停、准备停止、停止、失败、成功、需要容错、kill、等待线程的个数
- **工作流定义统计**:统计用户创建的工作流定义及管理员授予该用户的工作流定义

![project-overview](../../../../img/new_ui/dev/project/project-overview.png)
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ private void installAlertPlugin() {
String name = entry.getKey();
AlertChannelFactory factory = entry.getValue();

log.info("Registering alert plugin: {} - {}", name, factory.getClass());
log.info("Registering alert plugin: {} - {}", name, factory.getClass().getSimpleName());

final AlertChannel alertChannel = factory.create();

log.info("Registered alert plugin: {} - {}", name, factory.getClass());
log.info("Registered alert plugin: {} - {}", name, factory.getClass().getSimpleName());

final List<PluginParams> params = new ArrayList<>(factory.params());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
import static org.apache.dolphinscheduler.api.enums.Status.TASK_INSTANCE_STATE_COUNT_ERROR;

import org.apache.dolphinscheduler.api.dto.CommandStateCount;
import org.apache.dolphinscheduler.api.dto.DefineUserDto;
import org.apache.dolphinscheduler.api.dto.TaskCountDto;
import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.DataAnalysisService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVo;
import org.apache.dolphinscheduler.api.vo.WorkflowDefinitionCountVo;
import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVo;
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.dao.entity.User;

Expand Down Expand Up @@ -59,17 +60,8 @@
public class DataAnalysisController extends BaseController {

@Autowired
DataAnalysisService dataAnalysisService;
private DataAnalysisService dataAnalysisService;

/**
* statistical task instance status data
*
* @param loginUser login user
* @param startDate count start date
* @param endDate count end date
* @param projectCode project code
* @return task instance count data
*/
@Operation(summary = "countTaskState", description = "COUNT_TASK_STATE_NOTES")
@Parameters({
@Parameter(name = "startDate", description = "START_DATE", schema = @Schema(implementation = String.class)),
Expand All @@ -79,25 +71,17 @@ public class DataAnalysisController extends BaseController {
@GetMapping(value = "/task-state-count")
@ResponseStatus(HttpStatus.OK)
@ApiException(TASK_INSTANCE_STATE_COUNT_ERROR)
public Result<TaskCountDto> countTaskState(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "projectCode", required = false, defaultValue = "0") long projectCode) {

TaskCountDto taskCountDto =
dataAnalysisService.countTaskStateByProject(loginUser, projectCode, startDate, endDate);
return Result.success(taskCountDto);
public Result<TaskInstanceCountVo> getTaskInstanceStateCount(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "projectCode", required = false) Long projectCode) {
if (projectCode == null) {
return Result.success(dataAnalysisService.getAllTaskInstanceStateCount(loginUser, startDate, endDate));
}
return Result.success(
dataAnalysisService.getTaskInstanceStateCountByProject(loginUser, projectCode, startDate, endDate));
}

/**
* statistical process instance status data
*
* @param loginUser login user
* @param startDate start date
* @param endDate end date
* @param projectCode project code
* @return process instance data
*/
@Operation(summary = "countProcessInstanceState", description = "COUNT_PROCESS_INSTANCE_NOTES")
@Parameters({
@Parameter(name = "startDate", description = "START_DATE", schema = @Schema(implementation = String.class)),
Expand All @@ -107,35 +91,30 @@ public Result<TaskCountDto> countTaskState(@Parameter(hidden = true) @RequestAtt
@GetMapping(value = "/process-state-count")
@ResponseStatus(HttpStatus.OK)
@ApiException(COUNT_PROCESS_INSTANCE_STATE_ERROR)
public Result<TaskCountDto> countProcessInstanceState(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "projectCode", required = false, defaultValue = "0") long projectCode) {

TaskCountDto taskCountDto =
dataAnalysisService.countProcessInstanceStateByProject(loginUser, projectCode, startDate, endDate);
return Result.success(taskCountDto);
public Result<WorkflowInstanceCountVo> getWorkflowInstanceStateCount(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "projectCode", required = false) Long projectCode) {
if (projectCode == null) {
return Result.success(dataAnalysisService.getAllWorkflowInstanceStateCount(loginUser, startDate, endDate));
}
return Result.success(
dataAnalysisService.getWorkflowInstanceStateCountByProject(loginUser, projectCode, startDate, endDate));
}

/**
* statistics the process definition quantities of certain person
*
* @param loginUser login user
* @param projectCode project code
* @return definition count in project code
*/
@Operation(summary = "countDefinitionByUser", description = "COUNT_PROCESS_DEFINITION_BY_USER_NOTES")
@Parameters({
@Parameter(name = "projectCode", description = "PROJECT_CODE", schema = @Schema(implementation = long.class, example = "100"))
})
@GetMapping(value = "/define-user-count")
@ResponseStatus(HttpStatus.OK)
@ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
public Result<DefineUserDto> countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "projectCode", required = false, defaultValue = "0") long projectCode) {

DefineUserDto defineUserDto = dataAnalysisService.countDefinitionByUser(loginUser, projectCode);
return Result.success(defineUserDto);
public Result<WorkflowDefinitionCountVo> countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "projectCode", required = false) Long projectCode) {
if (projectCode == null) {
return Result.success(dataAnalysisService.getAllWorkflowDefinitionCount(loginUser));
}
return Result.success(dataAnalysisService.getWorkflowDefinitionCountByProject(loginUser, projectCode));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.dolphinscheduler.api.controller.v2;

import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
Expand All @@ -34,10 +33,6 @@
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.dao.entity.User;

import org.apache.commons.lang3.StringUtils;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -62,20 +57,6 @@ public class StatisticsV2Controller extends BaseController {
@Autowired
private DataAnalysisService dataAnalysisService;

/**
* query all workflow count
* @param loginUser login user
* @return workflow count
*/
@Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
@GetMapping(value = "/workflows/count")
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
return returnDataList(result);
}

/**
* query all workflow states count
*
Expand Down Expand Up @@ -157,13 +138,8 @@ public Result<TaskCountDto> queryOneTaskStatesCounts(@Parameter(hidden = true) @
@ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
public Result<DefineUserDto> countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
String projectName = statisticsStateRequest.getProjectName();
Long projectCode = statisticsStateRequest.getProjectCode();
if (null == projectCode && !StringUtils.isBlank(projectName)) {
projectCode = dataAnalysisService.getProjectCodeByName(projectName);
}
DefineUserDto defineUserDto = dataAnalysisService.countDefinitionByUserV2(loginUser, projectCode, null, null);
return Result.success(defineUserDto);
// todo: directly use StatisticsStateRequest
throw new UnsupportedOperationException("not supported");
}

/**
Expand All @@ -179,7 +155,7 @@ public Result<DefineUserDto> countDefinitionByUser(@Parameter(hidden = true) @Re
@ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
public Result<DefineUserDto> countDefinitionByUserId(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable("userId") Integer userId) {
DefineUserDto defineUserDto = dataAnalysisService.countDefinitionByUserV2(loginUser, null, userId, null);
DefineUserDto defineUserDto = dataAnalysisService.countDefinitionByUserV2(loginUser, userId, null);
return Result.success(defineUserDto);
}

Expand All @@ -199,7 +175,7 @@ public Result<DefineUserDto> countDefinitionByUserState(@Parameter(hidden = true
@PathVariable("userId") Integer userId,
@PathVariable("releaseState") Integer releaseState) {
DefineUserDto defineUserDto =
dataAnalysisService.countDefinitionByUserV2(loginUser, null, userId, releaseState);
dataAnalysisService.countDefinitionByUserV2(loginUser, userId, releaseState);
return Result.success(defineUserDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.dolphinscheduler.api.dto;

import org.apache.dolphinscheduler.dao.entity.DefinitionGroupByUser;
import org.apache.dolphinscheduler.dao.model.WorkflowDefinitionCountDto;

import java.util.List;

Expand All @@ -28,11 +28,11 @@ public class DefineUserDto {

private int count;

private List<DefinitionGroupByUser> userList;
private List<WorkflowDefinitionCountDto> userList;

public DefineUserDto(List<DefinitionGroupByUser> defineGroupByUsers) {
public DefineUserDto(List<WorkflowDefinitionCountDto> defineGroupByUsers) {

for (DefinitionGroupByUser define : defineGroupByUsers) {
for (WorkflowDefinitionCountDto define : defineGroupByUsers) {
count += define.getCount();
}
this.userList = defineGroupByUsers;
Expand All @@ -46,11 +46,11 @@ public void setCount(int count) {
this.count = count;
}

public List<DefinitionGroupByUser> getUserList() {
public List<WorkflowDefinitionCountDto> getUserList() {
return userList;
}

public void setUserList(List<DefinitionGroupByUser> userList) {
public void setUserList(List<WorkflowDefinitionCountDto> userList) {
this.userList = userList;
}
}
Loading

0 comments on commit df656a7

Please sign in to comment.