status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
*/ Command command = new Command(); Map<String, String> cmdParam = new HashMap<>(); if (commandType == null) { command.setCommandType(CommandType.START_PROCESS); } else { command.setCommandType(commandType); } command.setProcessDefinitionCode(processDefineCode); if (nodeDep != null) { command.setTaskDependType(nodeDep); } if (failureStrategy != null) { command.setFailureStrategy(failureStrategy); } if (!StringUtils.isEmpty(startNodeList)) { cmdParam.put(CMD_PARAM_START_NODES, startNodeList); } if (warningType != null) { command.setWarningType(warningType); } if (startParams != null && startParams.size() > 0) { cmdParam.put(CMD_PARAM_START_PARAMS, JSONUtils.toJsonString(startParams)); } command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setExecutorId(executorId); command.setWarningGroupId(warningGroupId); command.setProcessInstancePriority(processInstancePriority); command.setWorkerGroup(workerGroup); command.setEnvironmentCode(environmentCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
command.setDryRun(dryRun); command.setTestFlag(testFlag); ProcessDefinition processDefinition = processService.findProcessDefinitionByCode(processDefineCode); if (processDefinition != null) { command.setProcessDefinitionVersion(processDefinition.getVersion()); } command.setProcessInstanceId(0); // det if (commandType == CommandType.COMPLEMENT_DATA) { if (schedule == null || StringUtils.isEmpty(schedule)) { logger.error("Create {} type command error because parameter schedule is invalid.", command.getCommandType().getDescp()); return 0; } if (!isValidateScheduleTime(schedule)) { return 0; } try { logger.info("Start to create {} command, processDefinitionCode:{}.", command.getCommandType().getDescp(), processDefineCode); return createComplementCommandList(schedule, runMode, command, expectedParallelismNumber, complementDependentMode); } catch (CronParseException cronParseException) { // We // cro return 0; } } else { command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
return commandService.createCommand(command); } } /** * create complement command * close left and close right * * @param scheduleTimeParam * @param runMode * @return */ protected int createComplementCommandList(String scheduleTimeParam, RunMode runMode, Command command, Integer expectedParallelismNumber, ComplementDependentMode complementDependentMode) throws CronParseException { int createCount = 0; String startDate = null; String endDate = null; String dateList = null; int dependentProcessDefinitionCreateCount = 0; runMode = (runMode == null) ? RunMode.RUN_MODE_SERIAL : runMode; Map<String, String> cmdParam = JSONUtils.toMap(command.getCommandParam()); Map<String, String> scheduleParam = JSONUtils.toMap(scheduleTimeParam); if (scheduleParam.containsKey(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { dateList = scheduleParam.get(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST); dateList = removeDuplicates(dateList); } if (scheduleParam.containsKey(CMD_PARAM_COMPLEMENT_DATA_START_DATE) && scheduleParam.containsKey( CMD_PARAM_COMPLEMENT_DATA_END_DATE)) { startDate = scheduleParam.get(CMD_PARAM_COMPLEMENT_DATA_START_DATE); endDate = scheduleParam.get(CMD_PARAM_COMPLEMENT_DATA_END_DATE);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} switch (runMode) { case RUN_MODE_SERIAL: { logger.info("RunMode of {} command is serial run, processDefinitionCode:{}.", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); if (StringUtils.isNotEmpty(dateList)) { cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST, dateList); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command); createCount = commandService.createCommand(command); if (createCount > 0) { logger.info("Create {} command complete, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } else { logger.error("Create {} command error, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } } if (startDate != null && endDate != null) { cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_START_DATE, startDate); cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_END_DATE, endDate); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command); createCount = commandService.createCommand(command); if (createCount > 0) { logger.info("Create {} command complete, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } else { logger.error("Create {} command error, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} // dep List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionCode( command.getProcessDefinitionCode()); if (schedules.isEmpty() || complementDependentMode == ComplementDependentMode.OFF_MODE) { logger.info( "Complement dependent mode is off mode or Scheduler is empty, so skip create complement dependent command, processDefinitionCode:{}.", command.getProcessDefinitionCode()); } else { logger.info( "Complement dependent mode is all dependent and Scheduler is not empty, need create complement dependent command, processDefinitionCode:{}.", command.getProcessDefinitionCode()); dependentProcessDefinitionCreateCount += createComplementDependentCommand(schedules, command); } } break; } case RUN_MODE_PARALLEL: { logger.info("RunMode of {} command is parallel run, processDefinitionCode:{}.", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); if (startDate != null && endDate != null) { List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionCode( command.getProcessDefinitionCode()); List<ZonedDateTime> listDate = CronUtils.getSelfFireDateList( DateUtils.stringToZoneDateTime(startDate), DateUtils.stringToZoneDateTime(endDate), schedules); int listDateSize = listDate.size(); createCount = listDate.size(); if (!CollectionUtils.isEmpty(listDate)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (expectedParallelismNumber != null && expectedParallelismNumber != 0) { createCount = Math.min(createCount, expectedParallelismNumber); } logger.info("Complement command run in parallel mode, current expectedParallelismNumber:{}.", createCount); // Dis // The int itemsPerCommand = (listDateSize / createCount); int remainingItems = (listDateSize % createCount); int startDateIndex = 0; int endDateIndex = 0; for (int i = 1; i <= createCount; i++) { int extra = (i <= remainingItems) ? 1 : 0; int singleCommandItems = (itemsPerCommand + extra); if (i == 1) { endDateIndex += singleCommandItems - 1; } else { startDateIndex = endDateIndex + 1; endDateIndex += singleCommandItems; } cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(listDate.get(startDateIndex))); cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(listDate.get(endDateIndex))); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command); if (commandService.createCommand(command) > 0) { logger.info("Create {} command complete, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
logger.error("Create {} command error, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } if (schedules.isEmpty() || complementDependentMode == ComplementDependentMode.OFF_MODE) { logger.info( "Complement dependent mode is off mode or Scheduler is empty, so skip create complement dependent command, processDefinitionCode:{}.", command.getProcessDefinitionCode()); } else { logger.info( "Complement dependent mode is all dependent and Scheduler is not empty, need create complement dependent command, processDefinitionCode:{}.", command.getProcessDefinitionCode()); dependentProcessDefinitionCreateCount += createComplementDependentCommand(schedules, command); } } } } if (StringUtils.isNotEmpty(dateList)) { List<String> listDate = Arrays.asList(dateList.split(COMMA)); createCount = listDate.size(); if (!CollectionUtils.isEmpty(listDate)) { if (expectedParallelismNumber != null && expectedParallelismNumber != 0) { createCount = Math.min(createCount, expectedParallelismNumber); } logger.info("Complement command run in parallel mode, current expectedParallelismNumber:{}.", createCount); for (List<String> stringDate : Lists.partition(listDate, createCount)) { cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST, String.join(COMMA, stringDate)); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (commandService.createCommand(command) > 0) { logger.info("Create {} command complete, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } else { logger.error("Create {} command error, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } } } } break; } default: break; } logger.info("Create complement command count:{}, Create dependent complement command count:{}", createCount, dependentProcessDefinitionCreateCount); return createCount; } /** * create complement dependent command */ public int createComplementDependentCommand(List<Schedule> schedules, Command command) { int dependentProcessDefinitionCreateCount = 0; Command dependentCommand; try { dependentCommand = (Command) BeanUtils.cloneBean(command); } catch (Exception e) { logger.error("Copy dependent command error.", e); return dependentProcessDefinitionCreateCount;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} List<DependentProcessDefinition> dependentProcessDefinitionList = getComplementDependentDefinitionList(dependentCommand.getProcessDefinitionCode(), CronUtils.getMaxCycle(schedules.get(0).getCrontab()), dependentCommand.getWorkerGroup()); dependentCommand.setTaskDependType(TaskDependType.TASK_POST); for (DependentProcessDefinition dependentProcessDefinition : dependentProcessDefinitionList) { // If // and dependentCommand.setId(null); dependentCommand.setProcessDefinitionCode(dependentProcessDefinition.getProcessDefinitionCode()); dependentCommand.setProcessDefinitionVersion(dependentProcessDefinition.getProcessDefinitionVersion()); dependentCommand.setWorkerGroup(dependentProcessDefinition.getWorkerGroup()); Map<String, String> cmdParam = JSONUtils.toMap(dependentCommand.getCommandParam()); cmdParam.put(CMD_PARAM_START_NODES, String.valueOf(dependentProcessDefinition.getTaskDefinitionCode())); dependentCommand.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating complement dependent command, commandInfo:{}.", command); dependentProcessDefinitionCreateCount += commandService.createCommand(dependentCommand); } return dependentProcessDefinitionCreateCount; } /** * get complement dep list */ private List<DependentProcessDefinition> getComplementDependentDefinitionList(long processDefinitionCode, CycleEnum processDefinitionCycle, String workerGroup) { List<DependentProcessDefinition> dependentProcessDefinitionList = processService.queryDependentProcessDefinitionByProcessDefinitionCode(processDefinitionCode); return checkDependentProcessDefinitionValid(dependentProcessDefinitionList, processDefinitionCycle, workerGroup, processDefinitionCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} /** * Check whether the dependency cycle of the dependent node is consistent with the schedule cycle of * the dep and if there is no worker group in the schedule, use the complement selection's * worker group */ private List<DependentProcessDefinition> checkDependentProcessDefinitionValid( List<DependentProcessDefinition> dependentProcessDefinitionList, CycleEnum processDefinitionCycle, String workerGroup, long upstreamProcessDefinitionCode) { List<DependentProcessDefinition> validDependentProcessDefinitionList = new ArrayList<>(); List<Long> processDefinitionCodeList = dependentProcessDefinitionList.stream().map(DependentProcessDefinition::getProcessDefinitionCode) .collect(Collectors.toList()); Map<Long, String> processDefinitionWorkerGroupMap = processService.queryWorkerGroupByProcessDefinitionCodes(processDefinitionCodeList); for (DependentProcessDefinition dependentProcessDefinition : dependentProcessDefinitionList) { if (dependentProcessDefinition.getDependentCycle(upstreamProcessDefinitionCode) == processDefinitionCycle) { if (processDefinitionWorkerGroupMap .get(dependentProcessDefinition.getProcessDefinitionCode()) == null) { dependentProcessDefinition.setWorkerGroup(workerGroup); } validDependentProcessDefinitionList.add(dependentProcessDefinition); } } return validDependentProcessDefinitionList; } /** * @param schedule
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @return check error return 0, otherwise 1 */ private boolean isValidateScheduleTime(String schedule) { Map<String, String> scheduleResult = JSONUtils.toMap(schedule); if (scheduleResult == null) { return false; } if (scheduleResult.containsKey(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { if (scheduleResult.get(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST) == null) { return false; } } if (scheduleResult.containsKey(CMD_PARAM_COMPLEMENT_DATA_START_DATE)) { String startDate = scheduleResult.get(CMD_PARAM_COMPLEMENT_DATA_START_DATE); String endDate = scheduleResult.get(CMD_PARAM_COMPLEMENT_DATA_END_DATE); if (startDate == null || endDate == null) { return false; } try { ZonedDateTime start = DateUtils.stringToZoneDateTime(startDate); ZonedDateTime end = DateUtils.stringToZoneDateTime(endDate); if (start == null || end == null) { return false; } if (start.isAfter(end)) { logger.error( "Complement data parameter error, start time should be before end time, startDate:{}, endDate:{}.", start, end); return false; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} catch (Exception ex) { logger.warn("Parse schedule time error, startDate:{}, endDate:{}.", startDate, endDate); return false; } } return true; } /** * @param scheduleTimeList * @return remove duplicate date list */ private String removeDuplicates(String scheduleTimeList) { if (StringUtils.isNotEmpty(scheduleTimeList)) { Set<String> dateSet = Arrays.stream(scheduleTimeList.split(COMMA)).map(String::trim).collect(Collectors.toSet()); return String.join(COMMA, dateSet); } return null; } /** * query executing data of processInstance by master * @param processInstanceId * @return */ @Override public WorkflowExecuteDto queryExecutingWorkflowByProcessInstanceId(Integer processInstanceId) { ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId).orElse(null); if (processInstance == null) { logger.error("Process instance does not exist, processInstanceId:{}.", processInstanceId); return null;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} Host host = new Host(processInstance.getHost()); WorkflowExecutingDataRequestCommand requestCommand = new WorkflowExecutingDataRequestCommand(); requestCommand.setProcessInstanceId(processInstanceId); org.apache.dolphinscheduler.remote.command.Command command = stateEventCallbackService.sendSync(host, requestCommand.convert2Command()); if (command == null) { logger.error("Query executing process instance from master error, processInstanceId:{}.", processInstanceId); return null; } WorkflowExecutingDataResponseCommand responseCommand = JSONUtils.parseObject(command.getBody(), WorkflowExecutingDataResponseCommand.class); return responseCommand.getWorkflowExecuteDto(); } @Override public Map<String, Object> execStreamTaskInstance(User loginUser, long projectCode, long taskDefinitionCode, int taskDefinitionVersion, int warningGroupId, String workerGroup, Long environmentCode, Map<String, String> startParams, int dryRun) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_START); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkMasterExists(result)) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} // tod List<Server> masterServerList = monitorService.getServerListFromRegistry(true); Host host = new Host(masterServerList.get(0).getHost(), masterServerList.get(0).getPort()); TaskExecuteStartCommand taskExecuteStartCommand = new TaskExecuteStartCommand(); taskExecuteStartCommand.setExecutorId(loginUser.getId()); taskExecuteStartCommand.setExecutorName(loginUser.getUserName()); taskExecuteStartCommand.setProjectCode(projectCode); taskExecuteStartCommand.setTaskDefinitionCode(taskDefinitionCode); taskExecuteStartCommand.setTaskDefinitionVersion(taskDefinitionVersion); taskExecuteStartCommand.setWorkerGroup(workerGroup); taskExecuteStartCommand.setWarningGroupId(warningGroupId); taskExecuteStartCommand.setEnvironmentCode(environmentCode); taskExecuteStartCommand.setStartParams(startParams); taskExecuteStartCommand.setDryRun(dryRun); org.apache.dolphinscheduler.remote.command.Command response = stateEventCallbackService.sendSync(host, taskExecuteStartCommand.convert2Command()); if (response != null) { logger.info("Send task execute start command complete, response is {}.", response); putMsg(result, Status.SUCCESS); } else { logger.error( "Start to execute stream task instance error, projectCode:{}, taskDefinitionCode:{}, taskVersion:{}.", projectCode, taskDefinitionCode, taskDefinitionVersion); putMsg(result, Status.START_TASK_INSTANCE_ERROR); } return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
/* * 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.service.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKER_GROUP_CREATE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKER_GROUP_DELETE; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.WorkerGroupService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.NodeType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.User;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
import org.apache.dolphinscheduler.dao.entity.WorkerGroup; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper; import org.apache.dolphinscheduler.service.registry.RegistryClient; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.facebook.presto.jdbc.internal.guava.base.Strings; /** * worker group service impl */ @Service public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGroupService { private static final Logger logger = LoggerFactory.getLogger(WorkerGroupServiceImpl.class); @Autowired private WorkerGroupMapper workerGroupMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
@Autowired private ProcessInstanceMapper processInstanceMapper; @Autowired private RegistryClient registryClient; /** * create or update a worker group * * @param loginUser login user * @param id worker group id * @param name worker group name * @param addrList addr list * @return create or update result code */ @Override @Transactional public Map<String, Object> saveWorkerGroup(User loginUser, int id, String name, String addrList, String description, String otherParamsJson) { Map<String, Object> result = new HashMap<>(); if (!canOperatorPermissions(loginUser, null, AuthorizationType.WORKER_GROUP, WORKER_GROUP_CREATE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (StringUtils.isEmpty(name)) { logger.warn("Parameter name can ot be null."); putMsg(result, Status.NAME_NULL); return result; } Date now = new Date(); WorkerGroup workerGroup; if (id != 0) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
workerGroup = workerGroupMapper.selectById(id); if (workerGroup == null) { workerGroup = new WorkerGroup(); workerGroup.setCreateTime(now); } } else { workerGroup = new WorkerGroup(); workerGroup.setCreateTime(now); } workerGroup.setName(name); workerGroup.setAddrList(addrList); workerGroup.setUpdateTime(now); workerGroup.setDescription(description); if (checkWorkerGroupNameExists(workerGroup)) { logger.warn("Worker group with the same name already exists, name:{}.", workerGroup.getName()); putMsg(result, Status.NAME_EXIST, workerGroup.getName()); return result; } String invalidAddr = checkWorkerGroupAddrList(workerGroup); if (invalidAddr != null) { logger.warn("Worker group address is invalid, invalidAddr:{}.", invalidAddr); putMsg(result, Status.WORKER_ADDRESS_INVALID, invalidAddr); return result; } handleDefaultWorkGroup(workerGroupMapper, workerGroup, loginUser, otherParamsJson); logger.info("Worker group save complete, workerGroupName:{}.", workerGroup.getName()); putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
protected void handleDefaultWorkGroup(WorkerGroupMapper workerGroupMapper, WorkerGroup workerGroup, User loginUser, String otherParamsJson) { if (workerGroup.getId() != null) { workerGroupMapper.updateById(workerGroup); } else { workerGroupMapper.insert(workerGroup); permissionPostHandle(AuthorizationType.WORKER_GROUP, loginUser.getId(), Collections.singletonList(workerGroup.getId()), logger); } } /** * check worker group name exists * * @param workerGroup worker group * @return boolean */ private boolean checkWorkerGroupNameExists(WorkerGroup workerGroup) { List<WorkerGroup> workerGroupList = workerGroupMapper.queryWorkerGroupByName(workerGroup.getName()); if (CollectionUtils.isNotEmpty(workerGroupList)) { if (workerGroup.getId() == null) { return true; } for (WorkerGroup group : workerGroupList) { if (Objects.equals(group.getId(), workerGroup.getId())) { return true; } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
String workerGroupPath = Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS + Constants.SINGLE_SLASH + workerGroup.getName(); return registryClient.exists(workerGroupPath); } /** * check worker group addr list * * @param workerGroup worker group * @return boolean */ private String checkWorkerGroupAddrList(WorkerGroup workerGroup) { if (Strings.isNullOrEmpty(workerGroup.getAddrList())) { return null; } Map<String, String> serverMaps = registryClient.getServerMaps(NodeType.WORKER); for (String addr : workerGroup.getAddrList().split(Constants.COMMA)) { if (!serverMaps.containsKey(addr)) { return addr; } } return null; } /** * query worker group paging * * @param loginUser login user * @param pageNo page number * @param searchVal search value * @param pageSize page size
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
* @return worker group list page */ @Override public Result queryAllGroupPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal) { int fromIndex = (pageNo - 1) * pageSize; int toIndex = (pageNo - 1) * pageSize + pageSize; Result result = new Result(); List<WorkerGroup> workerGroups; if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { workerGroups = getWorkerGroups(null); } else { Set<Integer> ids = resourcePermissionCheckService .userOwnedResourceIdsAcquisition(AuthorizationType.WORKER_GROUP, loginUser.getId(), logger); workerGroups = getWorkerGroups(ids.isEmpty() ? Collections.emptyList() : new ArrayList<>(ids)); } List<WorkerGroup> resultDataList = new ArrayList<>(); int total = 0; if (CollectionUtils.isNotEmpty(workerGroups)) { List<WorkerGroup> searchValDataList = new ArrayList<>(); if (!StringUtils.isEmpty(searchVal)) { for (WorkerGroup workerGroup : workerGroups) { if (workerGroup.getName().contains(searchVal)) { searchValDataList.add(workerGroup); } } } else { searchValDataList = workerGroups; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
total = searchValDataList.size(); if (fromIndex < searchValDataList.size()) { if (toIndex > searchValDataList.size()) { toIndex = searchValDataList.size(); } resultDataList = searchValDataList.subList(fromIndex, toIndex); } } PageInfo<WorkerGroup> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal(total); pageInfo.setTotalList(resultDataList); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * query all worker group * * @param loginUser * @return all worker group list */ @Override public Map<String, Object> queryAllGroup(User loginUser) { Map<String, Object> result = new HashMap<>(); List<WorkerGroup> workerGroups; if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { workerGroups = getWorkerGroups(null); } else { Set<Integer> ids = resourcePermissionCheckService .userOwnedResourceIdsAcquisition(AuthorizationType.WORKER_GROUP, loginUser.getId(), logger);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
workerGroups = getWorkerGroups(ids.isEmpty() ? Collections.emptyList() : new ArrayList<>(ids)); } List<String> availableWorkerGroupList = workerGroups.stream() .map(WorkerGroup::getName) .collect(Collectors.toList()); result.put(Constants.DATA_LIST, availableWorkerGroupList); putMsg(result, Status.SUCCESS); return result; } /** * get worker groups * * @return WorkerGroup list */ private List<WorkerGroup> getWorkerGroups(List<Integer> ids) { List<WorkerGroup> workerGroups; if (ids != null) { workerGroups = ids.isEmpty() ? new ArrayList<>() : workerGroupMapper.selectBatchIds(ids); } else { workerGroups = workerGroupMapper.queryAllWorkerGroup(); } Optional<Boolean> containDefaultWorkerGroups = workerGroups.stream() .map(workerGroup -> Constants.DEFAULT_WORKER_GROUP.equals(workerGroup.getName())).findAny(); if (!containDefaultWorkerGroups.isPresent() || !containDefaultWorkerGroups.get()) { Set<String> activeWorkerNodes = registryClient.getServerNodeSet(NodeType.WORKER); WorkerGroup defaultWorkerGroup = new WorkerGroup(); defaultWorkerGroup.setName(Constants.DEFAULT_WORKER_GROUP); defaultWorkerGroup.setAddrList(String.join(Constants.COMMA, activeWorkerNodes));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
defaultWorkerGroup.setCreateTime(new Date()); defaultWorkerGroup.setUpdateTime(new Date()); defaultWorkerGroup.setSystemDefault(true); workerGroups.add(defaultWorkerGroup); } return workerGroups; } /** * delete worker group by id * * @param id worker group id * @return delete result code */ @Override @Transactional public Map<String, Object> deleteWorkerGroupById(User loginUser, Integer id) { Map<String, Object> result = new HashMap<>(); if (!canOperatorPermissions(loginUser, null, AuthorizationType.WORKER_GROUP, WORKER_GROUP_DELETE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } WorkerGroup workerGroup = workerGroupMapper.selectById(id); if (workerGroup == null) { logger.error("Worker group does not exist, workerGroupId:{}.", id); putMsg(result, Status.DELETE_WORKER_GROUP_NOT_EXIST); return result; } List<ProcessInstance> processInstances = processInstanceMapper .queryByWorkerGroupNameAndStatus(workerGroup.getName(), org.apache.dolphinscheduler.service.utils.Constants.NOT_TERMINATED_STATES);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
if (CollectionUtils.isNotEmpty(processInstances)) { List<Integer> processInstanceIds = processInstances.stream().map(ProcessInstance::getId).collect(Collectors.toList()); logger.warn( "Delete worker group failed because there are {} processInstances are using it, processInstanceIds:{}.", processInstances.size(), processInstanceIds); putMsg(result, Status.DELETE_WORKER_GROUP_BY_ID_FAIL, processInstances.size()); return result; } workerGroupMapper.deleteById(id); processInstanceMapper.updateProcessInstanceByWorkerGroupName(workerGroup.getName(), ""); logger.info("Delete worker group complete, workerGroupName:{}.", workerGroup.getName()); putMsg(result, Status.SUCCESS); return result; } /** * query all worker address list * * @return all worker address list */ @Override public Map<String, Object> getWorkerAddressList() { Map<String, Object> result = new HashMap<>(); Set<String> serverNodeList = registryClient.getServerNodeSet(NodeType.WORKER); result.put(Constants.DATA_LIST, serverNodeList); putMsg(result, Status.SUCCESS); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
/* * 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.service; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.RERUN; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_START; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
import static org.mockito.Mockito.verify; import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.apache.dolphinscheduler.api.service.impl.BaseServiceImpl; import org.apache.dolphinscheduler.api.service.impl.ExecutorServiceImpl; import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.ComplementDependentMode; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.RunMode; import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.service.command.CommandService; import org.apache.dolphinscheduler.service.process.ProcessService; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Optional; import org.assertj.core.util.Lists; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * executor service 2 test */ @ExtendWith(MockitoExtension.class)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
@MockitoSettings(strictness = Strictness.LENIENT) public class ExecutorServiceTest { private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceTest.class); private static final Logger baseServiceLogger = LoggerFactory.getLogger(BaseServiceImpl.class); @Mock private ResourcePermissionCheckService resourcePermissionCheckService; @InjectMocks private ExecutorServiceImpl executorService; @Mock
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
private ProcessService processService; @Mock private CommandService commandService; @Mock private ProcessDefinitionMapper processDefinitionMapper; @Mock private ProcessTaskRelationMapper processTaskRelationMapper; @Mock private TaskDefinitionMapper taskDefinitionMapper; @Mock private ProjectMapper projectMapper; @Mock private ProjectServiceImpl projectService; @Mock private MonitorService monitorService; @Mock private TaskGroupQueueMapper taskGroupQueueMapper; @Mock private ProcessInstanceMapper processInstanceMapper; private int processDefinitionId = 1; private long processDefinitionCode = 1L; private int processInstanceId = 1; private int tenantId = 1; private int userId = 1; private int taskQueueId = 1; private ProcessDefinition processDefinition = new ProcessDefinition(); private ProcessInstance processInstance = new ProcessInstance(); private TaskGroupQueue taskGroupQueue = new TaskGroupQueue(); private User loginUser = new User(); private long projectCode = 1L;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
private String projectName = "projectName"; private Project project = new Project(); private String cronTime; @BeforeEach public void init() { loginUser.setId(userId); processDefinition.setId(processDefinitionId); processDefinition.setReleaseState(ReleaseState.ONLINE); processDefinition.setTenantId(tenantId); processDefinition.setUserId(userId); processDefinition.setVersion(1); processDefinition.setCode(1L); processDefinition.setProjectCode(projectCode); processInstance.setId(processInstanceId); processInstance.setState(WorkflowExecutionStatus.FAILURE); processInstance.setExecutorId(userId); processInstance.setTenantId(tenantId); processInstance.setProcessDefinitionVersion(1); processInstance.setProcessDefinitionCode(1L); project.setCode(projectCode); project.setName(projectName); taskGroupQueue.setId(taskQueueId); taskGroupQueue.setStatus(TaskGroupQueueStatus.WAIT_QUEUE); taskGroupQueue.setProcessId(processInstanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
cronTime = "2020-01-01 00:00:00,2020-01-31 23:00:00"; Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_START)) .thenReturn(checkProjectAndAuth()); Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); Mockito.when(processService.getTenantForProcess(tenantId, userId)).thenReturn(new Tenant()); doReturn(1).when(commandService).createCommand(argThat(c -> c.getId() == null)); doReturn(0).when(commandService).createCommand(argThat(c -> c.getId() != null)); Mockito.when(monitorService.getServerListFromRegistry(true)).thenReturn(getMasterServersList()); Mockito.when(processService.findProcessInstanceDetailById(processInstanceId)) .thenReturn(Optional.ofNullable(processInstance)); Mockito.when(processService.findProcessDefinition(1L, 1)).thenReturn(processDefinition); Mockito.when(taskGroupQueueMapper.selectById(1)).thenReturn(taskGroupQueue); Mockito.when(processInstanceMapper.selectById(1)).thenReturn(processInstance); } @Test public void testForceStartTaskInstance() { Map<String, Object> result = executorService.forceStartTaskInstance(loginUser, taskQueueId); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } /** * not complement */ @Test public void testNoComplement() { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) .thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, processDefinitionCode,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
"{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", CommandType.START_PROCESS, null, null, null, null, null, RunMode.RUN_MODE_SERIAL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 10, null, 0, Constants.DRY_RUN_FLAG_NO, Constants.TEST_FLAG_NO, ComplementDependentMode.OFF_MODE); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(commandService, times(1)).createCommand(any(Command.class)); } /** * not complement */ @Test public void testComplementWithStartNodeList() { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) .thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, processDefinitionCode, "{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", CommandType.START_PROCESS, null, "n1,n2", null, null, null, RunMode.RUN_MODE_SERIAL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, Constants.TEST_FLAG_NO, ComplementDependentMode.OFF_MODE); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(commandService, times(1)).createCommand(any(Command.class));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
} @Test public void testComplementWithDependentMode() { Schedule schedule = new Schedule(); schedule.setStartTime(new Date()); schedule.setEndTime(new Date()); schedule.setCrontab("0 0 7 * * ? *"); schedule.setFailureStrategy(FailureStrategy.CONTINUE); schedule.setReleaseState(ReleaseState.OFFLINE); schedule.setWarningType(WarningType.NONE); schedule.setCreateTime(new Date()); schedule.setUpdateTime(new Date()); List<Schedule> schedules = Lists.newArrayList(schedule); Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode( processDefinitionCode)) .thenReturn(schedules); DependentProcessDefinition dependentProcessDefinition = new DependentProcessDefinition(); dependentProcessDefinition.setProcessDefinitionCode(2); dependentProcessDefinition.setProcessDefinitionVersion(1); dependentProcessDefinition.setTaskDefinitionCode(1); dependentProcessDefinition.setWorkerGroup(Constants.DEFAULT_WORKER_GROUP); dependentProcessDefinition.setTaskParams( "{\"localParams\":[],\"resourceList\":[],\"dependence\":{\"relation\":\"AND\",\"dependTaskList\":[{\"relation\":\"AND\",\"dependItemList\":[{\"depTaskCode\":2,\"status\":\"SUCCESS\"}]}]},\"conditionResult\":{\"successNode\":[1],\"failedNode\":[1]}}"); Mockito.when(processService.queryDependentProcessDefinitionByProcessDefinitionCode(processDefinitionCode)) .thenReturn(Lists.newArrayList(dependentProcessDefinition)); Map<Long, String> processDefinitionWorkerGroupMap = new HashMap<>(); processDefinitionWorkerGroupMap.put(1L, Constants.DEFAULT_WORKER_GROUP); Mockito.when(processService.queryWorkerGroupByProcessDefinitionCodes(Lists.newArrayList(1L))) .thenReturn(processDefinitionWorkerGroupMap); Command command = new Command();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
command.setId(1); command.setCommandType(CommandType.COMPLEMENT_DATA); command.setCommandParam( "{\"StartNodeList\":\"1\",\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}"); command.setWorkerGroup(Constants.DEFAULT_WORKER_GROUP); command.setProcessDefinitionCode(processDefinitionCode); command.setExecutorId(1); int count = executorService.createComplementDependentCommand(schedules, command); Assertions.assertEquals(1, count); } /** * date error */ @Test public void testDateError() { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) .thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, processDefinitionCode, "{\"complementStartDate\":\"2022-01-07 12:12:12\",\"complementEndDate\":\"2022-01-06 12:12:12\"}", CommandType.COMPLEMENT_DATA, null, null, null, null, null, RunMode.RUN_MODE_SERIAL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, Constants.TEST_FLAG_NO, ComplementDependentMode.OFF_MODE); Assertions.assertEquals(Status.START_PROCESS_INSTANCE_ERROR, result.get(Constants.STATUS)); verify(commandService, times(0)).createCommand(any(Command.class)); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
/** * serial */ @Test public void testSerial() { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) .thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, processDefinitionCode, "{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", CommandType.COMPLEMENT_DATA, null, null, null, null, null, RunMode.RUN_MODE_SERIAL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, Constants.TEST_FLAG_NO, ComplementDependentMode.OFF_MODE); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(commandService, times(1)).createCommand(any(Command.class)); } /** * without schedule */ @Test public void testParallelWithOutSchedule() { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) .thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, processDefinitionCode, "{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}",
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
CommandType.COMPLEMENT_DATA, null, null, null, null, null, RunMode.RUN_MODE_PARALLEL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, Constants.TEST_FLAG_NO, ComplementDependentMode.OFF_MODE); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(commandService, times(31)).createCommand(any(Command.class)); } /** * with schedule */ @Test public void testParallelWithSchedule() { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) .thenReturn(oneSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, processDefinitionCode, "{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", CommandType.COMPLEMENT_DATA, null, null, null, null, null, RunMode.RUN_MODE_PARALLEL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 15, Constants.DRY_RUN_FLAG_NO, Constants.TEST_FLAG_NO, ComplementDependentMode.OFF_MODE); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(commandService, times(15)).createCommand(any(Command.class)); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
@Test public void testNoMasterServers() { Mockito.when(monitorService.getServerListFromRegistry(true)).thenReturn(new ArrayList<>()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, processDefinitionCode, "{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", CommandType.COMPLEMENT_DATA, null, null, null, null, null, RunMode.RUN_MODE_PARALLEL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, Constants.TEST_FLAG_NO, ComplementDependentMode.OFF_MODE); Assertions.assertEquals(result.get(Constants.STATUS), Status.MASTER_NOT_EXISTS); } @Test public void testExecuteRepeatRunning() { Mockito.when(commandService.verifyIsNeedCreateCommand(any(Command.class))).thenReturn(true); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode, RERUN)) .thenReturn(checkProjectAndAuth()); Map<String, Object> result = executorService.execute(loginUser, projectCode, processInstanceId, ExecuteType.REPEAT_RUNNING); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } @Test public void testOfTestRun() { Mockito.when(commandService.verifyIsNeedCreateCommand(any(Command.class))).thenReturn(true); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode, RERUN)) .thenReturn(checkProjectAndAuth()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
processDefinitionCode, "{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", CommandType.COMPLEMENT_DATA, null, null, null, null, 0, RunMode.RUN_MODE_PARALLEL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 15, Constants.DRY_RUN_FLAG_NO, Constants.TEST_FLAG_YES, ComplementDependentMode.OFF_MODE); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } @Test public void testStartCheckByProcessDefinedCode() { List<Long> ids = new ArrayList<>(); ids.add(1L); Mockito.doNothing().when(processService).recurseFindSubProcess(1, ids); List<ProcessDefinition> processDefinitionList = new ArrayList<>(); ProcessDefinition processDefinition = new ProcessDefinition(); processDefinition.setId(1); processDefinition.setReleaseState(ReleaseState.ONLINE); processDefinitionList.add(processDefinition); Mockito.when(processDefinitionMapper.queryDefinitionListByIdList(new Integer[ids.size()])) .thenReturn(processDefinitionList); Map<String, Object> result = executorService.startCheckByProcessDefinedCode(1L); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } private List<Server> getMasterServersList() { List<Server> masterServerList = new ArrayList<>(); Server masterServer1 = new Server(); masterServer1.setId(1);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
masterServer1.setHost("192.168.220.188"); masterServer1.setPort(1121); masterServerList.add(masterServer1); Server masterServer2 = new Server(); masterServer2.setId(2); masterServer2.setHost("192.168.220.189"); masterServer2.setPort(1122); masterServerList.add(masterServer2); return masterServerList; } private List zeroSchedulerList() { return Collections.EMPTY_LIST; } private List<Schedule> oneSchedulerList() { List<Schedule> schedulerList = new LinkedList<>(); Schedule schedule = new Schedule(); schedule.setCrontab("0 0 0 1/2 * ?"); schedulerList.add(schedule); return schedulerList; } private Map<String, Object> checkProjectAndAuth() { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, Status.SUCCESS); return result; } @Test public void testCreateComplementToParallel() { List<String> result = new ArrayList<>(); int expectedParallelismNumber = 3; LinkedList<Integer> listDate = new LinkedList<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
listDate.add(0); listDate.add(1); listDate.add(2); listDate.add(3); listDate.add(4); int listDateSize = listDate.size(); int createCount = Math.min(listDate.size(), expectedParallelismNumber); logger.info("In parallel mode, current expectedParallelismNumber:{}", createCount); int itemsPerCommand = (listDateSize / createCount); int remainingItems = (listDateSize % createCount); int startDateIndex = 0; int endDateIndex = 0; for (int i = 1; i <= createCount; i++) { int extra = (i <= remainingItems) ? 1 : 0; int singleCommandItems = (itemsPerCommand + extra); if (i == 1) { endDateIndex += singleCommandItems - 1; } else { startDateIndex = endDateIndex + 1; endDateIndex += singleCommandItems; } logger.info("startDate:{}, endDate:{}", listDate.get(startDateIndex), listDate.get(endDateIndex)); result.add(listDate.get(startDateIndex) + "," + listDate.get(endDateIndex)); } Assertions.assertEquals("0,1", result.get(0)); Assertions.assertEquals("2,3", result.get(1)); Assertions.assertEquals("4,4", result.get(2)); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
/* * 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
* 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.service; import org.apache.dolphinscheduler.api.ApiApplicationServer; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.impl.WorkerGroupServiceImpl; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.ProfileType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.WorkerGroup; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper; import org.apache.dolphinscheduler.service.registry.RegistryClient; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; @ActiveProfiles(value = {ProfileType.H2})
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
@SpringBootTest(classes = ApiApplicationServer.class) public class WorkerGroupServiceTest { @MockBean(name = "registryClient") private RegistryClient registryClient; @Autowired private WorkerGroupServiceImpl workerGroupService; @MockBean(name = "workerGroupMapper") private WorkerGroupMapper workerGroupMapper; @MockBean(name = "processInstanceMapper") private ProcessInstanceMapper processInstanceMapper; private String groupName = "groupName000001"; private User loginUSer; @BeforeEach public void init() { loginUSer = new User(); loginUSer.setUserType(UserType.ADMIN_USER); } @Test public void testQueryAllGroup() { Map<String, Object> result = workerGroupService.queryAllGroup(loginUSer); List<String> workerGroups = (List<String>) result.get(Constants.DATA_LIST); Assertions.assertEquals(workerGroups.size(), 1); } /** * delete group by id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
*/ @Test public void testDeleteWorkerGroupById() { User user = new User(); user.setId(1); user.setUserType(UserType.ADMIN_USER); WorkerGroup wg2 = getWorkerGroup(2); Mockito.when(workerGroupMapper.selectById(2)).thenReturn(wg2); Mockito.when(processInstanceMapper.queryByWorkerGroupNameAndStatus(wg2.getName(), org.apache.dolphinscheduler.service.utils.Constants.NOT_TERMINATED_STATES)) .thenReturn(getProcessInstanceList()); Map<String, Object> result = workerGroupService.deleteWorkerGroupById(user, 1); Assertions.assertEquals(Status.DELETE_WORKER_GROUP_NOT_EXIST.getCode(), ((Status) result.get(Constants.STATUS)).getCode()); result = workerGroupService.deleteWorkerGroupById(user, 2); Assertions.assertEquals(Status.DELETE_WORKER_GROUP_BY_ID_FAIL.getCode(), ((Status) result.get(Constants.STATUS)).getCode()); WorkerGroup wg3 = getWorkerGroup(3); Mockito.when(workerGroupMapper.selectById(3)).thenReturn(wg3); Mockito.when(processInstanceMapper.queryByWorkerGroupNameAndStatus(wg3.getName(), org.apache.dolphinscheduler.service.utils.Constants.NOT_TERMINATED_STATES)) .thenReturn(new ArrayList<>()); result = workerGroupService.deleteWorkerGroupById(user, 3); Assertions.assertEquals(Status.SUCCESS.getMsg(), result.get(Constants.MSG)); } /** * get processInstances */ private List<ProcessInstance> getProcessInstanceList() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java
List<ProcessInstance> processInstances = new ArrayList<>(); processInstances.add(new ProcessInstance()); return processInstances; } @Test public void testQueryAllGroupWithDefault() { Map<String, Object> result = workerGroupService.queryAllGroup(loginUSer); List<String> workerGroups = (List<String>) result.get(Constants.DATA_LIST); Assertions.assertEquals(1, workerGroups.size()); Assertions.assertEquals("default", workerGroups.toArray()[0]); } /** * get Group */ private WorkerGroup getWorkerGroup(int id) { WorkerGroup workerGroup = new WorkerGroup(); workerGroup.setName(groupName); workerGroup.setId(id); return workerGroup; } private WorkerGroup getWorkerGroup() { return getWorkerGroup(1); } private List<WorkerGroup> getList() { List<WorkerGroup> list = new ArrayList<>(); list.add(getWorkerGroup()); return list; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
/* * 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.service.process; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.model.TaskNodeRelation; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.DagData; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition; import org.apache.dolphinscheduler.dao.entity.DqComparisonType; import org.apache.dolphinscheduler.dao.entity.DqExecuteResult; import org.apache.dolphinscheduler.dao.entity.DqRule;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
import org.apache.dolphinscheduler.dao.entity.DqRuleExecuteSql; import org.apache.dolphinscheduler.dao.entity.DqRuleInputEntry; import org.apache.dolphinscheduler.dao.entity.Environment; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval; import org.apache.dolphinscheduler.service.exceptions.CronParseException; import org.apache.dolphinscheduler.service.model.TaskNode; import org.apache.dolphinscheduler.spi.enums.ResourceType; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Optional; import org.springframework.transaction.annotation.Transactional; public interface ProcessService {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
@Transactional ProcessInstance handleCommand(String host, Command command) throws CronParseException, CodeGenerateUtils.CodeGenerateException; Optional<ProcessInstance> findProcessInstanceDetailById(int processId); ProcessInstance findProcessInstanceById(int processId); ProcessDefinition findProcessDefineById(int processDefinitionId); ProcessDefinition findProcessDefinition(Long processDefinitionCode, int processDefinitionVersion); ProcessDefinition findProcessDefinitionByCode(Long processDefinitionCode); int deleteWorkProcessInstanceById(int processInstanceId); int deleteAllSubWorkProcessByParentId(int processInstanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
void removeTaskLogFile(Integer processInstanceId); void deleteWorkTaskInstanceByProcessInstanceId(int processInstanceId); void recurseFindSubProcess(long parentCode, List<Long> ids); Tenant getTenantForProcess(int tenantId, int userId); Environment findEnvironmentByCode(Long environmentCode); void setSubProcessParam(ProcessInstance subProcessInstance); TaskInstance submitTaskWithRetry(ProcessInstance processInstance, TaskInstance taskInstance, int commitRetryTimes, long commitInterval); @Transactional TaskInstance submitTask(ProcessInstance processInstance, TaskInstance taskInstance); void createSubWorkProcess(ProcessInstance parentProcessInstance, TaskInstance task); void packageTaskInstance(TaskInstance taskInstance, ProcessInstance processInstance); void updateTaskDefinitionResources(TaskDefinition taskDefinition); List<Integer> findTaskIdByInstanceState(int instanceId, TaskExecutionStatus state); int deleteWorkProcessMapByParentId(int parentWorkProcessId); ProcessInstance findSubProcessInstance(Integer parentProcessId, Integer parentTaskId); ProcessInstance findParentProcessInstance(Integer subProcessId); void changeOutParam(TaskInstance taskInstance); Schedule querySchedule(int id); List<Schedule> queryReleaseSchedulerListByProcessDefinitionCode(long processDefinitionCode); Map<Long, String> queryWorkerGroupByProcessDefinitionCodes(List<Long> processDefinitionCodeList); List<DependentProcessDefinition> queryDependentProcessDefinitionByProcessDefinitionCode(long processDefinitionCode); List<ProcessInstance> queryNeedFailoverProcessInstances(String host); List<String> queryNeedFailoverProcessInstanceHost(); @Transactional void processNeedFailoverProcessInstances(ProcessInstance processInstance); DataSource findDataSourceById(int id); ProcessInstance findProcessInstanceByTaskId(int taskId); List<UdfFunc> queryUdfFunListByIds(Integer[] ids); String queryTenantCodeByResName(String resName, ResourceType resourceType);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
List<Schedule> selectAllByProcessDefineCode(long[] codes); ProcessInstance findLastSchedulerProcessInterval(Long definitionCode, DateInterval dateInterval, int testFlag); ProcessInstance findLastManualProcessInterval(Long definitionCode, DateInterval dateInterval, int testFlag); ProcessInstance findLastRunningProcess(Long definitionCode, Date startTime, Date endTime, int testFlag); String queryUserQueueByProcessInstance(ProcessInstance processInstance); ProjectUser queryProjectWithUserByProcessInstanceId(int processInstanceId); String getTaskWorkerGroup(TaskInstance taskInstance); List<Project> getProjectListHavePerm(int userId); <T> List<T> listUnauthorized(int userId, T[] needChecks, AuthorizationType authorizationType); User getUserById(int userId); Resource getResourceById(int resourceId); List<Resource> listResourceByIds(Integer[] resIds); String formatTaskAppId(TaskInstance taskInstance); int switchVersion(ProcessDefinition processDefinition, ProcessDefinitionLog processDefinitionLog); int switchProcessTaskRelationVersion(ProcessDefinition processDefinition); int switchTaskDefinitionVersion(long taskCode, int taskVersion); String getResourceIds(TaskDefinition taskDefinition); int saveTaskDefine(User operator, long projectCode, List<TaskDefinitionLog> taskDefinitionLogs, Boolean syncDefine); int saveProcessDefine(User operator, ProcessDefinition processDefinition, Boolean syncDefine, Boolean isFromProcessDefine); int saveTaskRelation(User operator, long projectCode, long processDefinitionCode, int processDefinitionVersion, List<ProcessTaskRelationLog> taskRelationList, List<TaskDefinitionLog> taskDefinitionLogs, Boolean syncDefine); boolean isTaskOnline(long taskCode); DAG<String, TaskNode, TaskNodeRelation> genDagGraph(ProcessDefinition processDefinition); DagData genDagData(ProcessDefinition processDefinition); List<ProcessTaskRelation> findRelationByCode(long processDefinitionCode, int processDefinitionVersion); List<TaskNode> transformTask(List<ProcessTaskRelation> taskRelationList, List<TaskDefinitionLog> taskDefinitionLogs); Map<ProcessInstance, TaskInstance> notifyProcessList(int processId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
DqExecuteResult getDqExecuteResultByTaskInstanceId(int taskInstanceId); int updateDqExecuteResultUserId(int taskInstanceId); int updateDqExecuteResultState(DqExecuteResult dqExecuteResult); int deleteDqExecuteResultByTaskInstanceId(int taskInstanceId); int deleteTaskStatisticsValueByTaskInstanceId(int taskInstanceId); DqRule getDqRule(int ruleId); List<DqRuleInputEntry> getRuleInputEntry(int ruleId); List<DqRuleExecuteSql> getDqExecuteSql(int ruleId); DqComparisonType getComparisonTypeById(int id); boolean acquireTaskGroup(int taskId, String taskName, int groupId, int processId, int priority); boolean robTaskGroupResource(TaskGroupQueue taskGroupQueue); void releaseAllTaskGroup(int processInstanceId); TaskInstance releaseTaskGroup(TaskInstance taskInstance); void changeTaskGroupQueueStatus(int taskId, TaskGroupQueueStatus status); TaskGroupQueue insertIntoTaskGroupQueue(Integer taskId, String taskName, Integer groupId, Integer processId, Integer priority, TaskGroupQueueStatus status); int updateTaskGroupQueueStatus(Integer taskId, int status); int updateTaskGroupQueue(TaskGroupQueue taskGroupQueue); TaskGroupQueue loadTaskGroupQueue(int taskId); void sendStartTask2Master(ProcessInstance processInstance, int taskId, org.apache.dolphinscheduler.remote.command.CommandType taskType); ProcessInstance loadNextProcess4Serial(long code, int state, int id); public String findConfigYamlByName(String clusterName); void forceProcessInstanceSuccessByTaskInstanceId(Integer taskInstanceId); Integer queryTestDataSourceId(Integer onlineDataSourceId); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
/* * 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.service.process; import static java.util.stream.Collectors.toSet; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_END_DATE; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_EMPTY_SUB_PROCESS; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_RECOVER_PROCESS_ID_STRING;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_SUB_PROCESS; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID; import static org.apache.dolphinscheduler.common.constants.Constants.LOCAL_PARAMS; import static org.apache.dolphinscheduler.plugin.task.api.enums.DataType.VARCHAR; import static org.apache.dolphinscheduler.plugin.task.api.enums.Direct.IN; import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID; import org.apache.dolphinscheduler.common.constants.CommandKeyConstants; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.model.TaskNodeRelation; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Cluster; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.DagData; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition; import org.apache.dolphinscheduler.dao.entity.DqComparisonType;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
import org.apache.dolphinscheduler.dao.entity.DqExecuteResult; import org.apache.dolphinscheduler.dao.entity.DqRule; import org.apache.dolphinscheduler.dao.entity.DqRuleExecuteSql; import org.apache.dolphinscheduler.dao.entity.DqRuleInputEntry; import org.apache.dolphinscheduler.dao.entity.DqTaskStatisticsValue; import org.apache.dolphinscheduler.dao.entity.Environment; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.ResourcesTask; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskGroup; import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ClusterMapper; import org.apache.dolphinscheduler.dao.mapper.CommandMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.DqComparisonTypeMapper; import org.apache.dolphinscheduler.dao.mapper.DqExecuteResultMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.DqRuleExecuteSqlMapper; import org.apache.dolphinscheduler.dao.mapper.DqRuleInputEntryMapper; import org.apache.dolphinscheduler.dao.mapper.DqRuleMapper; import org.apache.dolphinscheduler.dao.mapper.DqTaskStatisticsValueMapper; import org.apache.dolphinscheduler.dao.mapper.EnvironmentMapper; import org.apache.dolphinscheduler.dao.mapper.ErrorCommandMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationLogMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceTaskMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.mapper.WorkFlowLineageMapper; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceMapDao; import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao; import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao; import org.apache.dolphinscheduler.dao.utils.DqRuleUtils; import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState; import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval; import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; import org.apache.dolphinscheduler.plugin.task.api.parameters.SubProcessParameters; import org.apache.dolphinscheduler.plugin.task.api.parameters.TaskTimeoutParameter; import org.apache.dolphinscheduler.remote.command.TaskEventChangeCommand; import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.service.command.CommandService; import org.apache.dolphinscheduler.service.cron.CronUtils; import org.apache.dolphinscheduler.service.exceptions.CronParseException; import org.apache.dolphinscheduler.service.exceptions.ServiceException; import org.apache.dolphinscheduler.service.expand.CuringParamsService; import org.apache.dolphinscheduler.service.log.LogClient; import org.apache.dolphinscheduler.service.model.TaskNode; import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.dolphinscheduler.service.utils.ClusterConfUtils; import org.apache.dolphinscheduler.service.utils.DagHelper; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Joiner; import com.google.common.base.Strings; import com.google.common.collect.Lists; /** * process relative dao that some mappers in this. */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
public class ProcessServiceImpl implements ProcessService { private final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private UserMapper userMapper; @Autowired private ProcessDefinitionMapper processDefineMapper; @Autowired private ProcessDefinitionLogMapper processDefineLogMapper; @Autowired private ProcessInstanceMapper processInstanceMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
private ProcessInstanceDao processInstanceDao; @Autowired private TaskDefinitionDao taskDefinitionDao; @Autowired private TaskInstanceDao taskInstanceDao; @Autowired private TaskDefinitionLogDao taskDefinitionLogDao; @Autowired private ProcessInstanceMapDao processInstanceMapDao; @Autowired private DataSourceMapper dataSourceMapper; @Autowired private ProcessInstanceMapMapper processInstanceMapMapper; @Autowired private TaskInstanceMapper taskInstanceMapper; @Autowired private CommandMapper commandMapper; @Autowired private ScheduleMapper scheduleMapper; @Autowired private UdfFuncMapper udfFuncMapper; @Autowired private ResourceMapper resourceMapper; @Autowired private ResourceTaskMapper resourceTaskMapper; @Autowired private ResourceUserMapper resourceUserMapper; @Autowired private ErrorCommandMapper errorCommandMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
private TenantMapper tenantMapper; @Autowired private ProjectMapper projectMapper; @Autowired private DqExecuteResultMapper dqExecuteResultMapper; @Autowired private DqRuleMapper dqRuleMapper; @Autowired private DqRuleInputEntryMapper dqRuleInputEntryMapper; @Autowired private DqRuleExecuteSqlMapper dqRuleExecuteSqlMapper; @Autowired private DqComparisonTypeMapper dqComparisonTypeMapper; @Autowired private DqTaskStatisticsValueMapper dqTaskStatisticsValueMapper; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private TaskDefinitionLogMapper taskDefinitionLogMapper; @Autowired private ProcessTaskRelationMapper processTaskRelationMapper; @Autowired private ProcessTaskRelationLogMapper processTaskRelationLogMapper; @Autowired StateEventCallbackService stateEventCallbackService; @Autowired private EnvironmentMapper environmentMapper; @Autowired private TaskGroupQueueMapper taskGroupQueueMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
private TaskGroupMapper taskGroupMapper; @Autowired private WorkFlowLineageMapper workFlowLineageMapper; @Autowired private TaskPluginManager taskPluginManager; @Autowired private ClusterMapper clusterMapper; @Autowired private CuringParamsService curingGlobalParamsService; @Autowired private LogClient logClient; @Autowired private CommandService commandService; /** * handle Command (construct ProcessInstance from Command) , wrapped in transaction * * @param host host * @param command found command * @return process instance */ @Override @Transactional public ProcessInstance handleCommand(String host, Command command) throws CronParseException, CodeGenerateException { ProcessInstance processInstance = constructProcessInstance(command, host); if (processInstance == null) { logger.error("scan command, command parameter is error: {}", command); commandService.moveToErrorCommand(command, "process instance is null"); return null;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} processInstance.setCommandType(command.getCommandType()); processInstance.addHistoryCmd(command.getCommandType()); processInstance.setTestFlag(command.getTestFlag()); ProcessDefinition processDefinition = this.findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (processDefinition.getExecutionType().typeIsSerial()) { saveSerialProcess(processInstance, processDefinition); if (processInstance.getState() != WorkflowExecutionStatus.SUBMITTED_SUCCESS) { setSubProcessParam(processInstance); deleteCommandWithCheck(command.getId()); return null; } } else { processInstanceDao.upsertProcessInstance(processInstance); } setSubProcessParam(processInstance); deleteCommandWithCheck(command.getId()); return processInstance; } protected void saveSerialProcess(ProcessInstance processInstance, ProcessDefinition processDefinition) { processInstance.setStateWithDesc(WorkflowExecutionStatus.SERIAL_WAIT, "wait by serial_wait strategy"); processInstanceDao.upsertProcessInstance(processInstance); if (processDefinition.getExecutionType().typeIsSerialWait()) { List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId( processInstance.getProcessDefinitionCode(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
processInstance.getProcessDefinitionVersion(), org.apache.dolphinscheduler.service.utils.Constants.RUNNING_PROCESS_STATE, processInstance.getId()); if (CollectionUtils.isEmpty(runningProcessInstances)) { processInstance.setStateWithDesc(WorkflowExecutionStatus.SUBMITTED_SUCCESS, "submit from serial_wait strategy"); processInstanceDao.upsertProcessInstance(processInstance); } } else if (processDefinition.getExecutionType().typeIsSerialDiscard()) { List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId( processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion(), org.apache.dolphinscheduler.service.utils.Constants.RUNNING_PROCESS_STATE, processInstance.getId()); if (CollectionUtils.isNotEmpty(runningProcessInstances)) { processInstance.setStateWithDesc(WorkflowExecutionStatus.STOP, "stop by serial_discard strategy"); processInstanceDao.upsertProcessInstance(processInstance); return; } processInstance.setStateWithDesc(WorkflowExecutionStatus.SUBMITTED_SUCCESS, "submit from serial_discard strategy"); processInstanceDao.upsertProcessInstance(processInstance); } else if (processDefinition.getExecutionType().typeIsSerialPriority()) { List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId( processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion(), org.apache.dolphinscheduler.service.utils.Constants.RUNNING_PROCESS_STATE, processInstance.getId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
for (ProcessInstance info : runningProcessInstances) { info.setCommandType(CommandType.STOP); info.addHistoryCmd(CommandType.STOP); info.setStateWithDesc(WorkflowExecutionStatus.READY_STOP, "ready stop by serial_priority strategy"); int update = processInstanceDao.updateProcessInstance(info); if (update > 0) { WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( info.getId(), 0, info.getState(), info.getId(), 0); try { Host host = new Host(info.getHost()); stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command()); } catch (Exception e) { logger.error("sendResultError", e); } } } processInstance.setStateWithDesc(WorkflowExecutionStatus.SUBMITTED_SUCCESS, "submit by serial_priority strategy"); processInstanceDao.upsertProcessInstance(processInstance); } } /** * find process instance detail by id * * @param processId processId * @return process instance */ @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
public Optional<ProcessInstance> findProcessInstanceDetailById(int processId) { return Optional.ofNullable(processInstanceMapper.queryDetailById(processId)); } /** * find process instance by id * * @param processId processId * @return process instance */ @Override public ProcessInstance findProcessInstanceById(int processId) { return processInstanceMapper.selectById(processId); } /** * find process define by id. * * @param processDefinitionId processDefinitionId * @return process definition */ @Override public ProcessDefinition findProcessDefineById(int processDefinitionId) { return processDefineMapper.selectById(processDefinitionId); } /** * find process define by code and version. * * @param processDefinitionCode processDefinitionCode * @return process definition */ @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
public ProcessDefinition findProcessDefinition(Long processDefinitionCode, int version) { ProcessDefinition processDefinition = processDefineMapper.queryByCode(processDefinitionCode); if (processDefinition == null || processDefinition.getVersion() != version) { processDefinition = processDefineLogMapper.queryByDefinitionCodeAndVersion(processDefinitionCode, version); if (processDefinition != null) { processDefinition.setId(0); } } return processDefinition; } /** * find process define by code. * * @param processDefinitionCode processDefinitionCode * @return process definition */ @Override public ProcessDefinition findProcessDefinitionByCode(Long processDefinitionCode) { return processDefineMapper.queryByCode(processDefinitionCode); } /** * delete work process instance by id * * @param processInstanceId processInstanceId * @return delete process instance result */ @Override public int deleteWorkProcessInstanceById(int processInstanceId) { return processInstanceMapper.deleteById(processInstanceId); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
/** * delete all sub process by parent instance id * * @param processInstanceId processInstanceId * @return delete all sub process instance result */ @Override public int deleteAllSubWorkProcessByParentId(int processInstanceId) { List<Integer> subProcessIdList = processInstanceMapMapper.querySubIdListByParentId(processInstanceId); for (Integer subId : subProcessIdList) { deleteAllSubWorkProcessByParentId(subId); deleteWorkProcessMapByParentId(subId); removeTaskLogFile(subId); deleteWorkProcessInstanceById(subId); } return 1; } /** * remove task log file * * @param processInstanceId processInstanceId */ @Override public void removeTaskLogFile(Integer processInstanceId) { ProcessInstance processInstance = processInstanceMapper.selectById(processInstanceId); List<TaskInstance> taskInstanceList = taskInstanceDao.findValidTaskListByProcessId(processInstanceId, processInstance.getTestFlag()); if (CollectionUtils.isEmpty(taskInstanceList)) { return; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
for (TaskInstance taskInstance : taskInstanceList) { String taskLogPath = taskInstance.getLogPath(); if (Strings.isNullOrEmpty(taskInstance.getHost())) { continue; } Host host = Host.of(taskInstance.getHost()); logClient.removeTaskLog(host.getIp(), host.getPort(), taskLogPath); } } /** * recursive delete all task instance by process instance id */ @Override public void deleteWorkTaskInstanceByProcessInstanceId(int processInstanceId) { ProcessInstance processInstance = processInstanceMapper.selectById(processInstanceId); List<TaskInstance> taskInstanceList = taskInstanceDao.findValidTaskListByProcessId(processInstanceId, processInstance.getTestFlag()); if (CollectionUtils.isEmpty(taskInstanceList)) { return; } List<Integer> taskInstanceIdList = new ArrayList<>(); for (TaskInstance taskInstance : taskInstanceList) { taskInstanceIdList.add(taskInstance.getId()); } taskInstanceMapper.deleteBatchIds(taskInstanceIdList); } /** * recursive query sub process definition id by parent id. *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
* @param parentCode parentCode * @param ids ids */ @Override public void recurseFindSubProcess(long parentCode, List<Long> ids) { List<TaskDefinition> taskNodeList = taskDefinitionDao.getTaskDefinitionListByDefinition(parentCode); if (taskNodeList != null && !taskNodeList.isEmpty()) { for (TaskDefinition taskNode : taskNodeList) { String parameter = taskNode.getTaskParams(); ObjectNode parameterJson = JSONUtils.parseObject(parameter); if (parameterJson.get(CMD_PARAM_SUB_PROCESS_DEFINE_CODE) != null) { SubProcessParameters subProcessParam = JSONUtils.parseObject(parameter, SubProcessParameters.class); ids.add(subProcessParam.getProcessDefinitionCode()); recurseFindSubProcess(subProcessParam.getProcessDefinitionCode(), ids); } } } } /** * get schedule time from command * * @param command command * @param cmdParam cmdParam map * @return date */ private Date getScheduleTime(Command command, Map<String, String> cmdParam) throws CronParseException { Date scheduleTime = command.getScheduleTime(); if (scheduleTime == null && cmdParam != null && cmdParam.containsKey(CMD_PARAM_COMPLEMENT_DATA_START_DATE)) { Date start = DateUtils.stringToDate(cmdParam.get(CMD_PARAM_COMPLEMENT_DATA_START_DATE)); Date end = DateUtils.stringToDate(cmdParam.get(CMD_PARAM_COMPLEMENT_DATA_END_DATE));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
List<Schedule> schedules = queryReleaseSchedulerListByProcessDefinitionCode(command.getProcessDefinitionCode()); List<Date> complementDateList = CronUtils.getSelfFireDateList(start, end, schedules); if (CollectionUtils.isNotEmpty(complementDateList)) { scheduleTime = complementDateList.get(0); } else { logger.error("set scheduler time error: complement date list is empty, command: {}", command.toString()); } } return scheduleTime; } /** * generate a new work process instance from command. * * @param processDefinition processDefinition * @param command command * @param cmdParam cmdParam map * @return process instance */ private ProcessInstance generateNewProcessInstance(ProcessDefinition processDefinition, Command command, Map<String, String> cmdParam) { ProcessInstance processInstance = new ProcessInstance(processDefinition); processInstance.setProcessDefinitionCode(processDefinition.getCode()); processInstance.setProcessDefinitionVersion(processDefinition.getVersion()); processInstance.setStateWithDesc(WorkflowExecutionStatus.RUNNING_EXECUTION, "init running"); processInstance.setRecovery(Flag.NO); processInstance.setStartTime(new Date());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
processInstance.setRestartTime(null); processInstance.setRunTimes(1); processInstance.setMaxTryTimes(0); processInstance.setCommandParam(command.getCommandParam()); processInstance.setCommandType(command.getCommandType()); processInstance.setIsSubProcess(Flag.NO); processInstance.setTaskDependType(command.getTaskDependType()); processInstance.setFailureStrategy(command.getFailureStrategy()); processInstance.setExecutorId(command.getExecutorId()); WarningType warningType = command.getWarningType() == null ? WarningType.NONE : command.getWarningType(); processInstance.setWarningType(warningType); Integer warningGroupId = command.getWarningGroupId() == null ? 0 : command.getWarningGroupId(); processInstance.setWarningGroupId(warningGroupId); processInstance.setDryRun(command.getDryRun()); processInstance.setTestFlag(command.getTestFlag()); if (command.getScheduleTime() != null) { processInstance.setScheduleTime(command.getScheduleTime()); } processInstance.setCommandStartTime(command.getStartTime()); processInstance.setLocations(processDefinition.getLocations()); setGlobalParamIfCommanded(processDefinition, cmdParam); Map<String, String> commandParamMap = JSONUtils.toMap(command.getCommandParam()); String timezoneId = null; if (commandParamMap != null) { timezoneId = commandParamMap.get(Constants.SCHEDULE_TIMEZONE); } String globalParams = curingGlobalParamsService.curingGlobalParams(processInstance.getId(), processDefinition.getGlobalParamMap(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
processDefinition.getGlobalParamList(), getCommandTypeIfComplement(processInstance, command), processInstance.getScheduleTime(), timezoneId); processInstance.setGlobalParams(globalParams); processInstance.setProcessInstancePriority(command.getProcessInstancePriority()); String workerGroup = Strings.isNullOrEmpty(command.getWorkerGroup()) ? Constants.DEFAULT_WORKER_GROUP : command.getWorkerGroup(); processInstance.setWorkerGroup(workerGroup); processInstance .setEnvironmentCode(Objects.isNull(command.getEnvironmentCode()) ? -1 : command.getEnvironmentCode()); processInstance.setTimeout(processDefinition.getTimeout()); processInstance.setTenantId(processDefinition.getTenantId()); return processInstance; } private void setGlobalParamIfCommanded(ProcessDefinition processDefinition, Map<String, String> cmdParam) { Map<String, String> startParamMap = new HashMap<>(); if (cmdParam != null && cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_START_PARAMS)) { String startParamJson = cmdParam.get(CommandKeyConstants.CMD_PARAM_START_PARAMS); startParamMap = JSONUtils.toMap(startParamJson); } Map<String, String> fatherParamMap = new HashMap<>(); if (cmdParam != null && cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_FATHER_PARAMS)) { String fatherParamJson = cmdParam.get(CommandKeyConstants.CMD_PARAM_FATHER_PARAMS); fatherParamMap = JSONUtils.toMap(fatherParamJson); } startParamMap.putAll(fatherParamMap); Map<String, String> globalMap = processDefinition.getGlobalParamMap();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
List<Property> globalParamList = processDefinition.getGlobalParamList(); if (MapUtils.isNotEmpty(startParamMap) && globalMap != null) { for (Map.Entry<String, String> param : globalMap.entrySet()) { String val = startParamMap.get(param.getKey()); if (val != null) { param.setValue(val); } } for (Entry<String, String> startParam : startParamMap.entrySet()) { if (!globalMap.containsKey(startParam.getKey())) { globalMap.put(startParam.getKey(), startParam.getValue()); globalParamList.add(new Property(startParam.getKey(), IN, VARCHAR, startParam.getValue())); } } } } /** * get process tenant * there is tenant id in definition, use the tenant of the definition. * if there is not tenant id in the definiton or the tenant not exist * use definition creator's tenant. * * @param tenantId tenantId * @param userId userId * @return tenant */ @Override public Tenant getTenantForProcess(int tenantId, int userId) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
Tenant tenant = null; if (tenantId >= 0) { tenant = tenantMapper.queryById(tenantId); } if (userId == 0) { return null; } if (tenant == null) { User user = userMapper.selectById(userId); tenant = tenantMapper.queryById(user.getTenantId()); } return tenant; } /** * get an environment * use the code of the environment to find a environment. * * @param environmentCode environmentCode * @return Environment */ @Override public Environment findEnvironmentByCode(Long environmentCode) { Environment environment = null; if (environmentCode >= 0) { environment = environmentMapper.queryByEnvironmentCode(environmentCode); } return environment; } /** * check command parameters is valid
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
* * @param command command * @param cmdParam cmdParam map * @return whether command param is valid */ private Boolean checkCmdParam(Command command, Map<String, String> cmdParam) { if (command.getTaskDependType() == TaskDependType.TASK_ONLY || command.getTaskDependType() == TaskDependType.TASK_PRE) { if (cmdParam == null || !cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_START_NODES) || cmdParam.get(CommandKeyConstants.CMD_PARAM_START_NODES).isEmpty()) { logger.error("command node depend type is {}, but start nodes is null ", command.getTaskDependType()); return false; } } return true; } /** * construct process instance according to one command. * * @param command command * @param host host * @return process instance */ protected @Nullable ProcessInstance constructProcessInstance(Command command, String host) throws CronParseException, CodeGenerateException { ProcessInstance processInstance; ProcessDefinition processDefinition; CommandType commandType = command.getCommandType(); processDefinition =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
this.findProcessDefinition(command.getProcessDefinitionCode(), command.getProcessDefinitionVersion()); if (processDefinition == null) { logger.error("cannot find the work process define! define code : {}", command.getProcessDefinitionCode()); throw new IllegalArgumentException("Cannot find the process definition for this workflowInstance"); } Map<String, String> cmdParam = JSONUtils.toMap(command.getCommandParam()); if (cmdParam == null) { cmdParam = new HashMap<>(); } int processInstanceId = command.getProcessInstanceId(); if (processInstanceId == 0) { processInstance = generateNewProcessInstance(processDefinition, command, cmdParam); } else { processInstance = this.findProcessInstanceDetailById(processInstanceId).orElse(null); if (processInstance == null) { return null; } } CommandType commandTypeIfComplement = getCommandTypeIfComplement(processInstance, command); if (commandTypeIfComplement == CommandType.REPEAT_RUNNING) { setGlobalParamIfCommanded(processDefinition, cmdParam); } String timezoneId = cmdParam.get(Constants.SCHEDULE_TIMEZONE); String globalParams = curingGlobalParamsService.curingGlobalParams(processInstance.getId(), processDefinition.getGlobalParamMap(), processDefinition.getGlobalParamList(), commandTypeIfComplement,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
processInstance.getScheduleTime(), timezoneId); processInstance.setGlobalParams(globalParams); processInstance.setProcessDefinition(processDefinition); if (processInstance.getCommandParam() != null) { Map<String, String> processCmdParam = JSONUtils.toMap(processInstance.getCommandParam()); Map<String, String> finalCmdParam = cmdParam; processCmdParam.forEach((key, value) -> { if (!finalCmdParam.containsKey(key)) { finalCmdParam.put(key, value); } }); } if (cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_SUB_PROCESS)) { processInstance.setCommandParam(command.getCommandParam()); } if (Boolean.FALSE.equals(checkCmdParam(command, cmdParam))) { logger.error("command parameter check failed!"); return null; } if (command.getScheduleTime() != null) { processInstance.setScheduleTime(command.getScheduleTime()); } processInstance.setHost(host); processInstance.setRestartTime(new Date()); WorkflowExecutionStatus runStatus = WorkflowExecutionStatus.RUNNING_EXECUTION; int runTime = processInstance.getRunTimes(); switch (commandType) { case START_PROCESS:
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
break; case START_FAILURE_TASK_PROCESS: List<Integer> failedList = this.findTaskIdByInstanceState(processInstance.getId(), TaskExecutionStatus.FAILURE); List<Integer> toleranceList = this.findTaskIdByInstanceState(processInstance.getId(), TaskExecutionStatus.NEED_FAULT_TOLERANCE); List<Integer> killedList = this.findTaskIdByInstanceState(processInstance.getId(), TaskExecutionStatus.KILL); cmdParam.remove(CommandKeyConstants.CMD_PARAM_RECOVERY_START_NODE_STRING); failedList.addAll(killedList); failedList.addAll(toleranceList); for (Integer taskId : failedList) { initTaskInstance(taskInstanceDao.findTaskInstanceById(taskId)); } cmdParam.put(CommandKeyConstants.CMD_PARAM_RECOVERY_START_NODE_STRING, String.join(Constants.COMMA, convertIntListToString(failedList))); processInstance.setCommandParam(JSONUtils.toJsonString(cmdParam)); processInstance.setRunTimes(runTime + 1); break; case START_CURRENT_TASK_PROCESS: break; case RECOVER_WAITING_THREAD: break; case RECOVER_SUSPENDED_PROCESS: cmdParam.remove(CommandKeyConstants.CMD_PARAM_RECOVERY_START_NODE_STRING); List<Integer> stopNodeList = findTaskIdByInstanceState(processInstance.getId(), TaskExecutionStatus.KILL); for (Integer taskId : stopNodeList) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
initTaskInstance(taskInstanceDao.findTaskInstanceById(taskId)); } cmdParam.put(CommandKeyConstants.CMD_PARAM_RECOVERY_START_NODE_STRING, String.join(Constants.COMMA, convertIntListToString(stopNodeList))); processInstance.setCommandParam(JSONUtils.toJsonString(cmdParam)); processInstance.setRunTimes(runTime + 1); break; case RECOVER_TOLERANCE_FAULT_PROCESS: processInstance.setRecovery(Flag.YES); processInstance.setRunTimes(runTime + 1); runStatus = processInstance.getState(); break; case COMPLEMENT_DATA: if (processInstance.getId() != null) { List<TaskInstance> taskInstanceList = taskInstanceDao.findValidTaskListByProcessId(processInstance.getId(), processInstance.getTestFlag()); for (TaskInstance taskInstance : taskInstanceList) { taskInstance.setFlag(Flag.NO); taskInstanceDao.updateTaskInstance(taskInstance); } } break; case REPEAT_RUNNING: if (cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_RECOVERY_START_NODE_STRING)) { cmdParam.remove(CommandKeyConstants.CMD_PARAM_RECOVERY_START_NODE_STRING);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
processInstance.setCommandParam(JSONUtils.toJsonString(cmdParam)); } List<TaskInstance> validTaskList = taskInstanceDao.findValidTaskListByProcessId(processInstance.getId(), processInstance.getTestFlag()); for (TaskInstance taskInstance : validTaskList) { taskInstance.setFlag(Flag.NO); taskInstanceDao.updateTaskInstance(taskInstance); } processInstance.setStartTime(new Date()); processInstance.setRestartTime(processInstance.getStartTime()); processInstance.setEndTime(null); processInstance.setRunTimes(runTime + 1); initComplementDataParam(processDefinition, processInstance, cmdParam); break; case SCHEDULER: break; default: break; } processInstance.setStateWithDesc(runStatus, commandType.getDescp()); return processInstance; } /** * get process definition by command * If it is a fault-tolerant command, get the specified version of ProcessDefinition through ProcessInstance * Otherwise, get the latest version of ProcessDefinition * * @return ProcessDefinition
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
*/ private @Nullable ProcessDefinition getProcessDefinitionByCommand(long processDefinitionCode, Map<String, String> cmdParam) { if (cmdParam != null) { int processInstanceId = 0; if (cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_RECOVER_PROCESS_ID_STRING)) { processInstanceId = Integer.parseInt(cmdParam.get(CommandKeyConstants.CMD_PARAM_RECOVER_PROCESS_ID_STRING)); } else if (cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_SUB_PROCESS)) { processInstanceId = Integer.parseInt(cmdParam.get(CommandKeyConstants.CMD_PARAM_SUB_PROCESS)); } else if (cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_RECOVERY_WAITING_THREAD)) { processInstanceId = Integer.parseInt(cmdParam.get(CommandKeyConstants.CMD_PARAM_RECOVERY_WAITING_THREAD)); } if (processInstanceId != 0) { ProcessInstance processInstance = this.findProcessInstanceDetailById(processInstanceId).orElse(null); if (processInstance == null) { return null; } return processDefineLogMapper.queryByDefinitionCodeAndVersion( processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); } } return processDefineMapper.queryByCode(processDefinitionCode); } /** * return complement data if the process start with complement data * * @param processInstance processInstance * @param command command
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
* @return command type */ private CommandType getCommandTypeIfComplement(ProcessInstance processInstance, Command command) { if (CommandType.COMPLEMENT_DATA == processInstance.getCmdTypeIfComplement()) { return CommandType.COMPLEMENT_DATA; } else { return command.getCommandType(); } } /** * initialize complement data parameters * * @param processDefinition processDefinition * @param processInstance processInstance * @param cmdParam cmdParam */ private void initComplementDataParam(ProcessDefinition processDefinition, ProcessInstance processInstance, Map<String, String> cmdParam) throws CronParseException { if (!processInstance.isComplementData()) { return; } Date start = DateUtils.stringToDate(cmdParam.get(CMD_PARAM_COMPLEMENT_DATA_START_DATE)); Date end = DateUtils.stringToDate(cmdParam.get(CMD_PARAM_COMPLEMENT_DATA_END_DATE)); List<Date> complementDate = Lists.newLinkedList(); if (start != null && end != null) { List<Schedule> listSchedules = queryReleaseSchedulerListByProcessDefinitionCode(processInstance.getProcessDefinitionCode()); complementDate = CronUtils.getSelfFireDateList(start, end, listSchedules); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
if (cmdParam.containsKey(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { complementDate = CronUtils.getSelfScheduleDateList(cmdParam); } if (CollectionUtils.isNotEmpty(complementDate) && Flag.NO == processInstance.getIsSubProcess()) { processInstance.setScheduleTime(complementDate.get(0)); } String timezoneId = cmdParam.get(Constants.SCHEDULE_TIMEZONE); String globalParams = curingGlobalParamsService.curingGlobalParams(processInstance.getId(), processDefinition.getGlobalParamMap(), processDefinition.getGlobalParamList(), CommandType.COMPLEMENT_DATA, processInstance.getScheduleTime(), timezoneId); processInstance.setGlobalParams(globalParams); } /** * set sub work process parameters. * handle sub work process instance, update relation table and command parameters * set sub work process flag, extends parent work process command parameters * * @param subProcessInstance subProcessInstance */ @Override public void setSubProcessParam(ProcessInstance subProcessInstance) { String cmdParam = subProcessInstance.getCommandParam(); if (Strings.isNullOrEmpty(cmdParam)) { return; } Map<String, String> paramMap = JSONUtils.toMap(cmdParam); if (paramMap.containsKey(CMD_PARAM_SUB_PROCESS)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
&& CMD_PARAM_EMPTY_SUB_PROCESS.equals(paramMap.get(CMD_PARAM_SUB_PROCESS))) { paramMap.remove(CMD_PARAM_SUB_PROCESS); paramMap.put(CMD_PARAM_SUB_PROCESS, String.valueOf(subProcessInstance.getId())); subProcessInstance.setCommandParam(JSONUtils.toJsonString(paramMap)); subProcessInstance.setIsSubProcess(Flag.YES); processInstanceDao.upsertProcessInstance(subProcessInstance); } String parentInstanceId = paramMap.get(CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID); if (!Strings.isNullOrEmpty(parentInstanceId)) { ProcessInstance parentInstance = findProcessInstanceDetailById(Integer.parseInt(parentInstanceId)).orElse(null); if (parentInstance != null) { subProcessInstance.setGlobalParams( joinGlobalParams(parentInstance.getGlobalParams(), subProcessInstance.getGlobalParams())); subProcessInstance .setVarPool(joinVarPool(parentInstance.getVarPool(), subProcessInstance.getVarPool())); processInstanceDao.upsertProcessInstance(subProcessInstance); } else { logger.error("sub process command params error, cannot find parent instance: {} ", cmdParam); } } ProcessInstanceMap processInstanceMap = JSONUtils.parseObject(cmdParam, ProcessInstanceMap.class); if (processInstanceMap == null || processInstanceMap.getParentProcessInstanceId() == 0) { return; } processInstanceMap.setProcessInstanceId(subProcessInstance.getId()); processInstanceMapDao.updateWorkProcessInstanceMap(processInstanceMap); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
/** * join parent global params into sub process. * only the keys doesn't in sub process global would be joined. * * @param parentGlobalParams parentGlobalParams * @param subGlobalParams subGlobalParams * @return global params join */ private String joinGlobalParams(String parentGlobalParams, String subGlobalParams) { List<Property> parentParams = Lists.newArrayList(JSONUtils.toList(parentGlobalParams, Property.class)); List<Property> subParams = JSONUtils.toList(subGlobalParams, Property.class); Set<String> parentParamKeys = parentParams.stream().map(Property::getProp).collect(toSet()); List<Property> extraSubParams = subParams.stream() .filter(subProp -> !parentParamKeys.contains(subProp.getProp())).collect(Collectors.toList()); parentParams.addAll(extraSubParams); return JSONUtils.toJsonString(parentParams); } /** * join parent var pool params into sub process. * only the keys doesn't in sub process global would be joined. * * @param parentValPool * @param subValPool * @return
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
*/ private String joinVarPool(String parentValPool, String subValPool) { List<Property> parentValPools = Lists.newArrayList(JSONUtils.toList(parentValPool, Property.class)); parentValPools = parentValPools.stream().filter(valPool -> valPool.getDirect() == Direct.OUT) .collect(Collectors.toList()); List<Property> subValPools = Lists.newArrayList(JSONUtils.toList(subValPool, Property.class)); Set<String> parentValPoolKeys = parentValPools.stream().map(Property::getProp).collect(toSet()); List<Property> extraSubValPools = subValPools.stream().filter(sub -> !parentValPoolKeys.contains(sub.getProp())) .collect(Collectors.toList()); parentValPools.addAll(extraSubValPools); return JSONUtils.toJsonString(parentValPools); } /** * initialize task instance * * @param taskInstance taskInstance */ private void initTaskInstance(TaskInstance taskInstance) { if (!taskInstance.isSubProcess() && (taskInstance.getState().isKill() || taskInstance.getState().isFailure())) { taskInstance.setFlag(Flag.NO); taskInstanceDao.updateTaskInstance(taskInstance); return; } taskInstance.setState(TaskExecutionStatus.SUBMITTED_SUCCESS); taskInstanceDao.updateTaskInstance(taskInstance); } /** * retry submit task to db */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
@Override public TaskInstance submitTaskWithRetry(ProcessInstance processInstance, TaskInstance taskInstance, int commitRetryTimes, long commitInterval) { int retryTimes = 1; TaskInstance task = null; while (retryTimes <= commitRetryTimes) { try { task = submitTask(processInstance, taskInstance); if (task != null && task.getId() != null) { break; } logger.error( "task commit to db failed , taskCode: {} has already retry {} times, please check the database", taskInstance.getTaskCode(), retryTimes); Thread.sleep(commitInterval); } catch (Exception e) { logger.error("task commit to db failed", e); } finally { retryTimes += 1; } } return task; } /** * // todo: This method need to refactor, we find when the db down, but the taskInstanceId is not 0. It's better to change to void, rather than return TaskInstance * submit task to db * submit sub process to command
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
* * @param processInstance processInstance * @param taskInstance taskInstance * @return task instance */ @Override @Transactional public TaskInstance submitTask(ProcessInstance processInstance, TaskInstance taskInstance) { logger.info("Start save taskInstance to database : {}, processInstance id:{}, state: {}", taskInstance.getName(), taskInstance.getProcessInstanceId(), processInstance.getState()); TaskInstance task = taskInstanceDao.submitTaskInstanceToDB(taskInstance, processInstance); if (task == null) { logger.error("Save taskInstance to db error, task name:{}, process id:{} state: {} ", taskInstance.getName(), taskInstance.getProcessInstance().getId(), processInstance.getState()); return null; } if (!task.getState().isFinished()) { createSubWorkProcess(processInstance, task); } logger.info( "End save taskInstance to db successfully:{}, taskInstanceName: {}, taskInstance state:{}, processInstanceId:{}, processInstanceState: {}", task.getId(), task.getName(), task.getState(), processInstance.getId(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
processInstance.getState()); return task; } /** * set work process instance map * consider o * repeat running does not generate new sub process instance * set map {parent instance id, task instance id, 0(child instance id)} * * @param parentInstance parentInstance * @param parentTask parentTask * @param processMap processMap * @return process instance map */ private ProcessInstanceMap setProcessInstanceMap(ProcessInstance parentInstance, TaskInstance parentTask, ProcessInstanceMap processMap) { if (processMap != null) { return processMap; } if (parentInstance.getCommandType() == CommandType.REPEAT_RUNNING) { processMap = findPreviousTaskProcessMap(parentInstance, parentTask); if (processMap != null) { processMap.setParentTaskInstanceId(parentTask.getId()); processInstanceMapDao.updateWorkProcessInstanceMap(processMap); return processMap; } } processMap = new ProcessInstanceMap();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
processMap.setParentProcessInstanceId(parentInstance.getId()); processMap.setParentTaskInstanceId(parentTask.getId()); processInstanceMapDao.createWorkProcessInstanceMap(processMap); return processMap; } /** * find previous task work process map. * * @param parentProcessInstance parentProcessInstance * @param parentTask parentTask * @return process instance map */ private ProcessInstanceMap findPreviousTaskProcessMap(ProcessInstance parentProcessInstance, TaskInstance parentTask) { Integer preTaskId = 0; List<TaskInstance> preTaskList = taskInstanceDao.findPreviousTaskListByWorkProcessId(parentProcessInstance.getId()); for (TaskInstance task : preTaskList) { if (task.getName().equals(parentTask.getName())) { preTaskId = task.getId(); ProcessInstanceMap map = processInstanceMapDao.findWorkProcessMapByParent(parentProcessInstance.getId(), preTaskId); if (map != null) { return map; } } } logger.info("sub process instance is not found,parent task:{},parent instance:{}", parentTask.getId(), parentProcessInstance.getId()); return null;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} /** * create sub work process command * * @param parentProcessInstance parentProcessInstance * @param task task */ @Override public void createSubWorkProcess(ProcessInstance parentProcessInstance, TaskInstance task) { if (!task.isSubProcess()) { return; } ProcessInstanceMap instanceMap = processInstanceMapDao.findWorkProcessMapByParent(parentProcessInstance.getId(), task.getId()); if (null != instanceMap && CommandType.RECOVER_TOLERANCE_FAULT_PROCESS == parentProcessInstance.getCommandType()) { return; } instanceMap = setProcessInstanceMap(parentProcessInstance, task, instanceMap); ProcessInstance childInstance = null; if (instanceMap.getProcessInstanceId() != 0) { childInstance = findProcessInstanceById(instanceMap.getProcessInstanceId()); } if (childInstance != null && childInstance.getState() == WorkflowExecutionStatus.SUCCESS && CommandType.START_FAILURE_TASK_PROCESS == parentProcessInstance.getCommandType()) { logger.info("sub process instance {} status is success, so skip creating command", childInstance.getId()); return; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
Command subProcessCommand = commandService.createSubProcessCommand(parentProcessInstance, childInstance, instanceMap, task); if (subProcessCommand == null) { logger.error("create sub process command failed, so skip creating command"); return; } updateSubProcessDefinitionByParent(parentProcessInstance, subProcessCommand.getProcessDefinitionCode()); initSubInstanceState(childInstance); commandService.createCommand(subProcessCommand); logger.info("sub process command created: {} ", subProcessCommand); } /** * initialize sub work flow state * child instance state would be initialized when 'recovery from pause/stop/failure' */ private void initSubInstanceState(ProcessInstance childInstance) { if (childInstance != null) { childInstance.setStateWithDesc(WorkflowExecutionStatus.RUNNING_EXECUTION, "init sub workflow instance"); processInstanceDao.updateProcessInstance(childInstance); } } /** * get sub work flow command type * child instance exist: child command = fatherCommand * child instance not exists: child command = fatherCommand[0] */ private CommandType getSubCommandType(ProcessInstance parentProcessInstance, ProcessInstance childInstance) { CommandType commandType = parentProcessInstance.getCommandType(); if (childInstance == null) { String fatherHistoryCommand = parentProcessInstance.getHistoryCmd();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
commandType = CommandType.valueOf(fatherHistoryCommand.split(Constants.COMMA)[0]); } return commandType; } /** * update sub process definition * * @param parentProcessInstance parentProcessInstance * @param childDefinitionCode childDefinitionId */ private void updateSubProcessDefinitionByParent(ProcessInstance parentProcessInstance, long childDefinitionCode) { ProcessDefinition fatherDefinition = this.findProcessDefinition(parentProcessInstance.getProcessDefinitionCode(), parentProcessInstance.getProcessDefinitionVersion()); ProcessDefinition childDefinition = this.findProcessDefinitionByCode(childDefinitionCode); if (childDefinition != null && fatherDefinition != null) { childDefinition.setWarningGroupId(fatherDefinition.getWarningGroupId()); processDefineMapper.updateById(childDefinition); } } /** * package task instance */ @Override public void packageTaskInstance(TaskInstance taskInstance, ProcessInstance processInstance) { taskInstance.setProcessInstance(processInstance); taskInstance.setProcessDefine(processInstance.getProcessDefinition()); taskInstance.setProcessInstancePriority(processInstance.getProcessInstancePriority()); TaskDefinition taskDefinition = taskDefinitionDao.findTaskDefinition( taskInstance.getTaskCode(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
taskInstance.getTaskDefinitionVersion()); this.updateTaskDefinitionResources(taskDefinition); taskInstance.setTaskDefine(taskDefinition); taskInstance.setTestFlag(processInstance.getTestFlag()); } /** * Update {@link ResourceInfo} information in {@link TaskDefinition} * * @param taskDefinition the given {@link TaskDefinition} */ @Override public void updateTaskDefinitionResources(TaskDefinition taskDefinition) { Map<String, Object> taskParameters = JSONUtils.parseObject( taskDefinition.getTaskParams(), new TypeReference<Map<String, Object>>() { }); if (taskParameters != null) { if (taskParameters.containsKey("mainJar")) { Object mainJarObj = taskParameters.get("mainJar"); ResourceInfo mainJar = JSONUtils.parseObject( JSONUtils.toJsonString(mainJarObj), ResourceInfo.class); ResourceInfo resourceInfo = updateResourceInfo(taskDefinition.getId(), mainJar); if (resourceInfo != null) { taskParameters.put("mainJar", resourceInfo); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
if (taskParameters.containsKey("resourceList")) { String resourceListStr = JSONUtils.toJsonString(taskParameters.get("resourceList")); List<ResourceInfo> resourceInfos = JSONUtils.toList(resourceListStr, ResourceInfo.class); List<ResourceInfo> updatedResourceInfos = resourceInfos .stream() .map(resourceInfo -> updateResourceInfo(taskDefinition.getId(), resourceInfo)) .filter(Objects::nonNull) .collect(Collectors.toList()); taskParameters.put("resourceList", updatedResourceInfos); } taskDefinition.setTaskParams(JSONUtils.toJsonString(taskParameters)); } } /** * update {@link ResourceInfo} by given original ResourceInfo * * @param res origin resource info * @return {@link ResourceInfo} */ protected ResourceInfo updateResourceInfo(int task_id, ResourceInfo res) { ResourceInfo resourceInfo = null; if (res != null) { String resourceFullName = res.getResourceName(); if (StringUtils.isBlank(resourceFullName)) { logger.error("invalid resource full name, {}", resourceFullName); return new ResourceInfo(); } resourceInfo = new ResourceInfo();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
Integer resultList = resourceTaskMapper.existResourceByTaskIdNFullName(task_id, resourceFullName); if (resultList != null) { resourceInfo.setId(resultList); resourceInfo.setRes(res.getRes()); resourceInfo.setResourceName(resourceFullName); } if (logger.isInfoEnabled()) { logger.info("updated resource info {}", JSONUtils.toJsonString(resourceInfo)); } } return resourceInfo; } /** * get id list by task state * * @param instanceId instanceId * @param state state * @return task instance states */ @Override public List<Integer> findTaskIdByInstanceState(int instanceId, TaskExecutionStatus state) { return taskInstanceMapper.queryTaskByProcessIdAndState(instanceId, state.getCode()); } /** * delete work process map by parent process id * * @param parentWorkProcessId parentWorkProcessId * @return delete process map result
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
*/ @Override public int deleteWorkProcessMapByParentId(int parentWorkProcessId) { return processInstanceMapMapper.deleteByParentProcessId(parentWorkProcessId); } /** * find sub process instance * * @param parentProcessId parentProcessId * @param parentTaskId parentTaskId * @return process instance */ @Override public ProcessInstance findSubProcessInstance(Integer parentProcessId, Integer parentTaskId) { ProcessInstance processInstance = null; ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryByParentId(parentProcessId, parentTaskId); if (processInstanceMap == null || processInstanceMap.getProcessInstanceId() == 0) { return processInstance; } processInstance = findProcessInstanceById(processInstanceMap.getProcessInstanceId()); return processInstance; } /** * find parent process instance * * @param subProcessId subProcessId * @return process instance */ @Override public ProcessInstance findParentProcessInstance(Integer subProcessId) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
ProcessInstance processInstance = null; ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryBySubProcessId(subProcessId); if (processInstanceMap == null || processInstanceMap.getProcessInstanceId() == 0) { return processInstance; } processInstance = findProcessInstanceById(processInstanceMap.getParentProcessInstanceId()); return processInstance; } /** * for show in page of taskInstance */ @Override public void changeOutParam(TaskInstance taskInstance) { if (Strings.isNullOrEmpty(taskInstance.getVarPool())) { return; } List<Property> properties = JSONUtils.toList(taskInstance.getVarPool(), Property.class); if (CollectionUtils.isEmpty(properties)) { return; } Map<String, Object> taskParams = JSONUtils.parseObject(taskInstance.getTaskParams(), new TypeReference<Map<String, Object>>() { }); Object localParams = taskParams.get(LOCAL_PARAMS); if (localParams == null) { return; } List<Property> allParam = JSONUtils.toList(JSONUtils.toJsonString(localParams), Property.class); Map<String, String> outProperty = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
for (Property info : properties) { if (info.getDirect() == Direct.OUT) { outProperty.put(info.getProp(), info.getValue()); } } for (Property info : allParam) { if (info.getDirect() == Direct.OUT) { String paramName = info.getProp(); info.setValue(outProperty.get(paramName)); } } taskParams.put(LOCAL_PARAMS, allParam); taskInstance.setTaskParams(JSONUtils.toJsonString(taskParams)); } /** * convert integer list to string list * * @param intList intList * @return string list */ private List<String> convertIntListToString(List<Integer> intList) { if (intList == null) { return new ArrayList<>(); } List<String> result = new ArrayList<>(intList.size()); for (Integer intVar : intList) { result.add(String.valueOf(intVar)); } return result; }