Skip to content

Commit cea203a

Browse files
authored
Merge 00fe466 into 173a385
2 parents 173a385 + 00fe466 commit cea203a

42 files changed

Lines changed: 3246 additions & 74 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.dolphinscheduler.api.controller;
19+
20+
import static org.apache.dolphinscheduler.api.enums.Status.CLOSE_TASK_GROUP_ERROR;
21+
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_TASK_GROUP_ERROR;
22+
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_GROUP_LIST_ERROR;
23+
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_GROUP_QUEUE_LIST_ERROR;
24+
import static org.apache.dolphinscheduler.api.enums.Status.START_TASK_GROUP_ERROR;
25+
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_TASK_GROUP_ERROR;
26+
27+
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
28+
import org.apache.dolphinscheduler.api.exceptions.ApiException;
29+
import org.apache.dolphinscheduler.api.service.TaskGroupQueueService;
30+
import org.apache.dolphinscheduler.api.service.TaskGroupService;
31+
import org.apache.dolphinscheduler.api.utils.Result;
32+
import org.apache.dolphinscheduler.common.Constants;
33+
import org.apache.dolphinscheduler.dao.entity.User;
34+
35+
import java.util.Map;
36+
37+
import org.springframework.beans.factory.annotation.Autowired;
38+
import org.springframework.http.HttpStatus;
39+
import org.springframework.web.bind.annotation.GetMapping;
40+
import org.springframework.web.bind.annotation.PostMapping;
41+
import org.springframework.web.bind.annotation.RequestAttribute;
42+
import org.springframework.web.bind.annotation.RequestMapping;
43+
import org.springframework.web.bind.annotation.RequestParam;
44+
import org.springframework.web.bind.annotation.ResponseStatus;
45+
import org.springframework.web.bind.annotation.RestController;
46+
47+
import io.swagger.annotations.Api;
48+
import io.swagger.annotations.ApiImplicitParam;
49+
import io.swagger.annotations.ApiImplicitParams;
50+
import io.swagger.annotations.ApiOperation;
51+
import springfox.documentation.annotations.ApiIgnore;
52+
53+
54+
/**
55+
* task group controller
56+
*/
57+
@Api(tags = "task group")
58+
@RestController
59+
@RequestMapping("/task-group")
60+
public class TaskGroupController extends BaseController {
61+
62+
@Autowired
63+
private TaskGroupService taskGroupService;
64+
65+
/**
66+
* query task group list
67+
*
68+
* @param loginUser login user
69+
* @param name name
70+
* @param description description
71+
* @param groupSize group size
72+
* @param name project id
73+
* @return result and msg code
74+
*/
75+
@ApiOperation(value = "createTaskGroup", notes = "CREATE_TAKS_GROUP_NOTE")
76+
@ApiImplicitParams({
77+
@ApiImplicitParam(name = "name", value = "NAME", dataType = "String"),
78+
@ApiImplicitParam(name = "description", value = "DESCRIPTION", dataType = "String"),
79+
@ApiImplicitParam(name = "groupSize", value = "GROUPSIZE", dataType = "Int"),
80+
81+
})
82+
@PostMapping(value = "/create")
83+
@ResponseStatus(HttpStatus.CREATED)
84+
@ApiException(CREATE_TASK_GROUP_ERROR)
85+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
86+
public Result createTaskGroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
87+
@RequestParam("name") String name,
88+
@RequestParam("description") String description,
89+
@RequestParam("groupSize") Integer groupSize) {
90+
Map<String, Object> result = taskGroupService.createTaskGroup(loginUser, name, description, groupSize);
91+
return returnDataList(result);
92+
}
93+
94+
/**
95+
* update task group list
96+
*
97+
* @param loginUser login user
98+
* @param name name
99+
* @param description description
100+
* @param groupSize group size
101+
* @param name project id
102+
* @return result and msg code
103+
*/
104+
@ApiOperation(value = "updateTaskGroup", notes = "UPDATE_TAKS_GROUP_NOTE")
105+
@ApiImplicitParams({
106+
@ApiImplicitParam(name = "id", value = "id", dataType = "Int"),
107+
@ApiImplicitParam(name = "name", value = "NAME", dataType = "String"),
108+
@ApiImplicitParam(name = "description", value = "DESCRIPTION", dataType = "String"),
109+
@ApiImplicitParam(name = "groupSize", value = "GROUPSIZE", dataType = "Int"),
110+
111+
})
112+
@PostMapping(value = "/update")
113+
@ResponseStatus(HttpStatus.CREATED)
114+
@ApiException(UPDATE_TASK_GROUP_ERROR)
115+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
116+
public Result updateTaskGroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
117+
@RequestParam("id") Integer id,
118+
@RequestParam("name") String name,
119+
@RequestParam("description") String description,
120+
@RequestParam("groupSize") Integer groupSize) {
121+
Map<String, Object> result = taskGroupService.updateTaskGroup(loginUser, id, name, description, groupSize);
122+
return returnDataList(result);
123+
}
124+
125+
/**
126+
* query task group list paging
127+
*
128+
* @param loginUser login user
129+
* @param pageNo page number
130+
* @param pageSize page size
131+
* @return queue list
132+
*/
133+
@ApiOperation(value = "queryAllTaskGroup", notes = "QUERY_ALL_TASK_GROUP_NOTES")
134+
@ApiImplicitParams({
135+
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "1"),
136+
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "20")
137+
})
138+
@GetMapping(value = "/query-list-all")
139+
@ResponseStatus(HttpStatus.OK)
140+
@ApiException(QUERY_TASK_GROUP_LIST_ERROR)
141+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
142+
public Result queryAllTaskGroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
143+
@RequestParam("pageNo") Integer pageNo,
144+
@RequestParam("pageSize") Integer pageSize) {
145+
Map<String, Object> result = taskGroupService.queryAllTaskGroup(loginUser, pageNo, pageSize);
146+
return returnDataList(result);
147+
}
148+
149+
/**
150+
* query task group list paging
151+
*
152+
* @param loginUser login user
153+
* @param pageNo page number
154+
* @param status status
155+
* @param pageSize page size
156+
* @return queue list
157+
*/
158+
@ApiOperation(value = "queryTaskGroupByStatus", notes = "QUERY_TASK_GROUP_LIST_BY_STSATUS_NOTES")
159+
@ApiImplicitParams({
160+
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "1"),
161+
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "20"),
162+
@ApiImplicitParam(name = "status", value = "status", required = true, dataType = "Int")
163+
})
164+
@GetMapping(value = "/query-list-by-status")
165+
@ResponseStatus(HttpStatus.OK)
166+
@ApiException(QUERY_TASK_GROUP_LIST_ERROR)
167+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
168+
public Result queryTaskGroupByStatus(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
169+
@RequestParam("pageNo") Integer pageNo,
170+
@RequestParam(value = "status", required = false) Integer status,
171+
@RequestParam("pageSize") Integer pageSize) {
172+
Map<String, Object> result = taskGroupService.queryTaskGroupByStatus(loginUser, pageNo, pageSize, status);
173+
return returnDataList(result);
174+
}
175+
176+
/**
177+
* query task group list paging by project id
178+
*
179+
* @param loginUser login user
180+
* @param pageNo page number
181+
* @param name project id
182+
* @param pageSize page size
183+
* @return queue list
184+
*/
185+
@ApiOperation(value = "queryTaskGroupByName", notes = "QUERY_TASK_GROUP_LIST_BY_PROJECT_ID_NOTES")
186+
@ApiImplicitParams({
187+
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "1"),
188+
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "20"),
189+
@ApiImplicitParam(name = "name", value = "PROJECT_ID", required = true, dataType = "String")
190+
})
191+
@GetMapping(value = "/query-list-by-name")
192+
@ResponseStatus(HttpStatus.OK)
193+
@ApiException(QUERY_TASK_GROUP_LIST_ERROR)
194+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
195+
public Result queryTaskGroupByName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
196+
@RequestParam("pageNo") Integer pageNo,
197+
@RequestParam(value = "name", required = false) String name,
198+
@RequestParam("pageSize") Integer pageSize) {
199+
Map<String, Object> result = taskGroupService.queryTaskGroupByName(loginUser, pageNo, pageSize, name);
200+
return returnDataList(result);
201+
}
202+
203+
/**
204+
* close a task group
205+
*
206+
* @param loginUser login user
207+
* @param id id
208+
* @return result
209+
*/
210+
@ApiOperation(value = "closeTaskGroup", notes = "CLOSE_TASK_GROUP_NOTES")
211+
@ApiImplicitParams({
212+
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Int")
213+
})
214+
@PostMapping(value = "/close-task-group")
215+
@ResponseStatus(HttpStatus.CREATED)
216+
@ApiException(CLOSE_TASK_GROUP_ERROR)
217+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
218+
public Result closeTaskGroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
219+
@RequestParam(value = "id", required = false) Integer id) {
220+
221+
Map<String, Object> result = taskGroupService.closeTaskGroup(loginUser, id);
222+
return returnDataList(result);
223+
}
224+
225+
/**
226+
* start a task group
227+
*
228+
* @param loginUser login user
229+
* @param id id
230+
* @return result
231+
*/
232+
@ApiOperation(value = "startTaskGroup", notes = "START_TASK_GROUP_NOTES")
233+
@ApiImplicitParams({
234+
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Int")
235+
})
236+
@PostMapping(value = "/start-task-group")
237+
@ResponseStatus(HttpStatus.CREATED)
238+
@ApiException(START_TASK_GROUP_ERROR)
239+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
240+
public Result startTaskGroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
241+
@RequestParam(value = "id", required = false) Integer id) {
242+
Map<String, Object> result = taskGroupService.startTaskGroup(loginUser, id);
243+
return returnDataList(result);
244+
}
245+
246+
/**
247+
* force start task without task group
248+
*
249+
* @param loginUser login user
250+
* @param taskId task id
251+
* @return result
252+
*/
253+
@ApiOperation(value = "wakeCompulsively", notes = "WAKE_TASK_COMPULSIVELY_NOTES")
254+
@ApiImplicitParams({
255+
@ApiImplicitParam(name = "taskId", value = "TASKID", required = true, dataType = "Int")
256+
})
257+
@PostMapping(value = "/wake-task-compulsively")
258+
@ResponseStatus(HttpStatus.CREATED)
259+
@ApiException(START_TASK_GROUP_ERROR)
260+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
261+
public Result wakeCompulsively(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
262+
@RequestParam(value = "taskId") Integer taskId) {
263+
Map<String, Object> result = taskGroupService.wakeTaskcompulsively(loginUser, taskId);
264+
return returnDataList(result);
265+
}
266+
267+
@Autowired
268+
private TaskGroupQueueService taskGroupQueueService;
269+
270+
/**
271+
* query task group queue list paging
272+
*
273+
* @param loginUser login user
274+
* @param pageNo page number
275+
* @param pageSize page size
276+
* @return queue list
277+
*/
278+
@ApiOperation(value = "queryTasksByGroupId", notes = "QUERY_ALL_TASKS_NOTES")
279+
@ApiImplicitParams({
280+
@ApiImplicitParam(name = "groupId", value = "GROUP_ID", required = true, dataType = "Int", example = "1"),
281+
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "1"),
282+
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "20")
283+
})
284+
@GetMapping(value = "/query-list-by-group-id")
285+
@ResponseStatus(HttpStatus.OK)
286+
@ApiException(QUERY_TASK_GROUP_QUEUE_LIST_ERROR)
287+
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
288+
public Result queryTasksByGroupId(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
289+
@RequestParam("groupId") Integer groupId,
290+
@RequestParam("pageNo") Integer pageNo,
291+
@RequestParam("pageSize") Integer pageSize) {
292+
Map<String, Object> result = taskGroupQueueService.queryTasksByGroupId(loginUser, groupId, pageNo, pageSize);
293+
return returnDataList(result);
294+
}
295+
296+
}

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,26 @@ public enum Status {
340340
QUERY_ENVIRONMENT_BY_CODE_ERROR(1200009, "not found environment [{0}] ", "查询环境编码[{0}]不存在"),
341341
QUERY_ENVIRONMENT_ERROR(1200010, "login user query environment error", "分页查询环境列表错误"),
342342
VERIFY_ENVIRONMENT_ERROR(1200011, "verify environment error", "验证环境信息错误"),
343-
ENVIRONMENT_WORKER_GROUPS_IS_INVALID(1200012, "environment worker groups is invalid format", "环境关联的工作组参数解析错误"),
344-
UPDATE_ENVIRONMENT_WORKER_GROUP_RELATION_ERROR(1200013,"You can't modify the worker group, because the worker group [{0}] and this environment [{1}] already be used in the task [{2}]",
345-
"您不能修改工作组选项,因为该工作组 [{0}] 和 该环境 [{1}] 已经被用在任务 [{2}] 中");
346343

344+
TASK_GROUP_NAME_EXSIT(130001,"this task group name is repeated in a project","该任务组名称在一个项目中已经使用"),
345+
TASK_GROUP_SIZE_ERROR(130002,"task group size error","任务组大小应该为大于1的整数"),
346+
TASK_GROUP_STATUS_ERROR(130003,"task group status error","任务组已经被关闭"),
347+
TASK_GROUP_FULL(130004,"task group is full","任务组已经满了"),
348+
TASK_GROUP_USED_SIZE_ERROR(130005,"the used size number of task group is dirty","任务组使用的容量发生了变化"),
349+
TASK_GROUP_QUEUE_RELEASE_ERROR(130006,"relase task group queue failed","任务组资源释放时出现了错误"),
350+
TASK_GROUP_QUEUE_AWAKE_ERROR(130007,"awake waiting task failed","任务组使唤醒等待任务时发生了错误"),
351+
CREATE_TASK_GROUP_ERROR(130008,"create task group error","创建任务组错误"),
352+
UPDATE_TASK_GROUP_ERROR(130009,"update task group list error","更新任务组错误"),
353+
QUERY_TASK_GROUP_LIST_ERROR(130010,"query task group list error","查询任务组列表错误"),
354+
CLOSE_TASK_GROUP_ERROR(130011,"close task group error","关闭任务组错误"),
355+
START_TASK_GROUP_ERROR(130012,"start task group error","启动任务组错误"),
356+
QUERY_TASK_GROUP_QUEUE_LIST_ERROR(130013,"query task group queue list error","查询任务组队列列表错误"),
357+
TASK_GROUP_CACHE_START_FAILED(130014,"cache start failed","任务组相关的缓存启动失败"),
358+
ENVIRONMENT_WORKER_GROUPS_IS_INVALID(130015, "environment worker groups is invalid format", "环境关联的工作组参数解析错误"),
359+
UPDATE_ENVIRONMENT_WORKER_GROUP_RELATION_ERROR(130016,"You can't modify the worker group, because the worker group [{0}] and this environment [{1}] already be used in the task [{2}]",
360+
"您不能修改工作组选项,因为该工作组 [{0}] 和 该环境 [{1}] 已经被用在任务 [{2}] 中"),
361+
TASK_GROUP_QUEUE_ALREADY_START(130017, "task group queue already start", "节点已经获取任务组资源")
362+
;
347363

348364
private final int code;
349365
private final String enMsg;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.dolphinscheduler.api.service;
19+
20+
import org.apache.dolphinscheduler.dao.entity.User;
21+
22+
import java.util.Map;
23+
24+
/**
25+
* task group queue service
26+
*/
27+
public interface TaskGroupQueueService {
28+
29+
/**
30+
* query tasks in task group queue by group id
31+
* @param loginUser login user
32+
* @param groupId group id
33+
* @param pageNo page no
34+
* @param pageSize page size
35+
36+
* @return tasks list
37+
*/
38+
Map<String, Object> queryTasksByGroupId(User loginUser, int groupId, int pageNo,
39+
int pageSize);
40+
41+
/**
42+
* query tasks in task group queue by project id
43+
* @param loginUser login user
44+
* @param pageNo page no
45+
* @param pageSize page size
46+
* @param processId process id
47+
* @return tasks list
48+
*/
49+
Map<String, Object> queryTasksByProcessId(User loginUser, int pageNo,
50+
int pageSize, int processId);
51+
52+
/**
53+
* query all tasks in task group queue
54+
* @param loginUser login user
55+
* @param pageNo page no
56+
* @param pageSize page size
57+
* @return tasks list
58+
*/
59+
Map<String, Object> queryAllTasks(User loginUser, int pageNo, int pageSize);
60+
61+
/**
62+
* delete by task id
63+
* @param taskId task id
64+
* @return TaskGroupQueue entity
65+
*/
66+
boolean deleteByTaskId(int taskId);
67+
68+
void forceStartTask(int taskId,int forceStart);
69+
}

0 commit comments

Comments
 (0)