ruanwenjun commented on code in PR #18293:
URL:
https://github.com/apache/dolphinscheduler/pull/18293#discussion_r3301604669
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectWorkerGroupRelationService.java:
##########
@@ -43,4 +44,22 @@ public interface ProjectWorkerGroupRelationService {
*/
List<ProjectWorkerGroup> queryAssignedWorkerGroupsByProject(User
loginUser, Long projectCode);
+ /**
+ * check if worker group is assigned to project
+ *
+ * @param projectCode project code
+ * @param workerGroup worker group name
+ * @return true if worker group is assigned to project
+ */
+ boolean isWorkerGroupAssignedToProject(Long projectCode, String
workerGroup);
+
+ /**
+ * validate worker groups are all assigned to project
+ *
+ * @param projectCode project code
+ * @param workerGroups worker group names to validate
+ * @throws ServiceException if any worker group is not assigned
+ */
+ void validateWorkerGroupsAssignedToProject(Long projectCode, List<String>
workerGroups);
Review Comment:
duplicated with `WorkerGroupValidator`
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:
##########
@@ -381,6 +389,23 @@ private List<TaskDefinitionLog>
generateTaskDefinitionList(String taskDefinition
}
}
+ /**
+ * Validate worker groups in task definitions
+ */
+ private void validateTaskWorkerGroups(long projectCode,
List<TaskDefinitionLog> taskDefinitionLogs) {
+ if (CollectionUtils.isEmpty(taskDefinitionLogs)) {
+ return;
+ }
+
+ List<String> workerGroups = taskDefinitionLogs.stream()
+ .map(TaskDefinitionLog::getWorkerGroup)
+ .filter(StringUtils::isNotEmpty)
+ .distinct()
+ .collect(Collectors.toList());
+
+
projectWorkerGroupRelationService.validateWorkerGroupsAssignedToProject(projectCode,
workerGroups);
+ }
Review Comment:
This kind of code should put into `WorkerGroupValidator`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]