diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkerGroupController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkerGroupController.java index be4ff00e1a..bd04868993 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkerGroupController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkerGroupController.java @@ -113,8 +113,8 @@ public class WorkerGroupController extends BaseController{ Map result = workerGroupService.queryAllGroupPaging(loginUser,pageNo, pageSize, searchVal); return returnDataListPaging(result); }catch (Exception e){ - logger.error(Status.SAVE_ERROR.getMsg(),e); - return error(Status.SAVE_ERROR.getCode(), Status.SAVE_ERROR.getMsg()); + logger.error(Status.QUERY_WORKER_GROUP_FAIL.getMsg(),e); + return error(Status.QUERY_WORKER_GROUP_FAIL.getCode(), Status.QUERY_WORKER_GROUP_FAIL.getMsg()); } } @@ -135,8 +135,8 @@ public class WorkerGroupController extends BaseController{ Map result = workerGroupService.queryAllGroup(); return returnDataList(result); }catch (Exception e){ - logger.error(Status.SAVE_ERROR.getMsg(),e); - return error(Status.SAVE_ERROR.getCode(), Status.SAVE_ERROR.getMsg()); + logger.error(Status.QUERY_WORKER_GROUP_FAIL.getMsg(),e); + return error(Status.QUERY_WORKER_GROUP_FAIL.getCode(), Status.QUERY_WORKER_GROUP_FAIL.getMsg()); } } @@ -163,8 +163,8 @@ public class WorkerGroupController extends BaseController{ Map result = workerGroupService.deleteWorkerGroupById(id); return returnDataList(result); }catch (Exception e){ - logger.error(Status.SAVE_ERROR.getMsg(),e); - return error(Status.SAVE_ERROR.getCode(), Status.SAVE_ERROR.getMsg()); + logger.error(Status.DELETE_WORKER_GROUP_FAIL.getMsg(),e); + return error(Status.DELETE_WORKER_GROUP_FAIL.getCode(), Status.DELETE_WORKER_GROUP_FAIL.getMsg()); } } } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java index 479f38d725..6978b2019a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java @@ -168,7 +168,11 @@ public enum Status { DELETE_TENANT_BY_ID_FAIL_DEFINES(100143,"delete tenant by id fail, for there are {0} process definitions using it"), DELETE_TENANT_BY_ID_FAIL_USERS(100144,"delete tenant by id fail, for there are {0} users using it"), - DELETE_WORKER_GROUP_BY_ID_FAIL(100143,"delete worker group by id fail, for there are {0} process instances in executing using it"), + DELETE_WORKER_GROUP_BY_ID_FAIL(100145,"delete worker group by id fail, for there are {0} process instances in executing using it"), + + QUERY_WORKER_GROUP_FAIL(100146,"query worker group fail "), + DELETE_WORKER_GROUP_FAIL(100147,"delete worker group fail "), + UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found"), UDF_FUNCTION_EXISTS(20002, "UDF function already exists"), diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java index 09954938d7..7514e3e282 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java @@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashMap; @@ -149,17 +150,18 @@ public class WorkerGroupService extends BaseService { * @param id * @return */ + @Transactional(rollbackFor = Exception.class) public Map deleteWorkerGroupById(Integer id) { Map result = new HashMap<>(5); - List processInstances = processInstanceMapper.queryByWorkerGroupIdAndStatus(id, org.apache.dolphinscheduler.common.Constants.NOT_TERMINATED_STATES); + List processInstances = processInstanceMapper.queryByWorkerGroupIdAndStatus(id, Constants.NOT_TERMINATED_STATES); if(CollectionUtils.isNotEmpty(processInstances)){ putMsg(result, Status.DELETE_WORKER_GROUP_BY_ID_FAIL, processInstances.size()); return result; } workerGroupMapper.deleteById(id); - processInstanceMapper.updateProcessInstanceByWorkerGroupId(id, org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_ID); + processInstanceMapper.updateProcessInstanceByWorkerGroupId(id, Constants.DEFAULT_WORKER_ID); putMsg(result, Status.SUCCESS); return result; }