From 3548432ff69648d8949a92ab9a35265c23056503 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Tue, 16 Apr 2024 17:10:22 +0800 Subject: [PATCH 01/28] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BB=8E=20DS?= =?UTF-8?q?=20=E8=8E=B7=E5=8F=96=E4=BB=BB=E5=8A=A1=E7=BB=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dinky/controller/SchedulerController.java | 11 +++++++ .../org/dinky/service/SchedulerService.java | 7 ++++ .../service/impl/SchedulerServiceImpl.java | 16 ++++------ .../dinky/scheduler/client/TaskClient.java | 32 +++++++++++++++++++ .../org/dinky/scheduler/model/TaskGroup.java | 18 +++++++++++ .../dinky/scheduler/result/DsPageData.java | 10 ++++++ .../dinky/scheduler/result/DsPageInfo.java | 21 ++++++++++++ 7 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java create mode 100644 dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java create mode 100644 dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java diff --git a/dinky-admin/src/main/java/org/dinky/controller/SchedulerController.java b/dinky-admin/src/main/java/org/dinky/controller/SchedulerController.java index d60c549da9..9e6a882559 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/SchedulerController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/SchedulerController.java @@ -23,6 +23,7 @@ import org.dinky.data.result.Result; import org.dinky.scheduler.model.DinkyTaskRequest; import org.dinky.scheduler.model.TaskDefinition; +import org.dinky.scheduler.model.TaskGroup; import org.dinky.scheduler.model.TaskMainInfo; import org.dinky.service.SchedulerService; @@ -99,4 +100,14 @@ public Result createOrUpdateTaskDefinition(@RequestBody DinkyTaskRequest } return Result.succeed(Status.DS_ADD_TASK_DEFINITION_SUCCESS); } + + /** + * 获取任务组 + * @param projectCode + * @return + */ + @GetMapping(value = "/task/groups") + public Result> getTaskGroups(@RequestParam("projectCode") Long projectCode) { + return Result.succeed(schedulerService.getTaskGroupsFromDolphinScheduler(projectCode)); + } } diff --git a/dinky-admin/src/main/java/org/dinky/service/SchedulerService.java b/dinky-admin/src/main/java/org/dinky/service/SchedulerService.java index 54b04fc042..63b762e309 100644 --- a/dinky-admin/src/main/java/org/dinky/service/SchedulerService.java +++ b/dinky-admin/src/main/java/org/dinky/service/SchedulerService.java @@ -21,6 +21,7 @@ import org.dinky.scheduler.model.DinkyTaskRequest; import org.dinky.scheduler.model.TaskDefinition; +import org.dinky.scheduler.model.TaskGroup; import org.dinky.scheduler.model.TaskMainInfo; import java.util.List; @@ -61,4 +62,10 @@ public interface SchedulerService { * @return the task definition information */ TaskDefinition getTaskDefinitionInfo(long dinkyTaskId); + /** + * Get the task groups from DolphinScheduler + * @param projectCode + * @return + */ + List getTaskGroupsFromDolphinScheduler(long projectCode); } diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java index 5d751cf66d..35b5c2f888 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java @@ -28,16 +28,7 @@ import org.dinky.scheduler.client.TaskClient; import org.dinky.scheduler.enums.ReleaseState; import org.dinky.scheduler.exception.SchedulerException; -import org.dinky.scheduler.model.DagData; -import org.dinky.scheduler.model.DagNodeLocation; -import org.dinky.scheduler.model.DinkyTaskParams; -import org.dinky.scheduler.model.DinkyTaskRequest; -import org.dinky.scheduler.model.ProcessDefinition; -import org.dinky.scheduler.model.ProcessTaskRelation; -import org.dinky.scheduler.model.Project; -import org.dinky.scheduler.model.TaskDefinition; -import org.dinky.scheduler.model.TaskMainInfo; -import org.dinky.scheduler.model.TaskRequest; +import org.dinky.scheduler.model.*; import org.dinky.service.CatalogueService; import org.dinky.service.SchedulerService; import org.dinky.utils.JsonUtils; @@ -353,6 +344,11 @@ public TaskDefinition getTaskDefinitionInfo(long dinkyTaskId) { return taskDefinition; } + @Override + public List getTaskGroupsFromDolphinScheduler(long projectCode) { + return taskClient.getTaskGroupList(projectCode); + } + /** * Retrieves the dinky names from the given catalogue and index. * diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java index 49893659a6..45b63cf8df 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java @@ -19,12 +19,15 @@ package org.dinky.scheduler.client; +import com.fasterxml.jackson.core.JsonProcessingException; import org.dinky.data.model.SystemConfiguration; import org.dinky.scheduler.constant.Constants; import org.dinky.scheduler.exception.SchedulerException; import org.dinky.scheduler.model.TaskDefinition; import org.dinky.scheduler.model.TaskDefinitionLog; +import org.dinky.scheduler.model.TaskGroup; import org.dinky.scheduler.model.TaskMainInfo; +import org.dinky.scheduler.result.DsPageInfo; import org.dinky.scheduler.result.PageInfo; import org.dinky.scheduler.result.Result; import org.dinky.scheduler.utils.MyJSONUtil; @@ -36,6 +39,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -263,4 +267,32 @@ public Long genTaskCode(Long projectCode) { } return codes.get(0); } + + /** + * 通过 projectCode 获得 DolphinScheduler 任务组列表 + * @param projectCode + * @return + */ + public List getTaskGroupList(Long projectCode) { + String url = SystemConfiguration.getInstances().getDolphinschedulerUrl().getValue() + + "/task-group/query-list-by-projectCode"; + Map params = new HashMap<>(); + params.put("projectCode", projectCode); + params.put("pageNo", 1); + params.put("pageSize", 100); + String content = HttpRequest.get(url) + .header( + Constants.TOKEN, + SystemConfiguration.getInstances() + .getDolphinschedulerToken() + .getValue() + ) + .form(params) + .timeout(5000) + .execute() + .body(); + System.out.println(content); + List jsonObjects = MyJSONUtil.toBean(content, DsPageInfo.class).getData().getTotalList(); + return jsonObjects.stream().map(jsonObject->MyJSONUtil.toBean(jsonObject, TaskGroup.class)).collect(Collectors.toList()); + } } diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java new file mode 100644 index 0000000000..5522825c8b --- /dev/null +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java @@ -0,0 +1,18 @@ +package org.dinky.scheduler.model; + +import lombok.Data; + +import java.util.Date; +@Data +public class TaskGroup { + private Integer id; + private String name; + private Long projectCode; + private String description; + private Integer groupSize; + private Integer useSize; + private Integer userId; + private String status; + private Date createTime; + private Date updateTime; +} diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java new file mode 100644 index 0000000000..2dca479bda --- /dev/null +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java @@ -0,0 +1,10 @@ +package org.dinky.scheduler.result; + +import lombok.Data; + +import java.util.List; + +@Data +public class DsPageData { + private List totalList; +} diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java new file mode 100644 index 0000000000..cc872f1060 --- /dev/null +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java @@ -0,0 +1,21 @@ +package org.dinky.scheduler.result; + +import lombok.Data; + +import java.util.List; + +@Data +public class DsPageInfo { + /** total */ + private DsPageData data; + private Integer total = 0; + /** total Page */ + private Integer totalPage; + /** page size */ + private Integer pageSize = 20; + /** current page */ + private Integer currentPage = 0; + /** pageNo */ + private Integer pageNo; + +} \ No newline at end of file From 8b937762f05d94b3438adef695a716bffb31d890 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 17 Apr 2024 13:10:48 +0800 Subject: [PATCH 02/28] =?UTF-8?q?feat:=20=E8=B0=83=E7=94=A8=20DolphinSched?= =?UTF-8?q?uler=20=E6=8E=A5=E5=8F=A3=20ProcessClient.createOrUpdateProcess?= =?UTF-8?q?Definition=E3=80=81TaskClient.createTaskDefinition=20=E4=BC=A0?= =?UTF-8?q?=E5=85=A5=20taskGroupId=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/dinky/service/impl/SchedulerServiceImpl.java | 2 ++ .../src/main/java/org/dinky/scheduler/model/TaskRequest.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java index 35b5c2f888..1e5a08e42b 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java @@ -101,6 +101,7 @@ public boolean pushAddTask(DinkyTaskRequest dinkyTaskRequest) { taskRequest.setTimeoutFlag(dinkyTaskRequest.getTimeoutFlag()); taskRequest.setFlag(dinkyTaskRequest.getFlag()); taskRequest.setIsCache(dinkyTaskRequest.getIsCache()); + taskRequest.setTaskGroupId(dinkyTaskRequest.getTaskGroupId()); JSONObject jsonObject = JSONUtil.parseObj(taskRequest); JSONArray taskArray = new JSONArray(); taskArray.set(jsonObject); @@ -147,6 +148,7 @@ public boolean pushAddTask(DinkyTaskRequest dinkyTaskRequest) { taskRequest.setTimeoutFlag(dinkyTaskRequest.getTimeoutFlag()); taskRequest.setFlag(dinkyTaskRequest.getFlag()); taskRequest.setIsCache(dinkyTaskRequest.getIsCache()); + taskRequest.setTaskGroupId(dinkyTaskRequest.getTaskGroupId()); String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest); taskClient.createTaskDefinition( diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java index 5310b5f2b4..b389421b7c 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java @@ -66,6 +66,9 @@ public class TaskRequest { @ApiModelProperty(value = "任务类型 默认DINKY") private String taskType = "DINKY"; + @ApiModelProperty(value = "任务组 ID") + private Long taskGroupId; + @ApiModelProperty(value = "超时时间(分钟)") private Integer timeout; From 5cfc1dd07b23b82f186b5c966a1fc9fc6c45c0e5 Mon Sep 17 00:00:00 2001 From: guohuayu Date: Tue, 16 Apr 2024 10:10:25 +0800 Subject: [PATCH 03/28] =?UTF-8?q?feat:=20=E6=B3=A8=E5=86=8C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=BB=84=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dinky-web/src/locales/en-US/pages.ts | 1 + dinky-web/src/locales/zh-CN/pages.ts | 1 + .../HeaderContainer/PushDolphin/index.tsx | 32 +++++++------------ .../DataStudio/HeaderContainer/index.tsx | 32 ++++++++++++++----- dinky-web/src/services/endpoints.tsx | 2 ++ dinky-web/src/types/Studio/data.d.ts | 6 ++++ 6 files changed, 45 insertions(+), 29 deletions(-) diff --git a/dinky-web/src/locales/en-US/pages.ts b/dinky-web/src/locales/en-US/pages.ts index 5a47c9c528..a80f72b4fc 100644 --- a/dinky-web/src/locales/en-US/pages.ts +++ b/dinky-web/src/locales/en-US/pages.ts @@ -95,6 +95,7 @@ export default { 'datastudio.middle.qg.udf': 'UDF', 'datastudio.header.pushdolphin.title': 'Push task [ {name} ] to DolphinScheduler', 'datastudio.header.pushdolphin.taskId': 'Dinky task encoding', + 'datastudio.header.pushdolphin.taskGroup': 'Task Group', 'datastudio.header.pushdolphin.taskName': 'Task name: {name}', 'datastudio.header.pushdolphin.taskNameExt': 'Task type: {type} Process definition: {processDefinitionName}', diff --git a/dinky-web/src/locales/zh-CN/pages.ts b/dinky-web/src/locales/zh-CN/pages.ts index e73a5f7656..c45d3e14b9 100644 --- a/dinky-web/src/locales/zh-CN/pages.ts +++ b/dinky-web/src/locales/zh-CN/pages.ts @@ -90,6 +90,7 @@ export default { 'datastudio.middle.qg.udf': 'UDF', 'datastudio.header.pushdolphin.title': '将任务 [ {name} ] 推送至 DolphinScheduler', 'datastudio.header.pushdolphin.taskId': 'Dinky任务编码', + 'datastudio.header.pushdolphin.taskGroup': '任务组', 'datastudio.header.pushdolphin.taskName': 'Task名称: {name}', 'datastudio.header.pushdolphin.taskNameExt': 'Task类型: {type} 所属进程定义: {processDefinitionName}', diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx index 6819b6e5d4..fb4eb78cb6 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx @@ -1,22 +1,3 @@ -/* - * - * 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. - * - */ - import { FormContextValue } from '@/components/Context/FormContext'; import { NORMAL_MODAL_OPTIONS, SWITCH_OPTIONS } from '@/services/constants'; import { l } from '@/utils/intl'; @@ -40,6 +21,7 @@ import { TaskDataType } from '@/pages/DataStudio/model'; import { DolphinTaskDefinition, DolphinTaskMinInfo, + DolphinTaskGroupInfo, PushDolphinParams } from '@/types/Studio/data.d'; import { InitPushDolphinParams } from '@/types/Studio/init.d'; @@ -50,6 +32,7 @@ import React from 'react'; type PushDolphinProps = { onCancel: () => void; dolphinTaskList: DolphinTaskMinInfo[]; + dolphinTaskGroup:DolphinTaskGroupInfo[], dolphinDefinitionTask: Partial; modalVisible: boolean; currentDinkyTaskValue: Partial; @@ -64,10 +47,12 @@ export const PushDolphin: React.FC = (props) => { modalVisible, dolphinTaskList, dolphinDefinitionTask, + dolphinTaskGroup, currentDinkyTaskValue, loading } = props; - + console.log('我获取到了,0',dolphinTaskList,dolphinTaskGroup); + const [formValues, setFormValues] = React.useState( transformPushDolphinParams( dolphinDefinitionTask as DolphinTaskDefinition, @@ -184,7 +169,12 @@ export const PushDolphin: React.FC = (props) => { width={'sm'} options={PriorityList} /> - + { buttonLoading: boolean; confirmLoading: boolean; dolphinTaskList: DolphinTaskMinInfo[]; + dolphinTaskGroup:DolphinTaskGroupInfo[], dolphinDefinitionTask: Partial; currentDinkyTaskValue: Partial; }>({ @@ -110,6 +111,7 @@ const HeaderContainer = (props: connect) => { buttonLoading: false, confirmLoading: false, dolphinTaskList: [], + dolphinTaskGroup:[], dolphinDefinitionTask: {}, currentDinkyTaskValue: {} }); @@ -133,12 +135,22 @@ const HeaderContainer = (props: connect) => { dinkyTaskId } ); + let dolphinTaskGroup:any =[] + // : DolphinTaskGroupInfo[] | undefined = await queryDataByParams< + // DolphinTaskGroupInfo[] + // >(API_CONSTANTS.SCHEDULER_QUERY_TASK_GROUP, { dinkyTaskId }); + dolphinTaskGroup=[{ label: '嗨', + value: 'HIGH', + key: 'HIGH'}] + console.log(44444,dolphinTaskGroup); + setPushDolphinState((prevState) => ({ ...prevState, buttonLoading: true, confirmLoading: false, modalVisible: true, dolphinTaskList: dolphinTaskList ?? [], + dolphinTaskGroup:dolphinTaskGroup??[], dolphinDefinitionTask: dolphinTaskDefinition ?? {}, currentDinkyTaskValue: currentData as TaskDataType })); @@ -150,6 +162,7 @@ const HeaderContainer = (props: connect) => { modalVisible: false, buttonLoading: false, dolphinTaskList: [], + dolphinTaskGroup:[], confirmLoading: false, dolphinDefinitionTask: {}, currentDinkyTaskValue: {} @@ -502,13 +515,15 @@ const HeaderContainer = (props: connect) => { }; const handlePushDolphinSubmit = async (value: DolphinTaskDefinition) => { - setPushDolphinState((prevState) => ({ ...prevState, loading: true })); - await handleOption( - API_CONSTANTS.SCHEDULER_CREATE_OR_UPDATE_TASK_DEFINITION, - `推送任务[${currentData?.name}]至 DolphinScheduler`, - value - ); - await handlePushDolphinCancel(); + console.log('提交按钮',value); + + // setPushDolphinState((prevState) => ({ ...prevState, loading: true })); + // await handleOption( + // API_CONSTANTS.SCHEDULER_CREATE_OR_UPDATE_TASK_DEFINITION, + // `推送任务[${currentData?.name}]至 DolphinScheduler`, + // value + // ); + // await handlePushDolphinCancel(); }; /** @@ -527,6 +542,7 @@ const HeaderContainer = (props: connect) => { loading={pushDolphinState.confirmLoading} dolphinDefinitionTask={pushDolphinState.dolphinDefinitionTask} dolphinTaskList={pushDolphinState.dolphinTaskList} + dolphinTaskGroup={pushDolphinState.dolphinTaskGroup} onSubmit={(values) => handlePushDolphinSubmit(values)} /> )} diff --git a/dinky-web/src/services/endpoints.tsx b/dinky-web/src/services/endpoints.tsx index 6da038dcd8..8d37dc1dfe 100644 --- a/dinky-web/src/services/endpoints.tsx +++ b/dinky-web/src/services/endpoints.tsx @@ -278,6 +278,8 @@ export enum API_CONSTANTS { // ------------------------------------ scheduler ------------------------------------ SCHEDULER_QUERY_UPSTREAM_TASKS = '/api/scheduler/queryUpstreamTasks', SCHEDULER_QUERY_TASK_DEFINITION = '/api/scheduler/queryTaskDefinition', + SCHEDULER_QUERY_TASK_GROUP = '/api/scheduler/XXXX', + SCHEDULER_CREATE_OR_UPDATE_TASK_DEFINITION = '/api/scheduler/createOrUpdateTaskDefinition', // ------------------------------------ flink conf about ------------------------------------ diff --git a/dinky-web/src/types/Studio/data.d.ts b/dinky-web/src/types/Studio/data.d.ts index 6edeb14df1..8524773d15 100644 --- a/dinky-web/src/types/Studio/data.d.ts +++ b/dinky-web/src/types/Studio/data.d.ts @@ -250,6 +250,12 @@ export interface DolphinTaskMinInfo { upstreamTaskName: string; } +export interface DolphinTaskGroupInfo { + label:string, + value: string, + key: string +} + export interface TaskParamProperty { prop: string; direct: string; From 195a61027453c2d74f010352563e4ce7f6fddac3 Mon Sep 17 00:00:00 2001 From: guohuayu Date: Wed, 17 Apr 2024 10:30:01 +0800 Subject: [PATCH 04/28] =?UTF-8?q?feat=EF=BC=9A=20=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=BB=84=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HeaderContainer/PushDolphin/index.tsx | 6 +++- .../DataStudio/HeaderContainer/index.tsx | 31 ++++++++++--------- dinky-web/src/services/BusinessCrud.ts | 1 + dinky-web/src/services/endpoints.tsx | 2 +- dinky-web/src/types/Studio/data.d.ts | 13 ++++++-- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx index fb4eb78cb6..640a182768 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx @@ -171,9 +171,13 @@ export const PushDolphin: React.FC = (props) => { /> { dinkyTaskId } ); - let dolphinTaskGroup:any =[] - // : DolphinTaskGroupInfo[] | undefined = await queryDataByParams< - // DolphinTaskGroupInfo[] - // >(API_CONSTANTS.SCHEDULER_QUERY_TASK_GROUP, { dinkyTaskId }); - dolphinTaskGroup=[{ label: '嗨', - value: 'HIGH', - key: 'HIGH'}] - console.log(44444,dolphinTaskGroup); + + + let dolphinTaskGroup : DolphinTaskGroupInfo[] | undefined = await queryDataByParams< + DolphinTaskGroupInfo[] + >(API_CONSTANTS.SCHEDULER_QUERY_TASK_GROUP, { projectCode:dolphinTaskDefinition.projectCode }); + + + // dolphinTaskGroup=[{ name: '嗨',id: 66666 }] + // console.log(44444,dolphinTaskGroup); setPushDolphinState((prevState) => ({ ...prevState, @@ -517,13 +518,13 @@ const HeaderContainer = (props: connect) => { const handlePushDolphinSubmit = async (value: DolphinTaskDefinition) => { console.log('提交按钮',value); - // setPushDolphinState((prevState) => ({ ...prevState, loading: true })); - // await handleOption( - // API_CONSTANTS.SCHEDULER_CREATE_OR_UPDATE_TASK_DEFINITION, - // `推送任务[${currentData?.name}]至 DolphinScheduler`, - // value - // ); - // await handlePushDolphinCancel(); + setPushDolphinState((prevState) => ({ ...prevState, loading: true })); + await handleOption( + API_CONSTANTS.SCHEDULER_CREATE_OR_UPDATE_TASK_DEFINITION, + `推送任务[${currentData?.name}]至 DolphinScheduler`, + value + ); + await handlePushDolphinCancel(); }; /** diff --git a/dinky-web/src/services/BusinessCrud.ts b/dinky-web/src/services/BusinessCrud.ts index c2c3002230..1f5fd61865 100644 --- a/dinky-web/src/services/BusinessCrud.ts +++ b/dinky-web/src/services/BusinessCrud.ts @@ -207,6 +207,7 @@ export const handleOption = async ( afterCallBack?: () => void ) => { await LoadingMessageAsync(l('app.request.running') + title); + try { const result = await postAll(url, param); if (result.code === RESPONSE_CODE.SUCCESS) { diff --git a/dinky-web/src/services/endpoints.tsx b/dinky-web/src/services/endpoints.tsx index 8d37dc1dfe..65d5458bf5 100644 --- a/dinky-web/src/services/endpoints.tsx +++ b/dinky-web/src/services/endpoints.tsx @@ -278,7 +278,7 @@ export enum API_CONSTANTS { // ------------------------------------ scheduler ------------------------------------ SCHEDULER_QUERY_UPSTREAM_TASKS = '/api/scheduler/queryUpstreamTasks', SCHEDULER_QUERY_TASK_DEFINITION = '/api/scheduler/queryTaskDefinition', - SCHEDULER_QUERY_TASK_GROUP = '/api/scheduler/XXXX', + SCHEDULER_QUERY_TASK_GROUP = '/api/scheduler/task/groups', SCHEDULER_CREATE_OR_UPDATE_TASK_DEFINITION = '/api/scheduler/createOrUpdateTaskDefinition', diff --git a/dinky-web/src/types/Studio/data.d.ts b/dinky-web/src/types/Studio/data.d.ts index 8524773d15..5919e70d37 100644 --- a/dinky-web/src/types/Studio/data.d.ts +++ b/dinky-web/src/types/Studio/data.d.ts @@ -251,9 +251,16 @@ export interface DolphinTaskMinInfo { } export interface DolphinTaskGroupInfo { - label:string, - value: string, - key: string + id: number; + name: string; + description: string; + groupSize: number; + useSize: number; + userId: number; + status: number; + createTime: Date; + updateTime: Date; + projectCode: number; } export interface TaskParamProperty { From ceab412d61642ca06117b74bfdd855a368900416 Mon Sep 17 00:00:00 2001 From: guohuayu Date: Thu, 18 Apr 2024 09:08:24 +0800 Subject: [PATCH 05/28] =?UTF-8?q?fix:dinky=E6=8E=A8=E9=80=81=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=AD=97=E6=AE=B5dolphinTaskDefinition=E5=81=9A?= =?UTF-8?q?=E9=9D=9E=E7=A9=BA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx index 124c83bf60..75a6f36b5f 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx @@ -139,7 +139,7 @@ const HeaderContainer = (props: connect) => { let dolphinTaskGroup : DolphinTaskGroupInfo[] | undefined = await queryDataByParams< DolphinTaskGroupInfo[] - >(API_CONSTANTS.SCHEDULER_QUERY_TASK_GROUP, { projectCode:dolphinTaskDefinition.projectCode }); + >(API_CONSTANTS.SCHEDULER_QUERY_TASK_GROUP, { projectCode:dolphinTaskDefinition?.projectCode || undefined }); // dolphinTaskGroup=[{ name: '嗨',id: 66666 }] From bafce4a4da96a03d6ecdddddf0bc24dbe665d751 Mon Sep 17 00:00:00 2001 From: guohuayu Date: Mon, 22 Apr 2024 10:52:38 +0800 Subject: [PATCH 06/28] =?UTF-8?q?feat:=20dinky-=E4=BB=BB=E5=8A=A1=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=A2=9E=E5=8A=A0=E5=9B=9E=E6=98=BE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HeaderContainer/PushDolphin/function.tsx | 3 +- .../HeaderContainer/PushDolphin/index.tsx | 35 ++++++++++++++++--- .../DataStudio/HeaderContainer/index.tsx | 17 +++++---- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx index 91b3b4c215..f7114b2515 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx @@ -23,7 +23,8 @@ export const transformPushDolphinParams = ( dolphinTaskDefinition: DolphinTaskDefinition, pushDolphinParams: PushDolphinParams, toFormValues: boolean -) => { +) => { + if (toFormValues && dolphinTaskDefinition) { const transformValue: PushDolphinParams = { ...pushDolphinParams, diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx index 640a182768..6442b3e5d8 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx @@ -1,3 +1,21 @@ +/* + * + * 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. + * + */ import { FormContextValue } from '@/components/Context/FormContext'; import { NORMAL_MODAL_OPTIONS, SWITCH_OPTIONS } from '@/services/constants'; import { l } from '@/utils/intl'; @@ -27,7 +45,7 @@ import { import { InitPushDolphinParams } from '@/types/Studio/init.d'; import { Button, Form, Tag } from 'antd'; import { DefaultOptionType } from 'antd/es/select'; -import React from 'react'; +import React, { useEffect } from 'react'; type PushDolphinProps = { onCancel: () => void; @@ -38,6 +56,7 @@ type PushDolphinProps = { currentDinkyTaskValue: Partial; loading: boolean; onSubmit: (values: DolphinTaskDefinition) => void; + formValuesInfo:DolphinTaskDefinition }; export const PushDolphin: React.FC = (props) => { @@ -49,9 +68,10 @@ export const PushDolphin: React.FC = (props) => { dolphinDefinitionTask, dolphinTaskGroup, currentDinkyTaskValue, - loading + loading, + formValuesInfo } = props; - console.log('我获取到了,0',dolphinTaskList,dolphinTaskGroup); + const [formValues, setFormValues] = React.useState( transformPushDolphinParams( @@ -60,7 +80,14 @@ export const PushDolphin: React.FC = (props) => { true ) as PushDolphinParams ); - + useEffect(()=>{ + if (JSON.stringify(formValuesInfo)!='{}') { + const isWARN= formValuesInfo?.timeoutNotifyStrategy?.includes('WARN')?'WARN':false + const isFAILED=formValuesInfo?.timeoutNotifyStrategy?.includes('FAILED')?'FAILED':false + const temp:any = {...formValuesInfo,timeoutNotifyStrategy:[isWARN,isFAILED].filter(item=>item),} + form.setFieldsValue(temp) + } + },[]) /** * init form */ diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx index 75a6f36b5f..634fef8da5 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx @@ -16,7 +16,6 @@ * limitations under the License. * */ - import { LoadingBtn } from '@/components/CallBackButton/LoadingBtn'; import { PushpinIcon } from '@/components/Icons/CustomIcons'; import { FlexCenterDiv } from '@/components/StyledComponents'; @@ -106,6 +105,7 @@ const HeaderContainer = (props: connect) => { dolphinTaskGroup:DolphinTaskGroupInfo[], dolphinDefinitionTask: Partial; currentDinkyTaskValue: Partial; + formValuesInfo:any }>({ modalVisible: false, buttonLoading: false, @@ -113,7 +113,8 @@ const HeaderContainer = (props: connect) => { dolphinTaskList: [], dolphinTaskGroup:[], dolphinDefinitionTask: {}, - currentDinkyTaskValue: {} + currentDinkyTaskValue: {}, + formValuesInfo:{} }); useEffect(() => { @@ -141,9 +142,8 @@ const HeaderContainer = (props: connect) => { DolphinTaskGroupInfo[] >(API_CONSTANTS.SCHEDULER_QUERY_TASK_GROUP, { projectCode:dolphinTaskDefinition?.projectCode || undefined }); + const formValuesInfo=dolphinTaskDefinition?JSON.parse(JSON.stringify(dolphinTaskDefinition)):{} - // dolphinTaskGroup=[{ name: '嗨',id: 66666 }] - // console.log(44444,dolphinTaskGroup); setPushDolphinState((prevState) => ({ ...prevState, @@ -153,7 +153,8 @@ const HeaderContainer = (props: connect) => { dolphinTaskList: dolphinTaskList ?? [], dolphinTaskGroup:dolphinTaskGroup??[], dolphinDefinitionTask: dolphinTaskDefinition ?? {}, - currentDinkyTaskValue: currentData as TaskDataType + currentDinkyTaskValue: currentData as TaskDataType, + formValuesInfo:formValuesInfo??{} })); }; @@ -166,7 +167,8 @@ const HeaderContainer = (props: connect) => { dolphinTaskGroup:[], confirmLoading: false, dolphinDefinitionTask: {}, - currentDinkyTaskValue: {} + currentDinkyTaskValue: {}, + formValuesInfo:{} })); }; @@ -516,7 +518,7 @@ const HeaderContainer = (props: connect) => { }; const handlePushDolphinSubmit = async (value: DolphinTaskDefinition) => { - console.log('提交按钮',value); + setPushDolphinState((prevState) => ({ ...prevState, loading: true })); await handleOption( @@ -545,6 +547,7 @@ const HeaderContainer = (props: connect) => { dolphinTaskList={pushDolphinState.dolphinTaskList} dolphinTaskGroup={pushDolphinState.dolphinTaskGroup} onSubmit={(values) => handlePushDolphinSubmit(values)} + formValuesInfo={pushDolphinState.formValuesInfo} /> )} From a59d96531357c650205411fc6a93ae1441981f7c Mon Sep 17 00:00:00 2001 From: guohuayu Date: Tue, 23 Apr 2024 18:35:20 +0800 Subject: [PATCH 07/28] chore: resolve conflict caused by cherry-pick --- .../HeaderContainer/PushDolphin/index.tsx | 31 ++++++++------ .../DataStudio/HeaderContainer/index.tsx | 41 +++++++++++-------- dinky-web/src/pages/Other/Login/index.tsx | 2 + 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx index 6442b3e5d8..592fb738eb 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx @@ -38,8 +38,8 @@ import { transformPushDolphinParams } from '@/pages/DataStudio/HeaderContainer/P import { TaskDataType } from '@/pages/DataStudio/model'; import { DolphinTaskDefinition, - DolphinTaskMinInfo, DolphinTaskGroupInfo, + DolphinTaskMinInfo, PushDolphinParams } from '@/types/Studio/data.d'; import { InitPushDolphinParams } from '@/types/Studio/init.d'; @@ -50,13 +50,13 @@ import React, { useEffect } from 'react'; type PushDolphinProps = { onCancel: () => void; dolphinTaskList: DolphinTaskMinInfo[]; - dolphinTaskGroup:DolphinTaskGroupInfo[], + dolphinTaskGroup: DolphinTaskGroupInfo[]; dolphinDefinitionTask: Partial; modalVisible: boolean; currentDinkyTaskValue: Partial; loading: boolean; onSubmit: (values: DolphinTaskDefinition) => void; - formValuesInfo:DolphinTaskDefinition + formValuesInfo: DolphinTaskDefinition; }; export const PushDolphin: React.FC = (props) => { @@ -72,7 +72,6 @@ export const PushDolphin: React.FC = (props) => { formValuesInfo } = props; - const [formValues, setFormValues] = React.useState( transformPushDolphinParams( dolphinDefinitionTask as DolphinTaskDefinition, @@ -80,14 +79,21 @@ export const PushDolphin: React.FC = (props) => { true ) as PushDolphinParams ); - useEffect(()=>{ - if (JSON.stringify(formValuesInfo)!='{}') { - const isWARN= formValuesInfo?.timeoutNotifyStrategy?.includes('WARN')?'WARN':false - const isFAILED=formValuesInfo?.timeoutNotifyStrategy?.includes('FAILED')?'FAILED':false - const temp:any = {...formValuesInfo,timeoutNotifyStrategy:[isWARN,isFAILED].filter(item=>item),} - form.setFieldsValue(temp) + useEffect(() => { + if (JSON.stringify(formValuesInfo) != '{}') { + const isWARN = formValuesInfo?.timeoutNotifyStrategy?.includes('WARN') ? 'WARN' : false; + const isFAILED = formValuesInfo?.timeoutNotifyStrategy?.includes('FAILED') ? 'FAILED' : false; + + const temp: any = { + ...formValuesInfo, + flag: formValuesInfo.flag == 'NO' ? false : true, + timeoutFlag: formValuesInfo.timeoutFlag == 'CLOSE' ? false : true, + isCache: formValuesInfo.isCache == 'YES' ? true : false, + timeoutNotifyStrategy: [isWARN, isFAILED].filter((item) => item) + }; + form.setFieldsValue(temp); } - },[]) + }, []); /** * init form */ @@ -121,6 +127,7 @@ export const PushDolphin: React.FC = (props) => { formValues, false ) as DolphinTaskDefinition; + onSubmit(transformPushDolphinParamsValue); handleCancel(); }; @@ -202,7 +209,7 @@ export const PushDolphin: React.FC = (props) => { width={'sm'} options={dolphinTaskGroup} fieldProps={{ - fieldNames: {label:'name', value: 'id' } + fieldNames: { label: 'name', value: 'id' } }} // fieldNames={label:'label', value: 'value'} /> diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx index 634fef8da5..32b510f8a7 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx @@ -53,7 +53,12 @@ import { handleOption, handlePutDataJson, queryDataByParams } from '@/services/B import { DIALECT } from '@/services/constants'; import { API_CONSTANTS } from '@/services/endpoints'; import { Jobs } from '@/types/DevOps/data.d'; -import { ButtonRoute, DolphinTaskDefinition, DolphinTaskMinInfo,DolphinTaskGroupInfo } from '@/types/Studio/data.d'; +import { + ButtonRoute, + DolphinTaskDefinition, + DolphinTaskGroupInfo, + DolphinTaskMinInfo +} from '@/types/Studio/data.d'; import { l } from '@/utils/intl'; import { ApartmentOutlined, @@ -102,19 +107,19 @@ const HeaderContainer = (props: connect) => { buttonLoading: boolean; confirmLoading: boolean; dolphinTaskList: DolphinTaskMinInfo[]; - dolphinTaskGroup:DolphinTaskGroupInfo[], + dolphinTaskGroup: DolphinTaskGroupInfo[]; dolphinDefinitionTask: Partial; currentDinkyTaskValue: Partial; - formValuesInfo:any + formValuesInfo: any; }>({ modalVisible: false, buttonLoading: false, confirmLoading: false, dolphinTaskList: [], - dolphinTaskGroup:[], + dolphinTaskGroup: [], dolphinDefinitionTask: {}, currentDinkyTaskValue: {}, - formValuesInfo:{} + formValuesInfo: {} }); useEffect(() => { @@ -136,25 +141,27 @@ const HeaderContainer = (props: connect) => { dinkyTaskId } ); - - - let dolphinTaskGroup : DolphinTaskGroupInfo[] | undefined = await queryDataByParams< + + let dolphinTaskGroup: DolphinTaskGroupInfo[] | undefined = await queryDataByParams< DolphinTaskGroupInfo[] - >(API_CONSTANTS.SCHEDULER_QUERY_TASK_GROUP, { projectCode:dolphinTaskDefinition?.projectCode || undefined }); + >(API_CONSTANTS.SCHEDULER_QUERY_TASK_GROUP, { + projectCode: dolphinTaskDefinition?.projectCode || undefined + }); + + const formValuesInfo = dolphinTaskDefinition + ? JSON.parse(JSON.stringify(dolphinTaskDefinition)) + : {}; - const formValuesInfo=dolphinTaskDefinition?JSON.parse(JSON.stringify(dolphinTaskDefinition)):{} - - setPushDolphinState((prevState) => ({ ...prevState, buttonLoading: true, confirmLoading: false, modalVisible: true, dolphinTaskList: dolphinTaskList ?? [], - dolphinTaskGroup:dolphinTaskGroup??[], + dolphinTaskGroup: dolphinTaskGroup ?? [], dolphinDefinitionTask: dolphinTaskDefinition ?? {}, currentDinkyTaskValue: currentData as TaskDataType, - formValuesInfo:formValuesInfo??{} + formValuesInfo: formValuesInfo ?? {} })); }; @@ -164,11 +171,11 @@ const HeaderContainer = (props: connect) => { modalVisible: false, buttonLoading: false, dolphinTaskList: [], - dolphinTaskGroup:[], + dolphinTaskGroup: [], confirmLoading: false, dolphinDefinitionTask: {}, currentDinkyTaskValue: {}, - formValuesInfo:{} + formValuesInfo: {} })); }; @@ -518,8 +525,6 @@ const HeaderContainer = (props: connect) => { }; const handlePushDolphinSubmit = async (value: DolphinTaskDefinition) => { - - setPushDolphinState((prevState) => ({ ...prevState, loading: true })); await handleOption( API_CONSTANTS.SCHEDULER_CREATE_OR_UPDATE_TASK_DEFINITION, diff --git a/dinky-web/src/pages/Other/Login/index.tsx b/dinky-web/src/pages/Other/Login/index.tsx index 885db8f5c8..e93cab91cd 100644 --- a/dinky-web/src/pages/Other/Login/index.tsx +++ b/dinky-web/src/pages/Other/Login/index.tsx @@ -127,6 +127,7 @@ const Login: React.FC = () => { const chooseTenantResult: API.Result = await chooseTenantSubmit({ tenantId }); + await handleChooseTenant(chooseTenantResult); }; @@ -134,6 +135,7 @@ const Login: React.FC = () => { try { // login const result = await login({ ...values }); + if (result.code === 0) { // if login success then get token info and set it to local storage await queryDataByParams(API_CONSTANTS.TOKEN_INFO).then((res) => { From c8fa7113f939718cdebb4d0cfdfc3273574b98f5 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Tue, 23 Apr 2024 19:42:07 +0800 Subject: [PATCH 08/28] style: remove print code & add license --- .../service/impl/SchedulerServiceImpl.java | 1 - .../dinky/scheduler/client/TaskClient.java | 12 ++++----- .../org/dinky/scheduler/model/TaskGroup.java | 22 +++++++++++++++- .../dinky/scheduler/result/DsPageData.java | 23 +++++++++++++++-- .../dinky/scheduler/result/DsPageInfo.java | 25 ++++++++++++++++--- .../HeaderContainer/PushDolphin/index.tsx | 1 + .../DataStudio/HeaderContainer/index.tsx | 1 + 7 files changed, 71 insertions(+), 14 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java index 1e5a08e42b..e0df317490 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java @@ -28,7 +28,6 @@ import org.dinky.scheduler.client.TaskClient; import org.dinky.scheduler.enums.ReleaseState; import org.dinky.scheduler.exception.SchedulerException; -import org.dinky.scheduler.model.*; import org.dinky.service.CatalogueService; import org.dinky.service.SchedulerService; import org.dinky.utils.JsonUtils; diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java index 45b63cf8df..449c2a3b1e 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java @@ -19,7 +19,6 @@ package org.dinky.scheduler.client; -import com.fasterxml.jackson.core.JsonProcessingException; import org.dinky.data.model.SystemConfiguration; import org.dinky.scheduler.constant.Constants; import org.dinky.scheduler.exception.SchedulerException; @@ -285,14 +284,15 @@ public List getTaskGroupList(Long projectCode) { Constants.TOKEN, SystemConfiguration.getInstances() .getDolphinschedulerToken() - .getValue() - ) + .getValue()) .form(params) .timeout(5000) .execute() .body(); - System.out.println(content); - List jsonObjects = MyJSONUtil.toBean(content, DsPageInfo.class).getData().getTotalList(); - return jsonObjects.stream().map(jsonObject->MyJSONUtil.toBean(jsonObject, TaskGroup.class)).collect(Collectors.toList()); + List jsonObjects = + MyJSONUtil.toBean(content, DsPageInfo.class).getData().getTotalList(); + return jsonObjects.stream() + .map(jsonObject -> MyJSONUtil.toBean(jsonObject, TaskGroup.class)) + .collect(Collectors.toList()); } } diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java index 5522825c8b..a5a6b4e7ba 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java @@ -1,8 +1,28 @@ +/* + * + * 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.dinky.scheduler.model; +import java.util.Date; + import lombok.Data; -import java.util.Date; @Data public class TaskGroup { private Integer id; diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java index 2dca479bda..90fbeda429 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java @@ -1,9 +1,28 @@ -package org.dinky.scheduler.result; +/* + * + * 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. + * + */ -import lombok.Data; +package org.dinky.scheduler.result; import java.util.List; +import lombok.Data; + @Data public class DsPageData { private List totalList; diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java index cc872f1060..f2812ffb92 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java @@ -1,13 +1,31 @@ +/* + * + * 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.dinky.scheduler.result; import lombok.Data; -import java.util.List; - @Data public class DsPageInfo { /** total */ private DsPageData data; + private Integer total = 0; /** total Page */ private Integer totalPage; @@ -17,5 +35,4 @@ public class DsPageInfo { private Integer currentPage = 0; /** pageNo */ private Integer pageNo; - -} \ No newline at end of file +} diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx index 592fb738eb..670beadc9b 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx @@ -16,6 +16,7 @@ * limitations under the License. * */ + import { FormContextValue } from '@/components/Context/FormContext'; import { NORMAL_MODAL_OPTIONS, SWITCH_OPTIONS } from '@/services/constants'; import { l } from '@/utils/intl'; diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx index 32b510f8a7..34cea5fe72 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx @@ -16,6 +16,7 @@ * limitations under the License. * */ + import { LoadingBtn } from '@/components/CallBackButton/LoadingBtn'; import { PushpinIcon } from '@/components/Icons/CustomIcons'; import { FlexCenterDiv } from '@/components/StyledComponents'; From e26587baf9d9c70f00c847207e70d24948dccea9 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Tue, 23 Apr 2024 19:42:07 +0800 Subject: [PATCH 09/28] style: remove print code & add license --- .../service/impl/SchedulerServiceImpl.java | 18 ++++++++++++- .../dinky/scheduler/client/TaskClient.java | 12 ++++----- .../org/dinky/scheduler/model/TaskGroup.java | 22 +++++++++++++++- .../dinky/scheduler/result/DsPageData.java | 23 +++++++++++++++-- .../dinky/scheduler/result/DsPageInfo.java | 25 ++++++++++++++++--- .../HeaderContainer/PushDolphin/index.tsx | 1 + .../DataStudio/HeaderContainer/index.tsx | 1 + 7 files changed, 88 insertions(+), 14 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java index 1e5a08e42b..5b1e726363 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java @@ -28,7 +28,17 @@ import org.dinky.scheduler.client.TaskClient; import org.dinky.scheduler.enums.ReleaseState; import org.dinky.scheduler.exception.SchedulerException; -import org.dinky.scheduler.model.*; +import org.dinky.scheduler.model.DagData; +import org.dinky.scheduler.model.DagNodeLocation; +import org.dinky.scheduler.model.DinkyTaskParams; +import org.dinky.scheduler.model.DinkyTaskRequest; +import org.dinky.scheduler.model.ProcessDefinition; +import org.dinky.scheduler.model.ProcessTaskRelation; +import org.dinky.scheduler.model.Project; +import org.dinky.scheduler.model.TaskDefinition; +import org.dinky.scheduler.model.TaskGroup; +import org.dinky.scheduler.model.TaskMainInfo; +import org.dinky.scheduler.model.TaskRequest; import org.dinky.service.CatalogueService; import org.dinky.service.SchedulerService; import org.dinky.utils.JsonUtils; @@ -346,6 +356,12 @@ public TaskDefinition getTaskDefinitionInfo(long dinkyTaskId) { return taskDefinition; } + /** + * Retrieves the list of task groups from DolphinScheduler. + * + * @param projectCode the project code + * @return the list of task groups + */ @Override public List getTaskGroupsFromDolphinScheduler(long projectCode) { return taskClient.getTaskGroupList(projectCode); diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java index 45b63cf8df..449c2a3b1e 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java @@ -19,7 +19,6 @@ package org.dinky.scheduler.client; -import com.fasterxml.jackson.core.JsonProcessingException; import org.dinky.data.model.SystemConfiguration; import org.dinky.scheduler.constant.Constants; import org.dinky.scheduler.exception.SchedulerException; @@ -285,14 +284,15 @@ public List getTaskGroupList(Long projectCode) { Constants.TOKEN, SystemConfiguration.getInstances() .getDolphinschedulerToken() - .getValue() - ) + .getValue()) .form(params) .timeout(5000) .execute() .body(); - System.out.println(content); - List jsonObjects = MyJSONUtil.toBean(content, DsPageInfo.class).getData().getTotalList(); - return jsonObjects.stream().map(jsonObject->MyJSONUtil.toBean(jsonObject, TaskGroup.class)).collect(Collectors.toList()); + List jsonObjects = + MyJSONUtil.toBean(content, DsPageInfo.class).getData().getTotalList(); + return jsonObjects.stream() + .map(jsonObject -> MyJSONUtil.toBean(jsonObject, TaskGroup.class)) + .collect(Collectors.toList()); } } diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java index 5522825c8b..a5a6b4e7ba 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskGroup.java @@ -1,8 +1,28 @@ +/* + * + * 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.dinky.scheduler.model; +import java.util.Date; + import lombok.Data; -import java.util.Date; @Data public class TaskGroup { private Integer id; diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java index 2dca479bda..90fbeda429 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java @@ -1,9 +1,28 @@ -package org.dinky.scheduler.result; +/* + * + * 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. + * + */ -import lombok.Data; +package org.dinky.scheduler.result; import java.util.List; +import lombok.Data; + @Data public class DsPageData { private List totalList; diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java index cc872f1060..f2812ffb92 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java @@ -1,13 +1,31 @@ +/* + * + * 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.dinky.scheduler.result; import lombok.Data; -import java.util.List; - @Data public class DsPageInfo { /** total */ private DsPageData data; + private Integer total = 0; /** total Page */ private Integer totalPage; @@ -17,5 +35,4 @@ public class DsPageInfo { private Integer currentPage = 0; /** pageNo */ private Integer pageNo; - -} \ No newline at end of file +} diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx index 592fb738eb..670beadc9b 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx @@ -16,6 +16,7 @@ * limitations under the License. * */ + import { FormContextValue } from '@/components/Context/FormContext'; import { NORMAL_MODAL_OPTIONS, SWITCH_OPTIONS } from '@/services/constants'; import { l } from '@/utils/intl'; diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx index 32b510f8a7..34cea5fe72 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx @@ -16,6 +16,7 @@ * limitations under the License. * */ + import { LoadingBtn } from '@/components/CallBackButton/LoadingBtn'; import { PushpinIcon } from '@/components/Icons/CustomIcons'; import { FlexCenterDiv } from '@/components/StyledComponents'; From 689450b9a022dc4c1fb33c6199768c532f2a0645 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 24 Apr 2024 15:44:07 +0800 Subject: [PATCH 10/28] refactor: Remove new classes, and use existed classes --- .../dinky/scheduler/client/TaskClient.java | 9 +---- .../dinky/scheduler/result/DsPageData.java | 29 -------------- .../dinky/scheduler/result/DsPageInfo.java | 38 ------------------- 3 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java delete mode 100644 dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java index 449c2a3b1e..981dfcb819 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java @@ -26,7 +26,6 @@ import org.dinky.scheduler.model.TaskDefinitionLog; import org.dinky.scheduler.model.TaskGroup; import org.dinky.scheduler.model.TaskMainInfo; -import org.dinky.scheduler.result.DsPageInfo; import org.dinky.scheduler.result.PageInfo; import org.dinky.scheduler.result.Result; import org.dinky.scheduler.utils.MyJSONUtil; @@ -38,7 +37,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -289,10 +287,7 @@ public List getTaskGroupList(Long projectCode) { .timeout(5000) .execute() .body(); - List jsonObjects = - MyJSONUtil.toBean(content, DsPageInfo.class).getData().getTotalList(); - return jsonObjects.stream() - .map(jsonObject -> MyJSONUtil.toBean(jsonObject, TaskGroup.class)) - .collect(Collectors.toList()); + PageInfo pageInfo = MyJSONUtil.toPageBean(content); + return MyJSONUtil.toBean(pageInfo.getTotalList().toString(), new TypeReference>() {}); } } diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java deleted file mode 100644 index 90fbeda429..0000000000 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageData.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * 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.dinky.scheduler.result; - -import java.util.List; - -import lombok.Data; - -@Data -public class DsPageData { - private List totalList; -} diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java deleted file mode 100644 index f2812ffb92..0000000000 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/result/DsPageInfo.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * 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.dinky.scheduler.result; - -import lombok.Data; - -@Data -public class DsPageInfo { - /** total */ - private DsPageData data; - - private Integer total = 0; - /** total Page */ - private Integer totalPage; - /** page size */ - private Integer pageSize = 20; - /** current page */ - private Integer currentPage = 0; - /** pageNo */ - private Integer pageNo; -} From 913e87216f105775130370360132f518aed76e5f Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 24 Apr 2024 16:59:40 +0800 Subject: [PATCH 11/28] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=BB=84=E5=86=85=E4=BC=98=E5=85=88=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/dinky/service/impl/SchedulerServiceImpl.java | 2 ++ .../src/main/java/org/dinky/scheduler/model/TaskRequest.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java index 5b1e726363..d66aee2392 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java @@ -112,6 +112,7 @@ public boolean pushAddTask(DinkyTaskRequest dinkyTaskRequest) { taskRequest.setFlag(dinkyTaskRequest.getFlag()); taskRequest.setIsCache(dinkyTaskRequest.getIsCache()); taskRequest.setTaskGroupId(dinkyTaskRequest.getTaskGroupId()); + taskRequest.setTaskGroupPriority(dinkyTaskRequest.getTaskGroupPriority()); JSONObject jsonObject = JSONUtil.parseObj(taskRequest); JSONArray taskArray = new JSONArray(); taskArray.set(jsonObject); @@ -159,6 +160,7 @@ public boolean pushAddTask(DinkyTaskRequest dinkyTaskRequest) { taskRequest.setFlag(dinkyTaskRequest.getFlag()); taskRequest.setIsCache(dinkyTaskRequest.getIsCache()); taskRequest.setTaskGroupId(dinkyTaskRequest.getTaskGroupId()); + taskRequest.setTaskGroupPriority(dinkyTaskRequest.getTaskGroupPriority()); String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest); taskClient.createTaskDefinition( diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java index b389421b7c..7432e516be 100644 --- a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java @@ -69,6 +69,9 @@ public class TaskRequest { @ApiModelProperty(value = "任务组 ID") private Long taskGroupId; + @ApiModelProperty(value = "任务组内优先级") + private Integer taskGroupPriority; + @ApiModelProperty(value = "超时时间(分钟)") private Integer timeout; From 0e4118652b50b5508fe3ccea728aced047b63f7c Mon Sep 17 00:00:00 2001 From: guohuayu Date: Wed, 24 Apr 2024 16:04:19 +0800 Subject: [PATCH 12/28] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E5=86=85=E4=BC=98=E5=85=88=E7=BA=A7=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dinky-web/src/locales/en-US/pages.ts | 1 + dinky-web/src/locales/zh-CN/pages.ts | 1 + .../DataStudio/HeaderContainer/PushDolphin/index.tsx | 11 +++++++++++ dinky-web/src/types/Studio/data.d.ts | 1 + 4 files changed, 14 insertions(+) diff --git a/dinky-web/src/locales/en-US/pages.ts b/dinky-web/src/locales/en-US/pages.ts index a80f72b4fc..667c897fc6 100644 --- a/dinky-web/src/locales/en-US/pages.ts +++ b/dinky-web/src/locales/en-US/pages.ts @@ -96,6 +96,7 @@ export default { 'datastudio.header.pushdolphin.title': 'Push task [ {name} ] to DolphinScheduler', 'datastudio.header.pushdolphin.taskId': 'Dinky task encoding', 'datastudio.header.pushdolphin.taskGroup': 'Task Group', + 'datastudio.header.pushdolphin.taskGroupPriority': 'Task Group Priority', 'datastudio.header.pushdolphin.taskName': 'Task name: {name}', 'datastudio.header.pushdolphin.taskNameExt': 'Task type: {type} Process definition: {processDefinitionName}', diff --git a/dinky-web/src/locales/zh-CN/pages.ts b/dinky-web/src/locales/zh-CN/pages.ts index c45d3e14b9..0a94bc0e5b 100644 --- a/dinky-web/src/locales/zh-CN/pages.ts +++ b/dinky-web/src/locales/zh-CN/pages.ts @@ -91,6 +91,7 @@ export default { 'datastudio.header.pushdolphin.title': '将任务 [ {name} ] 推送至 DolphinScheduler', 'datastudio.header.pushdolphin.taskId': 'Dinky任务编码', 'datastudio.header.pushdolphin.taskGroup': '任务组', + 'datastudio.header.pushdolphin.taskGroupPriority': '组内优先级', 'datastudio.header.pushdolphin.taskName': 'Task名称: {name}', 'datastudio.header.pushdolphin.taskNameExt': 'Task类型: {type} 所属进程定义: {processDefinitionName}', diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx index 670beadc9b..683a3adeb5 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx @@ -214,6 +214,17 @@ export const PushDolphin: React.FC = (props) => { }} // fieldNames={label:'label', value: 'value'} /> + Date: Wed, 15 May 2024 15:31:09 +0800 Subject: [PATCH 13/28] =?UTF-8?q?feat:=20=E5=88=9B=E5=BB=BA=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=92=8C=E4=BB=BB=E5=8A=A1=EF=BC=8C=E5=BE=80=20Dolphi?= =?UTF-8?q?nScheduler=20=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/dinky/configure/AppConfig.java | 11 +-- .../org/dinky/controller/APIController.java | 17 ++++ .../data/dto/CreatingCatalogueTaskDTO.java | 32 +++++++ .../java/org/dinky/service/APIService.java | 7 +- .../dinky/service/impl/APIServiceImpl.java | 66 ++++++++++++- .../service/impl/TestServiceImplTest.java | 95 +++++++++++++++++++ 6 files changed, 217 insertions(+), 11 deletions(-) create mode 100644 dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java create mode 100644 dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java diff --git a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java index 2f2bdb3a67..816d460505 100644 --- a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java +++ b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java @@ -75,16 +75,9 @@ public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(localeChangeInterceptor()); // 注册Sa-Token的路由拦截器 registry.addInterceptor(new SaInterceptor(handler -> { - SaRouter.match("/openapi/**", r -> { - if (!StpUtil.isLogin()) { - StpUtil.switchTo(BaseConstant.ADMIN_ID); - } - }); - if (!StpUtil.isLogin()) { - throw new StopMatchException(); - } + StpUtil.checkLogin(); })) - .addPathPatterns("/api/**", "/openapi/**") + .addPathPatterns("/api/**", "/openapi/createTaskAndSend2Ds") .excludePathPatterns("/api/login", "/api/ldap/ldapEnableStatus", "/download/**", "/druid/**"); registry.addInterceptor(new TenantInterceptor()) diff --git a/dinky-admin/src/main/java/org/dinky/controller/APIController.java b/dinky-admin/src/main/java/org/dinky/controller/APIController.java index 1d58b27cf5..24746956da 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/APIController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/APIController.java @@ -22,6 +22,7 @@ import org.dinky.DinkyVersion; import org.dinky.data.annotations.Log; import org.dinky.data.dto.APISavePointTaskDTO; +import org.dinky.data.dto.CreatingCatalogueTaskDTO; import org.dinky.data.dto.TaskDTO; import org.dinky.data.dto.TaskSubmitDto; import org.dinky.data.enums.BusinessType; @@ -33,11 +34,13 @@ import org.dinky.gateway.enums.SavePointType; import org.dinky.gateway.result.SavePointResult; import org.dinky.job.JobResult; +import org.dinky.service.APIService; import org.dinky.service.JobInstanceService; import org.dinky.service.TaskService; import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -66,6 +69,8 @@ public class APIController { private final TaskService taskService; private final JobInstanceService jobInstanceService; + @Autowired + private APIService apiService; @GetMapping("/version") @ApiOperation(value = "Query Service Version", notes = "Query Dinky Service Version Number") @@ -202,4 +207,16 @@ public Result getTaskLineage(@RequestParam Integer id) { taskService.initTenantByTaskId(id); return Result.succeed(taskService.getTaskLineage(id), Status.QUERY_SUCCESS); } + + @PostMapping("/createTaskAndSend2Ds") + @ApiOperation("Create Catalogues & Task and Send to DolphinScheduler") + @Log(title = "Create Catalogues & Task and Send to DolphinScheduler", businessType = BusinessType.OTHER) + public Result createTaskAndSend2Ds(@RequestBody CreatingCatalogueTaskDTO dto) { + try { + apiService.createTaskAndSend2Ds(dto); + return Result.succeed(Status.EXECUTE_SUCCESS); + }catch(Exception e) { + return Result.failed(e.getMessage()); + } + } } diff --git a/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java b/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java new file mode 100644 index 0000000000..85d8e38a3c --- /dev/null +++ b/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java @@ -0,0 +1,32 @@ +package org.dinky.data.dto; + +import lombok.Data; + +import java.util.List; + +@Data +public class CreatingCatalogueTaskDTO { + /** + * 目录名称列表 + * 例子:["catalogue1", "catalogue2"] + * 数组第 0 个元素为根目录,依次下一个元素是上一个元素的子目录 + * 目录不存在会新建,已存在就保持原来的目录 + */ + private List catalogueNames; + /** + * 作业类型:FlinkSql、Mysql 等,详见 dinky 创建作业时的作业类型下拉菜单 + */ + private String type; + /** + * 任务信息 + * 例子:{"name": "test", "note": "作业描述", "statement": "sql 语句", "type": "kubernetes-session", "clusterId": 36} + * 例子只列出了部分属性,其他属性请参考 TaskDTO 类 + */ + private String taskJson; + /** + * Dinky 推送时的作业配置 + * 例子: {"delayTime": 0, "taskPriority": "MEDIUM", "failRetryInterval": 2, "failRetryTimes": 3, "flag": "YES" } + * 例子只列出了部分属性,其他属性请参考 DinkyTaskRequest 类 + */ + private String jobConfigJson; +} diff --git a/dinky-admin/src/main/java/org/dinky/service/APIService.java b/dinky-admin/src/main/java/org/dinky/service/APIService.java index 0c362b6b7e..d32c64379a 100644 --- a/dinky-admin/src/main/java/org/dinky/service/APIService.java +++ b/dinky-admin/src/main/java/org/dinky/service/APIService.java @@ -19,9 +19,14 @@ package org.dinky.service; +import org.dinky.data.dto.CreatingCatalogueTaskDTO; +import org.dinky.data.exception.SqlExplainExcepition; + /** * APIService * * @since 2021/12/11 21:45 */ -public interface APIService {} +public interface APIService { + void createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) throws SqlExplainExcepition; +} diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java index 99fdeec261..190990defc 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java @@ -19,13 +19,31 @@ package org.dinky.service.impl; +import cn.hutool.json.JSONUtil; +import org.dinky.data.dto.CatalogueTaskDTO; +import org.dinky.data.dto.CreatingCatalogueTaskDTO; +import org.dinky.data.dto.TaskDTO; +import org.dinky.data.enums.JobLifeCycle; +import org.dinky.data.enums.Status; +import org.dinky.data.exception.SqlExplainExcepition; +import org.dinky.data.model.Catalogue; +import org.dinky.scheduler.model.DinkyTaskRequest; import org.dinky.service.APIService; +import org.dinky.service.CatalogueService; +import org.dinky.service.SchedulerService; +import org.dinky.service.TaskService; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + /** * APIServiceImpl * @@ -34,4 +52,50 @@ @Service @RequiredArgsConstructor @Slf4j -public class APIServiceImpl implements APIService {} +public class APIServiceImpl implements APIService { + @Autowired + private TaskService taskService; + @Autowired + private SchedulerService schedulerService; + @Autowired + private CatalogueService catalogueService; + + /** + * 创建目录、任务并推送到 DolphinScheduler + * @param dto CreateCatalogueTaskDTO + * @throws SqlExplainExcepition + */ + @Override + public void createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) throws SqlExplainExcepition { + int parentId = 0; + for (String catalogueName : dto.getCatalogueNames()) { + Catalogue catalogue = catalogueService.findByParentIdAndName(parentId, catalogueName); + // 目录不存在则创建 + if (catalogue == null) { + catalogue = new Catalogue(); + catalogue.setName(catalogueName); + catalogue.setIsLeaf(false); + catalogue.setParentId(parentId); + catalogueService.save(catalogue); + } + parentId = catalogue.getId(); + } + TaskDTO taskDTO = JSONUtil.toBean(dto.getTaskJson(), TaskDTO.class); + CatalogueTaskDTO catalogueTaskDTO = new CatalogueTaskDTO(); + catalogueTaskDTO.setLeaf(false); + catalogueTaskDTO.setName(taskDTO.getName()); + catalogueTaskDTO.setNote(taskDTO.getNote()); + catalogueTaskDTO.setParentId(parentId); + catalogueTaskDTO.setType(dto.getType()); + catalogueTaskDTO.setTask(taskDTO); + // 保存任务 + Catalogue catalogue = catalogueService.saveOrUpdateCatalogueAndTask(catalogueTaskDTO); + + // 发布任务 + taskService.changeTaskLifeRecyle(catalogue.getTaskId(), JobLifeCycle.PUBLISH); + // 推送任务 + DinkyTaskRequest dinkyTaskRequest = JSONUtil.toBean(dto.getJobConfigJson(), DinkyTaskRequest.class); + dinkyTaskRequest.setTaskId(taskDTO.getId() + ""); + schedulerService.pushAddTask(dinkyTaskRequest); + } +} diff --git a/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java b/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java new file mode 100644 index 0000000000..737c3ea4f2 --- /dev/null +++ b/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java @@ -0,0 +1,95 @@ +package org.dinky.service.impl; + +import org.dinky.Dinky; +import org.dinky.data.dto.CatalogueTaskDTO; +import org.dinky.data.dto.CreatingCatalogueTaskDTO; +import org.dinky.data.dto.TaskDTO; +import org.dinky.data.enums.JobLifeCycle; +import org.dinky.data.exception.SqlExplainExcepition; +import org.dinky.data.model.Catalogue; +import org.dinky.scheduler.model.DinkyTaskRequest; +import org.dinky.service.CatalogueService; +import org.dinky.service.SchedulerService; +import org.dinky.service.TaskService; +import org.jetbrains.annotations.NotNull; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(classes = Dinky.class) +public class TestServiceImplTest { + @Autowired + private CatalogueService catalogueService; + @Autowired + private TaskService taskService; + @Autowired + SchedulerService schedulerService; + + @Test + @Ignore + public void testCreateCatalogueAndTask() throws SqlExplainExcepition { + CreatingCatalogueTaskDTO dto = new CreatingCatalogueTaskDTO(); + List catalogueNames = List.of("DDP", "test1", "test3"); + dto.setCatalogueNames(catalogueNames); + int parentId = 0; + for (String catalogueName : catalogueNames) { + Catalogue catalogue = catalogueService.findByParentIdAndName(parentId, catalogueName); + // 目录不存在则创建 + if (catalogue == null) { + catalogue = new Catalogue(); + catalogue.setName(catalogueName); + catalogue.setIsLeaf(false); + catalogue.setParentId(parentId); + catalogueService.save(catalogue); + } + parentId = catalogue.getId(); + } + CatalogueTaskDTO catalogueTaskDTO = getCatalogueTaskDTO(parentId); + // 新建任务 + Catalogue catalogue = catalogueService.saveOrUpdateCatalogueAndTask(catalogueTaskDTO); + + // 发布任务 + taskService.changeTaskLifeRecyle(catalogue.getTaskId(), JobLifeCycle.PUBLISH); + DinkyTaskRequest dinkyTaskRequest = new DinkyTaskRequest(); + dinkyTaskRequest.setTaskId(catalogue.getTaskId() + ""); + dinkyTaskRequest.setDelayTime(0); + dinkyTaskRequest.setFailRetryTimes(3); + dinkyTaskRequest.setFailRetryInterval(2); + dinkyTaskRequest.setFlag("YES"); + dinkyTaskRequest.setTaskPriority("MEDIUM"); + // 推送任务 + schedulerService.pushAddTask(dinkyTaskRequest); + } + + private static @NotNull CatalogueTaskDTO getCatalogueTaskDTO(int parentId) { + TaskDTO taskDTO = new TaskDTO(); + taskDTO.setSavePointStrategy(0); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); + taskDTO.setName("Flink 测试任务" + sdf.format(new Date())); + taskDTO.setNote("备注信息"); + taskDTO.setStatement("select now()"); + taskDTO.setParallelism(5); + taskDTO.setEnvId(-1); + taskDTO.setStep(1); + taskDTO.setAlertGroupId(-1); + taskDTO.setType("kubernetes-session"); + taskDTO.setClusterId(36); + CatalogueTaskDTO catalogueTaskDTO = new CatalogueTaskDTO(); + catalogueTaskDTO.setLeaf(false); + catalogueTaskDTO.setName(taskDTO.getName()); + catalogueTaskDTO.setNote(taskDTO.getNote()); + catalogueTaskDTO.setParentId(parentId); + catalogueTaskDTO.setType("FlinkSql"); + catalogueTaskDTO.setTask(taskDTO); + + return catalogueTaskDTO; + } +} From 0d2d5069c3976ec58e895c35d6b76ce62f8b4590 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 15 May 2024 15:31:09 +0800 Subject: [PATCH 14/28] =?UTF-8?q?feat:=20=E5=88=9B=E5=BB=BA=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=92=8C=E4=BB=BB=E5=8A=A1=EF=BC=8C=E5=BE=80=20Dolphi?= =?UTF-8?q?nScheduler=20=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 2d65f9368fe4166e1e2f81a2e0b91c5e52b278b9 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 15 May 2024 17:37:33 +0800 Subject: [PATCH 15/28] =?UTF-8?q?fix:=20=E5=88=9B=E5=BB=BA=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=8E=A5=E5=8F=A3=E6=8E=A8=E9=80=81=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=B6=E5=8F=82=E6=95=B0=E8=AE=BE=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/dinky/service/impl/APIServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java index 190990defc..925ebbc344 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java @@ -95,7 +95,7 @@ public void createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) throws SqlExplain taskService.changeTaskLifeRecyle(catalogue.getTaskId(), JobLifeCycle.PUBLISH); // 推送任务 DinkyTaskRequest dinkyTaskRequest = JSONUtil.toBean(dto.getJobConfigJson(), DinkyTaskRequest.class); - dinkyTaskRequest.setTaskId(taskDTO.getId() + ""); + dinkyTaskRequest.setTaskId(catalogue.getTaskId() + ""); schedulerService.pushAddTask(dinkyTaskRequest); } } From 78008c412ae00c3d23a4c3284fd6ae7ddeb6ca42 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Thu, 16 May 2024 09:54:35 +0800 Subject: [PATCH 16/28] =?UTF-8?q?fix:=20token=20=E5=B7=B2=E8=A2=AB?= =?UTF-8?q?=E5=86=BB=E7=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dinky-admin/src/main/java/org/dinky/configure/AppConfig.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java index 816d460505..f33698f347 100644 --- a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java +++ b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java @@ -75,6 +75,9 @@ public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(localeChangeInterceptor()); // 注册Sa-Token的路由拦截器 registry.addInterceptor(new SaInterceptor(handler -> { + if (!StpUtil.isLogin()) { + StpUtil.switchTo(BaseConstant.ADMIN_ID); + } StpUtil.checkLogin(); })) .addPathPatterns("/api/**", "/openapi/createTaskAndSend2Ds") From 3b65e3683f9c9e1c203700e39c35bb5e1abf265a Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Mon, 20 May 2024 15:53:51 +0800 Subject: [PATCH 17/28] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E4=BB=BB=E5=8A=A1=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dinky/controller/APIController.java | 14 ++++---- .../java/org/dinky/service/APIService.java | 5 ++- .../dinky/service/impl/APIServiceImpl.java | 34 ++++++++++++++----- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/controller/APIController.java b/dinky-admin/src/main/java/org/dinky/controller/APIController.java index 24746956da..59a8d82683 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/APIController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/APIController.java @@ -212,11 +212,13 @@ public Result getTaskLineage(@RequestParam Integer id) { @ApiOperation("Create Catalogues & Task and Send to DolphinScheduler") @Log(title = "Create Catalogues & Task and Send to DolphinScheduler", businessType = BusinessType.OTHER) public Result createTaskAndSend2Ds(@RequestBody CreatingCatalogueTaskDTO dto) { - try { - apiService.createTaskAndSend2Ds(dto); - return Result.succeed(Status.EXECUTE_SUCCESS); - }catch(Exception e) { - return Result.failed(e.getMessage()); - } + return Result.succeed(apiService.createTaskAndSend2Ds(dto)); + } + @PostMapping("/saveTask") + @ApiOperation("Save a task") + @Log(title = "Save a task", businessType = BusinessType.OTHER) + public Result saveTask(@RequestBody TaskDTO dto) { + apiService.saveTask(dto); + return Result.succeed(); } } diff --git a/dinky-admin/src/main/java/org/dinky/service/APIService.java b/dinky-admin/src/main/java/org/dinky/service/APIService.java index d32c64379a..7c102143c1 100644 --- a/dinky-admin/src/main/java/org/dinky/service/APIService.java +++ b/dinky-admin/src/main/java/org/dinky/service/APIService.java @@ -20,6 +20,7 @@ package org.dinky.service; import org.dinky.data.dto.CreatingCatalogueTaskDTO; +import org.dinky.data.dto.TaskDTO; import org.dinky.data.exception.SqlExplainExcepition; /** @@ -28,5 +29,7 @@ * @since 2021/12/11 21:45 */ public interface APIService { - void createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) throws SqlExplainExcepition; + Integer createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto); + + void saveTask(TaskDTO dto); } diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java index 925ebbc344..888fb5669e 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java @@ -24,25 +24,20 @@ import org.dinky.data.dto.CreatingCatalogueTaskDTO; import org.dinky.data.dto.TaskDTO; import org.dinky.data.enums.JobLifeCycle; -import org.dinky.data.enums.Status; -import org.dinky.data.exception.SqlExplainExcepition; import org.dinky.data.model.Catalogue; +import org.dinky.data.model.Task; import org.dinky.scheduler.model.DinkyTaskRequest; import org.dinky.service.APIService; import org.dinky.service.CatalogueService; import org.dinky.service.SchedulerService; import org.dinky.service.TaskService; -import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; /** * APIServiceImpl @@ -62,11 +57,12 @@ public class APIServiceImpl implements APIService { /** * 创建目录、任务并推送到 DolphinScheduler + * * @param dto CreateCatalogueTaskDTO - * @throws SqlExplainExcepition + * @return Integer taskId */ @Override - public void createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) throws SqlExplainExcepition { + public Integer createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) { int parentId = 0; for (String catalogueName : dto.getCatalogueNames()) { Catalogue catalogue = catalogueService.findByParentIdAndName(parentId, catalogueName); @@ -92,10 +88,30 @@ public void createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) throws SqlExplain Catalogue catalogue = catalogueService.saveOrUpdateCatalogueAndTask(catalogueTaskDTO); // 发布任务 - taskService.changeTaskLifeRecyle(catalogue.getTaskId(), JobLifeCycle.PUBLISH); + try { + taskService.changeTaskLifeRecyle(catalogue.getTaskId(), JobLifeCycle.PUBLISH); + } catch(Exception e) { + log.error(e.getMessage()); + throw new RuntimeException(e); + } // 推送任务 DinkyTaskRequest dinkyTaskRequest = JSONUtil.toBean(dto.getJobConfigJson(), DinkyTaskRequest.class); dinkyTaskRequest.setTaskId(catalogue.getTaskId() + ""); schedulerService.pushAddTask(dinkyTaskRequest); + + return catalogue.getTaskId(); + } + + /** + * 更新任务的名称和 sql + * @param dto + */ + @Override + public void saveTask(TaskDTO dto) { + Task task = new Task(); + task.setId(dto.getId()); + task.setName(dto.getName()); + task.setStatement(dto.getStatement()); + taskService.save(task); } } From 20aa8d79383e930e417fb463bec1a8639314513b Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Mon, 20 May 2024 17:17:17 +0800 Subject: [PATCH 18/28] =?UTF-8?q?fix:=20/openapi=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=20sa-token=20=E6=9C=BA=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E6=9C=89=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dinky-admin/src/main/java/org/dinky/configure/AppConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java index f33698f347..cadba3d7d1 100644 --- a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java +++ b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java @@ -80,7 +80,7 @@ public void addInterceptors(InterceptorRegistry registry) { } StpUtil.checkLogin(); })) - .addPathPatterns("/api/**", "/openapi/createTaskAndSend2Ds") + .addPathPatterns("/api/**") .excludePathPatterns("/api/login", "/api/ldap/ldapEnableStatus", "/download/**", "/druid/**"); registry.addInterceptor(new TenantInterceptor()) From d76abf047603b40c08630bc74a82e541f15eea9d Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Tue, 21 May 2024 09:29:20 +0800 Subject: [PATCH 19/28] =?UTF-8?q?fix:=20=E5=8F=82=E6=95=B0=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=20json=20=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=8D=A2?= =?UTF-8?q?=E6=88=90=E6=A0=87=E5=87=86=E7=9A=84=20Java=20=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dinky-admin/src/main/java/org/dinky/configure/AppConfig.java | 2 -- .../java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java | 5 +++-- dinky-admin/src/main/java/org/dinky/service/APIService.java | 1 - .../src/main/java/org/dinky/service/impl/APIServiceImpl.java | 5 ++--- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java index cadba3d7d1..2b05c98c6b 100644 --- a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java +++ b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java @@ -32,9 +32,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.i18n.CookieLocaleResolver; -import cn.dev33.satoken.exception.StopMatchException; import cn.dev33.satoken.interceptor.SaInterceptor; -import cn.dev33.satoken.router.SaRouter; import cn.dev33.satoken.stp.StpUtil; /** diff --git a/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java b/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java index 85d8e38a3c..31bc641da8 100644 --- a/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java @@ -1,6 +1,7 @@ package org.dinky.data.dto; import lombok.Data; +import org.dinky.scheduler.model.DinkyTaskRequest; import java.util.List; @@ -22,11 +23,11 @@ public class CreatingCatalogueTaskDTO { * 例子:{"name": "test", "note": "作业描述", "statement": "sql 语句", "type": "kubernetes-session", "clusterId": 36} * 例子只列出了部分属性,其他属性请参考 TaskDTO 类 */ - private String taskJson; + private TaskDTO task; /** * Dinky 推送时的作业配置 * 例子: {"delayTime": 0, "taskPriority": "MEDIUM", "failRetryInterval": 2, "failRetryTimes": 3, "flag": "YES" } * 例子只列出了部分属性,其他属性请参考 DinkyTaskRequest 类 */ - private String jobConfigJson; + private DinkyTaskRequest jobConfig; } diff --git a/dinky-admin/src/main/java/org/dinky/service/APIService.java b/dinky-admin/src/main/java/org/dinky/service/APIService.java index 7c102143c1..377755626f 100644 --- a/dinky-admin/src/main/java/org/dinky/service/APIService.java +++ b/dinky-admin/src/main/java/org/dinky/service/APIService.java @@ -21,7 +21,6 @@ import org.dinky.data.dto.CreatingCatalogueTaskDTO; import org.dinky.data.dto.TaskDTO; -import org.dinky.data.exception.SqlExplainExcepition; /** * APIService diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java index 888fb5669e..57fdf0b9fd 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java @@ -19,7 +19,6 @@ package org.dinky.service.impl; -import cn.hutool.json.JSONUtil; import org.dinky.data.dto.CatalogueTaskDTO; import org.dinky.data.dto.CreatingCatalogueTaskDTO; import org.dinky.data.dto.TaskDTO; @@ -76,7 +75,7 @@ public Integer createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) { } parentId = catalogue.getId(); } - TaskDTO taskDTO = JSONUtil.toBean(dto.getTaskJson(), TaskDTO.class); + TaskDTO taskDTO = dto.getTask(); CatalogueTaskDTO catalogueTaskDTO = new CatalogueTaskDTO(); catalogueTaskDTO.setLeaf(false); catalogueTaskDTO.setName(taskDTO.getName()); @@ -95,7 +94,7 @@ public Integer createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) { throw new RuntimeException(e); } // 推送任务 - DinkyTaskRequest dinkyTaskRequest = JSONUtil.toBean(dto.getJobConfigJson(), DinkyTaskRequest.class); + DinkyTaskRequest dinkyTaskRequest = dto.getJobConfig(); dinkyTaskRequest.setTaskId(catalogue.getTaskId() + ""); schedulerService.pushAddTask(dinkyTaskRequest); From fe4d4e35a70df711feca859a101797d374b4bcf7 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Mon, 27 May 2024 13:38:47 +0800 Subject: [PATCH 20/28] =?UTF-8?q?fix:=20=E6=8A=8A=20/openapi/createTaskAnd?= =?UTF-8?q?Send2Ds=E3=80=81saveTask=20=E4=B8=A4=E4=B8=AA=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8A=A0=20sa-token=20=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dinky-admin/src/main/java/org/dinky/configure/AppConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java index 2b05c98c6b..62413a662a 100644 --- a/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java +++ b/dinky-admin/src/main/java/org/dinky/configure/AppConfig.java @@ -78,7 +78,7 @@ public void addInterceptors(InterceptorRegistry registry) { } StpUtil.checkLogin(); })) - .addPathPatterns("/api/**") + .addPathPatterns("/api/**", "/openapi/createTaskAndSend2Ds", "/openapi/saveTask") .excludePathPatterns("/api/login", "/api/ldap/ldapEnableStatus", "/download/**", "/druid/**"); registry.addInterceptor(new TenantInterceptor()) From 7d339fef6eb6cc3f97d39cc32f4e2c7ae451175a Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 5 Jun 2024 18:40:00 +0800 Subject: [PATCH 21/28] chore: add license info --- .../data/dto/CreatingCatalogueTaskDTO.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java b/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java index 31bc641da8..8080145db7 100644 --- a/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java @@ -1,3 +1,22 @@ +/* + * + * 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.dinky.data.dto; import lombok.Data; From 349b7b92a2123ffc0e2fd8439acfa62e0ce7947b Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 5 Jun 2024 18:57:45 +0800 Subject: [PATCH 22/28] chore: add license info --- .../main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java b/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java index 8080145db7..0445583a9b 100644 --- a/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java @@ -19,11 +19,12 @@ package org.dinky.data.dto; -import lombok.Data; import org.dinky.scheduler.model.DinkyTaskRequest; import java.util.List; +import lombok.Data; + @Data public class CreatingCatalogueTaskDTO { /** From f0937cdfda9b964d7ed1c415d4014c656b449eb6 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 5 Jun 2024 19:10:58 +0800 Subject: [PATCH 23/28] chore: code style --- .../src/main/java/org/dinky/controller/APIController.java | 4 +++- .../src/main/java/org/dinky/service/impl/APIServiceImpl.java | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/controller/APIController.java b/dinky-admin/src/main/java/org/dinky/controller/APIController.java index 59a8d82683..9331184a8e 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/APIController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/APIController.java @@ -68,9 +68,11 @@ public class APIController { private final TaskService taskService; + private final JobInstanceService jobInstanceService; + @Autowired - private APIService apiService; + private final APIService apiService; @GetMapping("/version") @ApiOperation(value = "Query Service Version", notes = "Query Dinky Service Version Number") diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java index 57fdf0b9fd..f9d457bbf2 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java @@ -49,8 +49,10 @@ public class APIServiceImpl implements APIService { @Autowired private TaskService taskService; + @Autowired private SchedulerService schedulerService; + @Autowired private CatalogueService catalogueService; From a916971c88fd08d03d5733215448a9a85fdfd7fd Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 5 Jun 2024 19:15:40 +0800 Subject: [PATCH 24/28] chore: code style --- .../src/main/java/org/dinky/controller/APIController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/dinky-admin/src/main/java/org/dinky/controller/APIController.java b/dinky-admin/src/main/java/org/dinky/controller/APIController.java index 9331184a8e..a3c8cc0821 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/APIController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/APIController.java @@ -216,6 +216,7 @@ public Result getTaskLineage(@RequestParam Integer id) { public Result createTaskAndSend2Ds(@RequestBody CreatingCatalogueTaskDTO dto) { return Result.succeed(apiService.createTaskAndSend2Ds(dto)); } + @PostMapping("/saveTask") @ApiOperation("Save a task") @Log(title = "Save a task", businessType = BusinessType.OTHER) From 3a39e59cc4215bf1017e73c8d8a3da0fe49c64b2 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 5 Jun 2024 19:18:22 +0800 Subject: [PATCH 25/28] chore: code style --- .../service/impl/TestServiceImplTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java b/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java index 737c3ea4f2..07558b0963 100644 --- a/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java +++ b/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java @@ -1,3 +1,22 @@ +/* + * + * 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.dinky.service.impl; import org.dinky.Dinky; From 9cc5d5be4494264e5c4bdec8122e007e012d924c Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 5 Jun 2024 19:28:56 +0800 Subject: [PATCH 26/28] chore: code style --- .../java/org/dinky/service/impl/APIServiceImpl.java | 5 ++--- .../org/dinky/service/impl/TestServiceImplTest.java | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java index f9d457bbf2..c4a3566e61 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java @@ -27,17 +27,16 @@ import org.dinky.data.model.Task; import org.dinky.scheduler.model.DinkyTaskRequest; import org.dinky.service.APIService; - import org.dinky.service.CatalogueService; import org.dinky.service.SchedulerService; import org.dinky.service.TaskService; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; - /** * APIServiceImpl * @@ -91,7 +90,7 @@ public Integer createTaskAndSend2Ds(CreatingCatalogueTaskDTO dto) { // 发布任务 try { taskService.changeTaskLifeRecyle(catalogue.getTaskId(), JobLifeCycle.PUBLISH); - } catch(Exception e) { + } catch (Exception e) { log.error(e.getMessage()); throw new RuntimeException(e); } diff --git a/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java b/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java index 07558b0963..1c4a457f3e 100644 --- a/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java +++ b/dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java @@ -30,6 +30,11 @@ import org.dinky.service.CatalogueService; import org.dinky.service.SchedulerService; import org.dinky.service.TaskService; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + import org.jetbrains.annotations.NotNull; import org.junit.Ignore; import org.junit.Test; @@ -38,17 +43,15 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Dinky.class) public class TestServiceImplTest { @Autowired private CatalogueService catalogueService; + @Autowired private TaskService taskService; + @Autowired SchedulerService schedulerService; From df1d27b9b67fea49bf97da2d65bbf89653d565b4 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 5 Jun 2024 20:01:44 +0800 Subject: [PATCH 27/28] chore: package path changed --- .../src/main/java/org/dinky/service/impl/APIServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java index c4a3566e61..1dc286230c 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java @@ -27,7 +27,7 @@ import org.dinky.data.model.Task; import org.dinky.scheduler.model.DinkyTaskRequest; import org.dinky.service.APIService; -import org.dinky.service.CatalogueService; +import org.dinky.service.catalogue.CatalogueService; import org.dinky.service.SchedulerService; import org.dinky.service.TaskService; From c725eeb45215c9963958510e29c9ccff856fb0b4 Mon Sep 17 00:00:00 2001 From: yangxiaotian Date: Wed, 5 Jun 2024 20:09:39 +0800 Subject: [PATCH 28/28] chore: code style --- .../src/main/java/org/dinky/service/impl/APIServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java index 1dc286230c..a11c6055c8 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/APIServiceImpl.java @@ -27,9 +27,9 @@ import org.dinky.data.model.Task; import org.dinky.scheduler.model.DinkyTaskRequest; import org.dinky.service.APIService; -import org.dinky.service.catalogue.CatalogueService; import org.dinky.service.SchedulerService; import org.dinky.service.TaskService; +import org.dinky.service.catalogue.CatalogueService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;