Loading dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java +5 −9 Original line number Diff line number Diff line Loading @@ -106,12 +106,10 @@ public class DataAnalysisService extends BaseService{ List<ExecuteStatusCount> taskInstanceStateCounts = taskInstanceMapper.countTaskInstanceStateByUser(start, end, projectIds); if (taskInstanceStateCounts != null && !taskInstanceStateCounts.isEmpty()) { if (taskInstanceStateCounts != null) { TaskCountDto taskCountResult = new TaskCountDto(taskInstanceStateCounts); result.put(Constants.DATA_LIST, taskCountResult); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.TASK_INSTANCE_STATE_COUNT_ERROR); } return result; } Loading Loading @@ -153,12 +151,10 @@ public class DataAnalysisService extends BaseService{ processInstanceMapper.countInstanceStateByUser(start, end, projectIdArray); if (processInstanceStateCounts != null && !processInstanceStateCounts.isEmpty()) { if (processInstanceStateCounts != null) { TaskCountDto taskCountResult = new TaskCountDto(processInstanceStateCounts); result.put(Constants.DATA_LIST, taskCountResult); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.COUNT_PROCESS_INSTANCE_STATE_ERROR); } return result; } Loading dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java +12 −13 Original line number Diff line number Diff line Loading @@ -225,20 +225,14 @@ public class ExecutorService extends BaseService{ if (processInstance.getState() == ExecutionStatus.READY_STOP) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { processInstance.setCommandType(CommandType.STOP); processInstance.addHistoryCmd(CommandType.STOP); processService.updateProcessInstance(processInstance); result = updateProcessInstanceState(processInstanceId, ExecutionStatus.READY_STOP); result = updateProcessInstancePrepare(processInstance, CommandType.STOP, ExecutionStatus.READY_STOP); } break; case PAUSE: if (processInstance.getState() == ExecutionStatus.READY_PAUSE) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { processInstance.setCommandType(CommandType.PAUSE); processInstance.addHistoryCmd(CommandType.PAUSE); processService.updateProcessInstance(processInstance); result = updateProcessInstanceState(processInstanceId, ExecutionStatus.READY_PAUSE); result = updateProcessInstancePrepare(processInstance, CommandType.PAUSE, ExecutionStatus.READY_PAUSE); } break; default: Loading Loading @@ -308,22 +302,27 @@ public class ExecutorService extends BaseService{ } /** * update process instance state * prepare to update process instance command type and status * * @param processInstanceId process instance id * @param processInstance process instance * @param commandType command type * @param executionStatus execute status * @return update result */ private Map<String, Object> updateProcessInstanceState(Integer processInstanceId, ExecutionStatus executionStatus) { private Map<String, Object> updateProcessInstancePrepare(ProcessInstance processInstance, CommandType commandType, ExecutionStatus executionStatus) { Map<String, Object> result = new HashMap<>(5); int update = processService.updateProcessInstanceState(processInstanceId, executionStatus); processInstance.setCommandType(commandType); processInstance.addHistoryCmd(commandType); processInstance.setState(executionStatus); int update = processService.updateProcessInstance(processInstance); // determine whether the process is normal if (update > 0) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } Loading dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java +0 −7 Original line number Diff line number Diff line Loading @@ -114,9 +114,6 @@ public class DataAnalysisServiceTest { Map<String, Object> result = dataAnalysisService.countTaskStateByProject(user, 2, startDate, endDate); Assert.assertTrue(result.isEmpty()); // task instance state count error result = dataAnalysisService.countTaskStateByProject(user, 1, startDate, endDate); Assert.assertEquals(Status.TASK_INSTANCE_STATE_COUNT_ERROR,result.get(Constants.STATUS)); //SUCCESS Mockito.when(taskInstanceMapper.countTaskInstanceStateByUser(DateUtils.getScheduleDate(startDate), Loading @@ -137,10 +134,6 @@ public class DataAnalysisServiceTest { Map<String, Object> result = dataAnalysisService.countProcessInstanceStateByProject(user,2,startDate,endDate); Assert.assertTrue(result.isEmpty()); //COUNT_PROCESS_INSTANCE_STATE_ERROR result = dataAnalysisService.countProcessInstanceStateByProject(user,1,startDate,endDate); Assert.assertEquals(Status.COUNT_PROCESS_INSTANCE_STATE_ERROR,result.get(Constants.STATUS)); //SUCCESS Mockito.when(processInstanceMapper.countInstanceStateByUser(DateUtils.getScheduleDate(startDate), DateUtils.getScheduleDate(endDate), new Integer[]{1})).thenReturn(getTaskInstanceStateCounts()); Loading dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/thread/ThreadUtils.java +10 −0 Original line number Diff line number Diff line Loading @@ -223,4 +223,14 @@ public class ThreadUtils { } return id + " (" + name + ")"; } /** * sleep * @param millis millis */ public static void sleep(final long millis) { try { Thread.sleep(millis); } catch (final InterruptedException ignore) {} } } dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Command.java +1 −1 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ public class Command { /** * worker group */ @TableField(exist = false) @TableField("worker_group") private String workerGroup; public Command() { Loading Loading
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java +5 −9 Original line number Diff line number Diff line Loading @@ -106,12 +106,10 @@ public class DataAnalysisService extends BaseService{ List<ExecuteStatusCount> taskInstanceStateCounts = taskInstanceMapper.countTaskInstanceStateByUser(start, end, projectIds); if (taskInstanceStateCounts != null && !taskInstanceStateCounts.isEmpty()) { if (taskInstanceStateCounts != null) { TaskCountDto taskCountResult = new TaskCountDto(taskInstanceStateCounts); result.put(Constants.DATA_LIST, taskCountResult); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.TASK_INSTANCE_STATE_COUNT_ERROR); } return result; } Loading Loading @@ -153,12 +151,10 @@ public class DataAnalysisService extends BaseService{ processInstanceMapper.countInstanceStateByUser(start, end, projectIdArray); if (processInstanceStateCounts != null && !processInstanceStateCounts.isEmpty()) { if (processInstanceStateCounts != null) { TaskCountDto taskCountResult = new TaskCountDto(processInstanceStateCounts); result.put(Constants.DATA_LIST, taskCountResult); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.COUNT_PROCESS_INSTANCE_STATE_ERROR); } return result; } Loading
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java +12 −13 Original line number Diff line number Diff line Loading @@ -225,20 +225,14 @@ public class ExecutorService extends BaseService{ if (processInstance.getState() == ExecutionStatus.READY_STOP) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { processInstance.setCommandType(CommandType.STOP); processInstance.addHistoryCmd(CommandType.STOP); processService.updateProcessInstance(processInstance); result = updateProcessInstanceState(processInstanceId, ExecutionStatus.READY_STOP); result = updateProcessInstancePrepare(processInstance, CommandType.STOP, ExecutionStatus.READY_STOP); } break; case PAUSE: if (processInstance.getState() == ExecutionStatus.READY_PAUSE) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { processInstance.setCommandType(CommandType.PAUSE); processInstance.addHistoryCmd(CommandType.PAUSE); processService.updateProcessInstance(processInstance); result = updateProcessInstanceState(processInstanceId, ExecutionStatus.READY_PAUSE); result = updateProcessInstancePrepare(processInstance, CommandType.PAUSE, ExecutionStatus.READY_PAUSE); } break; default: Loading Loading @@ -308,22 +302,27 @@ public class ExecutorService extends BaseService{ } /** * update process instance state * prepare to update process instance command type and status * * @param processInstanceId process instance id * @param processInstance process instance * @param commandType command type * @param executionStatus execute status * @return update result */ private Map<String, Object> updateProcessInstanceState(Integer processInstanceId, ExecutionStatus executionStatus) { private Map<String, Object> updateProcessInstancePrepare(ProcessInstance processInstance, CommandType commandType, ExecutionStatus executionStatus) { Map<String, Object> result = new HashMap<>(5); int update = processService.updateProcessInstanceState(processInstanceId, executionStatus); processInstance.setCommandType(commandType); processInstance.addHistoryCmd(commandType); processInstance.setState(executionStatus); int update = processService.updateProcessInstance(processInstance); // determine whether the process is normal if (update > 0) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } Loading
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java +0 −7 Original line number Diff line number Diff line Loading @@ -114,9 +114,6 @@ public class DataAnalysisServiceTest { Map<String, Object> result = dataAnalysisService.countTaskStateByProject(user, 2, startDate, endDate); Assert.assertTrue(result.isEmpty()); // task instance state count error result = dataAnalysisService.countTaskStateByProject(user, 1, startDate, endDate); Assert.assertEquals(Status.TASK_INSTANCE_STATE_COUNT_ERROR,result.get(Constants.STATUS)); //SUCCESS Mockito.when(taskInstanceMapper.countTaskInstanceStateByUser(DateUtils.getScheduleDate(startDate), Loading @@ -137,10 +134,6 @@ public class DataAnalysisServiceTest { Map<String, Object> result = dataAnalysisService.countProcessInstanceStateByProject(user,2,startDate,endDate); Assert.assertTrue(result.isEmpty()); //COUNT_PROCESS_INSTANCE_STATE_ERROR result = dataAnalysisService.countProcessInstanceStateByProject(user,1,startDate,endDate); Assert.assertEquals(Status.COUNT_PROCESS_INSTANCE_STATE_ERROR,result.get(Constants.STATUS)); //SUCCESS Mockito.when(processInstanceMapper.countInstanceStateByUser(DateUtils.getScheduleDate(startDate), DateUtils.getScheduleDate(endDate), new Integer[]{1})).thenReturn(getTaskInstanceStateCounts()); Loading
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/thread/ThreadUtils.java +10 −0 Original line number Diff line number Diff line Loading @@ -223,4 +223,14 @@ public class ThreadUtils { } return id + " (" + name + ")"; } /** * sleep * @param millis millis */ public static void sleep(final long millis) { try { Thread.sleep(millis); } catch (final InterruptedException ignore) {} } }
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Command.java +1 −1 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ public class Command { /** * worker group */ @TableField(exist = false) @TableField("worker_group") private String workerGroup; public Command() { Loading