From 8a26674de3cb45abfc847c2143e42f98571b04a9 Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Sat, 16 Dec 2023 21:56:17 +0800 Subject: [PATCH 1/2] refactor push ds --- .../dinky/controller/SchedulerController.java | 259 ++------------- .../main/java/org/dinky/init/SystemInit.java | 53 ++- .../org/dinky/service/SchedulerService.java | 64 ++++ .../service/impl/SchedulerServiceImpl.java | 284 ++++++++++++++++ .../dinky/data/exception/BusException.java | 7 + .../resources/i18n/messages_en_US.properties | 2 +- .../resources/i18n/messages_zh_CN.properties | 2 +- .../dinky/scheduler/client/TaskClient.java | 26 +- .../scheduler/model/DinkyTaskRequest.java | 48 +++ .../dinky/scheduler/model/TaskRequest.java | 12 +- .../src/components/Icons/CustomIcons.tsx | 28 ++ dinky-web/src/locales/en-US/pages.ts | 27 ++ dinky-web/src/locales/zh-CN/pages.ts | 24 ++ .../HeaderContainer/PushDolphin/constants.tsx | 90 ++++++ .../HeaderContainer/PushDolphin/function.tsx | 53 +++ .../HeaderContainer/PushDolphin/index.tsx | 303 ++++++++++++++++++ .../DataStudio/HeaderContainer/function.tsx | 13 + .../DataStudio/HeaderContainer/index.tsx | 122 +++++-- .../SettingCenter/GlobalSetting/model.ts | 31 +- dinky-web/src/types/Studio/data.d.ts | 80 +++++ dinky-web/src/types/Studio/init.d.ts | 36 ++- 21 files changed, 1252 insertions(+), 312 deletions(-) create mode 100644 dinky-admin/src/main/java/org/dinky/service/SchedulerService.java create mode 100644 dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java create mode 100644 dinky-scheduler/src/main/java/org/dinky/scheduler/model/DinkyTaskRequest.java create mode 100644 dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/constants.tsx create mode 100644 dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx create mode 100644 dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx 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 87387340a1..3c15894348 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/SchedulerController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/SchedulerController.java @@ -20,44 +20,24 @@ package org.dinky.controller; import org.dinky.data.enums.Status; -import org.dinky.data.model.Catalogue; -import org.dinky.data.model.SystemConfiguration; import org.dinky.data.result.Result; -import org.dinky.init.SystemInit; -import org.dinky.scheduler.client.ProcessClient; -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.DinkyTaskParams; -import org.dinky.scheduler.model.ProcessDefinition; -import org.dinky.scheduler.model.Project; +import org.dinky.scheduler.model.DinkyTaskRequest; import org.dinky.scheduler.model.TaskDefinition; import org.dinky.scheduler.model.TaskMainInfo; -import org.dinky.scheduler.model.TaskRequest; -import org.dinky.service.CatalogueService; +import org.dinky.service.SchedulerService; import java.util.List; -import javax.validation.Valid; - import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.google.common.base.Strings; - -import cn.hutool.json.JSONArray; -import cn.hutool.json.JSONObject; -import cn.hutool.json.JSONUtil; +import cn.hutool.core.collection.CollUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; @@ -68,13 +48,12 @@ @RequiredArgsConstructor public class SchedulerController { - public static final String TASK_TYPE = "DINKY"; - private final ProcessClient processClient; - private final TaskClient taskClient; - private final CatalogueService catalogueService; + private final SchedulerService schedulerService; - /** 获取任务定义 */ - @GetMapping("/task") + /** + * get task definition + */ + @GetMapping("/queryTaskDefinition") @ApiOperation("Get Task Definition") @ApiImplicitParam( name = "dinkyTaskId", @@ -84,37 +63,17 @@ public class SchedulerController { paramType = "query", example = "1") public Result getTaskDefinition(@ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId) { - Catalogue catalogue = - catalogueService.getOne(new LambdaQueryWrapper().eq(Catalogue::getTaskId, dinkyTaskId)); - if (catalogue == null) { - return Result.failed(Status.DS_GET_NODE_LIST_ERROR); - } - - Project dinkyProject = SystemInit.getProject(); - long projectCode = dinkyProject.getCode(); - - String processName = getDinkyNames(catalogue, 0); - String taskName = catalogue.getName() + ":" + catalogue.getId(); - TaskMainInfo taskMainInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName); - TaskDefinition taskDefinition = null; - if (taskMainInfo == null) { - return Result.succeed(taskDefinition); - } - - taskDefinition = taskClient.getTaskDefinition(projectCode, taskMainInfo.getTaskCode()); - if (taskDefinition == null) { - return Result.failed(Status.DS_WORK_FLOW_NOT_SAVE); + TaskDefinition taskDefinitionInfo = schedulerService.getTaskDefinitionInfo(dinkyTaskId); + if (taskDefinitionInfo == null) { + return Result.failed(Status.DS_TASK_NOT_EXIST); } - - taskDefinition.setProcessDefinitionCode(taskMainInfo.getProcessDefinitionCode()); - taskDefinition.setProcessDefinitionName(taskMainInfo.getProcessDefinitionName()); - taskDefinition.setProcessDefinitionVersion(taskMainInfo.getProcessDefinitionVersion()); - taskDefinition.setUpstreamTaskMap(taskMainInfo.getUpstreamTaskMap()); - return Result.succeed(taskDefinition); + return Result.succeed(taskDefinitionInfo); } - /** 获取前置任务定义集合 */ - @GetMapping("/upstream/tasks") + /** + * query upstream task + */ + @GetMapping("/queryUpstreamTasks") @ApiOperation("Get Upstream Task Definition") @ApiImplicitParam( name = "dinkyTaskId", @@ -124,186 +83,22 @@ public Result getTaskDefinition(@ApiParam(value = "dinky任务id paramType = "query", example = "1") public Result> getTaskMainInfos(@ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId) { - Catalogue catalogue = - catalogueService.getOne(new LambdaQueryWrapper().eq(Catalogue::getTaskId, dinkyTaskId)); - if (catalogue == null) { - return Result.failed(Status.DS_GET_NODE_LIST_ERROR); + List taskMainInfos = schedulerService.getTaskMainInfos(dinkyTaskId); + if (CollUtil.isEmpty(taskMainInfos)) { + return Result.failed(); } - - long projectCode = SystemInit.getProject().getCode(); - String processName = getDinkyNames(catalogue, 0); - List taskMainInfos = taskClient.getTaskMainInfos(projectCode, processName, ""); - // 去掉本身 - taskMainInfos.removeIf(taskMainInfo -> - (catalogue.getName() + ":" + catalogue.getId()).equalsIgnoreCase(taskMainInfo.getTaskName())); - return Result.succeed(taskMainInfos); } - /** 创建任务定义 */ - @PostMapping("/task") - @ApiOperation("Create Task Definition") - @ApiImplicitParams({ - @ApiImplicitParam( - name = "dinkyTaskId", - value = "Dinky Task id", - required = true, - dataType = "Long", - paramType = "query", - example = "1"), - @ApiImplicitParam( - name = "upstreamCodes", - value = "Upstream Task Codes", - required = false, - dataType = "String", - paramType = "query", - example = "1,2,3"), - @ApiImplicitParam( - name = "taskRequest", - value = "Task Request", - required = true, - dataType = "TaskRequest", - paramType = "body"), - }) - public Result createTaskDefinition( - @ApiParam(value = "前置任务编号 逗号隔开") @RequestParam(required = false) String upstreamCodes, - @ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId, - @Valid @RequestBody TaskRequest taskRequest) { - DinkyTaskParams dinkyTaskParams = new DinkyTaskParams(); - dinkyTaskParams.setTaskId(dinkyTaskId.toString()); - dinkyTaskParams.setAddress( - SystemConfiguration.getInstances().getDinkyAddr().getValue()); - taskRequest.setTaskParams(JSONUtil.parseObj(dinkyTaskParams).toString()); - taskRequest.setTaskType(TASK_TYPE); - - Catalogue catalogue = - catalogueService.getOne(new LambdaQueryWrapper().eq(Catalogue::getTaskId, dinkyTaskId)); - if (catalogue == null) { - return Result.failed(Status.DS_GET_NODE_LIST_ERROR); + /** + * create or update + */ + @PostMapping("/createOrUpdateTaskDefinition") + @ApiOperation("Create or Update Task Definition") + public Result createOrUpdateTaskDefinition(@RequestBody DinkyTaskRequest dinkyTaskRequest) { + if (schedulerService.pushAddTask(dinkyTaskRequest)) { + return Result.succeed(Status.DS_ADD_TASK_DEFINITION_SUCCESS); } - - String processName = getDinkyNames(catalogue, 0); - long projectCode = SystemInit.getProject().getCode(); - ProcessDefinition process = processClient.getProcessDefinitionInfo(projectCode, processName); - - String taskName = catalogue.getName() + ":" + catalogue.getId(); - taskRequest.setName(taskName); - if (process == null) { - Long taskCode = taskClient.genTaskCode(projectCode); - taskRequest.setCode(taskCode); - JSONObject jsonObject = JSONUtil.parseObj(taskRequest); - JSONArray array = new JSONArray(); - array.set(jsonObject); - processClient.createProcessDefinition(projectCode, processName, taskCode, array.toString()); - return Result.succeed(Status.DS_ADD_WORK_FLOW_DEFINITION_SUCCESS); - } - - if (process.getReleaseState() == ReleaseState.ONLINE) { - return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) processName); - } - - TaskMainInfo taskDefinitionInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName); - if (taskDefinitionInfo != null) { - return Result.failed(Status.DS_WORK_FLOW_DEFINITION_TASK_NAME_EXIST, processName, taskName); - } - - Long taskCode = taskClient.genTaskCode(projectCode); - taskRequest.setCode(taskCode); - - String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest); - taskClient.createTaskDefinition(projectCode, process.getCode(), upstreamCodes, taskDefinitionJsonObj); - return Result.succeed(Status.DS_ADD_TASK_DEFINITION_SUCCESS); } - - /** 更新任务定义 */ - @PutMapping("/task") - @ApiOperation("Update Task Definition") - @ApiImplicitParams({ - @ApiImplicitParam( - name = "projectCode", - value = "Project Code", - required = true, - dataType = "Long", - paramType = "query", - example = "1"), - @ApiImplicitParam( - name = "processCode", - value = "Process Code", - required = true, - dataType = "Long", - paramType = "query", - example = "1"), - @ApiImplicitParam( - name = "taskCode", - value = "Task Code", - required = true, - dataType = "Long", - paramType = "query", - example = "1"), - @ApiImplicitParam( - name = "upstreamCodes", - value = "Upstream Task Codes", - required = false, - dataType = "String", - paramType = "query", - example = "1,2,3") - }) - public Result updateTaskDefinition( - @ApiParam(value = "项目编号") @RequestParam long projectCode, - @ApiParam(value = "工作流定义编号") @RequestParam long processCode, - @ApiParam(value = "任务定义编号") @RequestParam long taskCode, - @ApiParam(value = "前置任务编号 逗号隔开") @RequestParam(required = false) String upstreamCodes, - @Valid @RequestBody TaskRequest taskRequest) { - - TaskDefinition taskDefinition = taskClient.getTaskDefinition(projectCode, taskCode); - if (taskDefinition == null) { - return Result.failed(Status.DS_TASK_NOT_EXIST); - } - - if (!TASK_TYPE.equals(taskDefinition.getTaskType())) { - return Result.failed(Status.DS_TASK_TYPE_NOT_SUPPORT, (Object) taskDefinition.getTaskType()); - } - - DagData dagData = processClient.getProcessDefinitionInfo(projectCode, processCode); - if (dagData == null) { - return Result.failed(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST); - } - - ProcessDefinition process = dagData.getProcessDefinition(); - if (process == null) { - return Result.failed(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST); - } - - if (process.getReleaseState() == ReleaseState.ONLINE) { - return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) process.getName()); - } - - taskRequest.setName(taskDefinition.getName()); - taskRequest.setTaskParams(taskDefinition.getTaskParams()); - taskRequest.setTaskType(TASK_TYPE); - - String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest); - taskClient.updateTaskDefinition(projectCode, taskCode, upstreamCodes, taskDefinitionJsonObj); - return Result.succeed(Status.MODIFY_SUCCESS); - } - - private String getDinkyNames(Catalogue catalogue, int i) { - if (i == 3 || catalogue.getParentId().equals(0)) { - return ""; - } - - catalogue = catalogueService.getById(catalogue.getParentId()); - if (catalogue == null) { - throw new SchedulerException("Get Node List Error"); - } - - String name = i == 0 ? catalogue.getName() + ":" + catalogue.getId() : catalogue.getName(); - String next = getDinkyNames(catalogue, ++i); - - if (Strings.isNullOrEmpty(next)) { - return name; - } - return name + "_" + next; - } } diff --git a/dinky-admin/src/main/java/org/dinky/init/SystemInit.java b/dinky-admin/src/main/java/org/dinky/init/SystemInit.java index 54ed238a80..8f2a62c021 100644 --- a/dinky-admin/src/main/java/org/dinky/init/SystemInit.java +++ b/dinky-admin/src/main/java/org/dinky/init/SystemInit.java @@ -225,33 +225,32 @@ private void initDaemon() { * init DolphinScheduler */ private void initDolphinScheduler() { - systemConfiguration - .getAllConfiguration() - .get("dolphinscheduler") - .forEach(c -> c.addParameterCheck(v -> { - if (Boolean.TRUE.equals( - systemConfiguration.getDolphinschedulerEnable().getValue())) { - if (StrUtil.isEmpty(Convert.toStr(v))) { - sysConfigService.updateSysConfigByKv( - systemConfiguration - .getDolphinschedulerEnable() - .getKey(), - "false"); - throw new DinkyException("Before starting DolphinScheduler" - + " docking, please fill in the" - + " relevant configuration"); - } - try { - project = projectClient.getDinkyProject(); - if (Asserts.isNull(project)) { - project = projectClient.createDinkyProject(); - } - } catch (Exception e) { - log.error("Error in DolphinScheduler: ", e); - throw new DinkyException(e); - } - } - })); + List> configurationList = + systemConfiguration.getAllConfiguration().get("dolphinscheduler"); + configurationList.forEach(c -> c.addParameterCheck(this::aboutDolphinSchedulerInitOperation)); + // init call for once + aboutDolphinSchedulerInitOperation("init"); + } + + private void aboutDolphinSchedulerInitOperation(Object v) { + if (Boolean.TRUE.equals(systemConfiguration.getDolphinschedulerEnable().getValue())) { + if (StrUtil.isEmpty(Convert.toStr(v))) { + sysConfigService.updateSysConfigByKv( + systemConfiguration.getDolphinschedulerEnable().getKey(), "false"); + throw new DinkyException("Before starting DolphinScheduler" + + " docking, please fill in the" + + " relevant configuration"); + } + try { + project = projectClient.getDinkyProject(); + if (Asserts.isNull(project)) { + project = projectClient.createDinkyProject(); + } + } catch (Exception e) { + log.error("Error in DolphinScheduler: ", e); + throw new DinkyException(e); + } + } } /** diff --git a/dinky-admin/src/main/java/org/dinky/service/SchedulerService.java b/dinky-admin/src/main/java/org/dinky/service/SchedulerService.java new file mode 100644 index 0000000000..54b04fc042 --- /dev/null +++ b/dinky-admin/src/main/java/org/dinky/service/SchedulerService.java @@ -0,0 +1,64 @@ +/* + * + * 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; + +import org.dinky.scheduler.model.DinkyTaskRequest; +import org.dinky.scheduler.model.TaskDefinition; +import org.dinky.scheduler.model.TaskMainInfo; + +import java.util.List; + +public interface SchedulerService { + + /** + * Pushes the specified DinkyTaskRequest to the task queue. + * + * @param dinkyTaskRequest the DinkyTaskRequest to be added to the task queue + * @return true if the task was successfully added, false otherwise + */ + boolean pushAddTask(DinkyTaskRequest dinkyTaskRequest); + + /** + * A description of the entire Java function. + * + * @param projectCode description of parameter + * @param processCode description of parameter + * @param taskCode description of parameter + * @param dinkyTaskRequest description of parameter + * @return description of return value + */ + boolean pushUpdateTask(long projectCode, long processCode, long taskCode, DinkyTaskRequest dinkyTaskRequest); + + /** + * Retrieves a list of TaskMainInfo objects based on the provided dinkyTaskId. + * + * @param dinkyTaskId the ID of the task + * @return a list of TaskMainInfo objects + */ + List getTaskMainInfos(long dinkyTaskId); + + /** + * Retrieves the task definition information for a given dinky task ID. + * + * @param dinkyTaskId the ID of the dinky task + * @return the task definition information + */ + TaskDefinition getTaskDefinitionInfo(long dinkyTaskId); +} 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 new file mode 100644 index 0000000000..bb3b76739b --- /dev/null +++ b/dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java @@ -0,0 +1,284 @@ +/* + * + * 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.data.enums.Status; +import org.dinky.data.exception.BusException; +import org.dinky.data.model.Catalogue; +import org.dinky.data.model.SystemConfiguration; +import org.dinky.init.SystemInit; +import org.dinky.scheduler.client.ProcessClient; +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.DinkyTaskParams; +import org.dinky.scheduler.model.DinkyTaskRequest; +import org.dinky.scheduler.model.ProcessDefinition; +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.service.CatalogueService; +import org.dinky.service.SchedulerService; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.google.common.base.Strings; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Service +@Slf4j +@RequiredArgsConstructor +public class SchedulerServiceImpl implements SchedulerService { + + public static final String TASK_TYPE = "DINKY"; + private final ProcessClient processClient; + private final TaskClient taskClient; + private final CatalogueService catalogueService; + + /** + * Pushes the specified DinkyTaskRequest to the task queue. + * + * @param dinkyTaskRequest the DinkyTaskRequest to be added to the task queue + * @return true if the task was successfully added, false otherwise + */ + @Override + public boolean pushAddTask(DinkyTaskRequest dinkyTaskRequest) { + + DinkyTaskParams dinkyTaskParams = new DinkyTaskParams(); + dinkyTaskParams.setTaskId(dinkyTaskRequest.getTaskId()); + dinkyTaskParams.setAddress( + SystemConfiguration.getInstances().getDinkyAddr().getValue()); + dinkyTaskRequest.setTaskParams(JSONUtil.parseObj(dinkyTaskParams).toString()); + dinkyTaskRequest.setTaskType(TASK_TYPE); + + Catalogue catalogue = catalogueService.getOne( + new LambdaQueryWrapper().eq(Catalogue::getTaskId, dinkyTaskRequest.getTaskId())); + if (catalogue == null) { + log.error(Status.DS_GET_NODE_LIST_ERROR.getMessage()); + throw new BusException(Status.DS_GET_NODE_LIST_ERROR); + } + + String processName = getDinkyNames(catalogue, 0); + long projectCode = SystemInit.getProject().getCode(); + ProcessDefinition process = processClient.getProcessDefinitionInfo(projectCode, processName); + + String taskName = catalogue.getName() + ":" + catalogue.getId(); + dinkyTaskRequest.setName(taskName); + + TaskRequest taskRequest = new TaskRequest(); + + if (process == null) { + Long taskCode = taskClient.genTaskCode(projectCode); + dinkyTaskRequest.setCode(taskCode); + BeanUtil.copyProperties(dinkyTaskRequest, taskRequest); + taskRequest.setTimeoutFlag(dinkyTaskRequest.getTimeoutFlag()); + taskRequest.setFlag(dinkyTaskRequest.getFlag()); + JSONObject jsonObject = JSONUtil.parseObj(taskRequest); + JSONArray array = new JSONArray(); + array.set(jsonObject); + processClient.createProcessDefinition(projectCode, processName, taskCode, array.toString()); + log.info(Status.DS_ADD_WORK_FLOW_DEFINITION_SUCCESS.getMessage()); + } + + if (process != null && process.getReleaseState() == ReleaseState.ONLINE) { + log.error(Status.DS_WORK_FLOW_DEFINITION_ONLINE.getMessage(), processName); + } + + TaskMainInfo taskMainInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName, "DINKY"); + if (taskMainInfo != null) { + // if task name exist, update task definition + log.warn(Status.DS_WORK_FLOW_DEFINITION_TASK_NAME_EXIST.getMessage(), processName, taskName); + return pushUpdateTask( + projectCode, taskMainInfo.getProcessDefinitionCode(), taskMainInfo.getTaskCode(), dinkyTaskRequest); + } + + Long taskCode = taskClient.genTaskCode(projectCode); + dinkyTaskRequest.setCode(taskCode); + BeanUtil.copyProperties(dinkyTaskRequest, taskRequest); + taskRequest.setTimeoutFlag(dinkyTaskRequest.getTimeoutFlag()); + taskRequest.setFlag(dinkyTaskRequest.getFlag()); + String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest); + if (process != null) { + taskClient.createTaskDefinition( + projectCode, process.getCode(), dinkyTaskRequest.getUpstreamCodes(), taskDefinitionJsonObj); + log.info(Status.DS_ADD_TASK_DEFINITION_SUCCESS.getMessage()); + return true; + } + return false; + } + + /** + * Pushes an update task to the API. + * + * @param projectCode the project code + * @param processCode the process code + * @param taskCode the task code + * @param dinkyTaskRequest the DinkyTaskRequest object containing task details + * @return true if the task is successfully updated, false otherwise + */ + @Override + public boolean pushUpdateTask( + long projectCode, long processCode, long taskCode, DinkyTaskRequest dinkyTaskRequest) { + TaskDefinition taskDefinition = taskClient.getTaskDefinition(projectCode, taskCode); + if (taskDefinition == null) { + log.error(Status.DS_TASK_NOT_EXIST.getMessage()); + throw new BusException(Status.DS_TASK_NOT_EXIST); + } + + if (!TASK_TYPE.equals(taskDefinition.getTaskType())) { + log.error(Status.DS_TASK_TYPE_NOT_SUPPORT.getMessage(), taskDefinition.getTaskType()); + throw new BusException(Status.DS_TASK_TYPE_NOT_SUPPORT, taskDefinition.getTaskType()); + } + + DagData dagData = processClient.getProcessDefinitionInfo(projectCode, processCode); + if (dagData == null) { + log.error(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST.getMessage()); + throw new BusException(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST); + } + + ProcessDefinition process = dagData.getProcessDefinition(); + if (process == null) { + log.error(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST.getMessage()); + throw new BusException(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST); + } + + if (process.getReleaseState() == ReleaseState.ONLINE) { + log.error(Status.DS_WORK_FLOW_DEFINITION_ONLINE.getMessage(), process.getName()); + throw new BusException(Status.DS_WORK_FLOW_DEFINITION_ONLINE, process.getName()); + } + TaskRequest taskRequest = new TaskRequest(); + + dinkyTaskRequest.setName(taskDefinition.getName()); + dinkyTaskRequest.setTaskParams(taskDefinition.getTaskParams()); + dinkyTaskRequest.setTaskType(TASK_TYPE); + BeanUtil.copyProperties(dinkyTaskRequest, taskRequest); + taskRequest.setTimeoutFlag(dinkyTaskRequest.getTimeoutFlag()); + taskRequest.setFlag(dinkyTaskRequest.getFlag()); + + String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest); + Long updatedTaskDefinition = taskClient.updateTaskDefinition( + projectCode, taskCode, dinkyTaskRequest.getUpstreamCodes(), taskDefinitionJsonObj); + if (updatedTaskDefinition != null && updatedTaskDefinition > 0) { + log.info(Status.MODIFY_SUCCESS.getMessage()); + return true; + } + log.error(Status.MODIFY_FAILED.getMessage()); + return false; + } + + /** + * Retrieves the list of TaskMainInfo objects for a given dinkyTaskId. + * + * @param dinkyTaskId the id of the dinky task + * @return the list of TaskMainInfo objects + */ + @Override + public List getTaskMainInfos(long dinkyTaskId) { + Catalogue catalogue = + catalogueService.getOne(new LambdaQueryWrapper().eq(Catalogue::getTaskId, dinkyTaskId)); + if (catalogue == null) { + log.error(Status.DS_GET_NODE_LIST_ERROR.getMessage()); + throw new BusException(Status.DS_GET_NODE_LIST_ERROR); + } + long projectCode = SystemInit.getProject().getCode(); + List taskMainInfos = taskClient.getTaskMainInfos(projectCode, "", "", ""); + // 去掉本身 + taskMainInfos.removeIf(taskMainInfo -> + (catalogue.getName() + ":" + catalogue.getId()).equalsIgnoreCase(taskMainInfo.getTaskName())); + return taskMainInfos; + } + + /** + * Retrieves the task definition information for a given dinkyTaskId. + * + * @param dinkyTaskId the ID of the dinky task + * @return the task definition information + */ + @Override + public TaskDefinition getTaskDefinitionInfo(long dinkyTaskId) { + Catalogue catalogue = + catalogueService.getOne(new LambdaQueryWrapper().eq(Catalogue::getTaskId, dinkyTaskId)); + if (catalogue == null) { + log.error(Status.DS_GET_NODE_LIST_ERROR.getMessage()); + throw new BusException(Status.DS_GET_NODE_LIST_ERROR); + } + + Project dinkyProject = SystemInit.getProject(); + long projectCode = dinkyProject.getCode(); + + String processName = getDinkyNames(catalogue, 0); + String taskName = catalogue.getName() + ":" + catalogue.getId(); + TaskMainInfo taskMainInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName, "DINKY"); + TaskDefinition taskDefinition = null; + if (taskMainInfo == null) { + log.error(Status.DS_WORK_FLOW_DEFINITION_TASK_NAME_EXIST.getMessage(), processName, taskName); + throw new BusException(Status.DS_WORK_FLOW_DEFINITION_TASK_NAME_EXIST, processName, taskName); + } + + taskDefinition = taskClient.getTaskDefinition(projectCode, taskMainInfo.getTaskCode()); + if (taskDefinition == null) { + log.error(Status.DS_WORK_FLOW_NOT_SAVE.getMessage()); + throw new BusException(Status.DS_WORK_FLOW_NOT_SAVE); + } + + taskDefinition.setProcessDefinitionCode(taskMainInfo.getProcessDefinitionCode()); + taskDefinition.setProcessDefinitionName(taskMainInfo.getProcessDefinitionName()); + taskDefinition.setProcessDefinitionVersion(taskMainInfo.getProcessDefinitionVersion()); + taskDefinition.setUpstreamTaskMap(taskMainInfo.getUpstreamTaskMap()); + return taskDefinition; + } + + /** + * Retrieves the dinky names from the given catalogue and index. + * + * @param catalogue the catalogue object to retrieve the names from + * @param i the index to start retrieving the names from + * @return the dinky names retrieved from the catalogue + */ + private String getDinkyNames(Catalogue catalogue, int i) { + if (i == 3 || catalogue.getParentId().equals(0)) { + return ""; + } + + catalogue = catalogueService.getById(catalogue.getParentId()); + if (catalogue == null) { + throw new SchedulerException("Get Node List Error"); + } + + String name = i == 0 ? catalogue.getName() + ":" + catalogue.getId() : catalogue.getName(); + String next = getDinkyNames(catalogue, ++i); + + if (Strings.isNullOrEmpty(next)) { + return name; + } + return name + "_" + next; + } +} diff --git a/dinky-common/src/main/java/org/dinky/data/exception/BusException.java b/dinky-common/src/main/java/org/dinky/data/exception/BusException.java index 7cfc2407ac..12fbe3f98e 100644 --- a/dinky-common/src/main/java/org/dinky/data/exception/BusException.java +++ b/dinky-common/src/main/java/org/dinky/data/exception/BusException.java @@ -22,6 +22,7 @@ import org.dinky.data.enums.Status; import cn.hutool.core.exceptions.ExceptionUtil; +import cn.hutool.core.util.StrUtil; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -58,6 +59,12 @@ public BusException(Status status) { setMsg(status.getMessage()); } + public BusException(Status status, Object... errorArgs) { + super(status.getMessage()); + setCode(String.valueOf(status.getCode())); + setMsg(StrUtil.format(status.getMessage(), errorArgs)); + } + public BusException(String message, Object... args) { super(); setCode(message); diff --git a/dinky-common/src/main/resources/i18n/messages_en_US.properties b/dinky-common/src/main/resources/i18n/messages_en_US.properties index aba5aac788..d58dddabf9 100644 --- a/dinky-common/src/main/resources/i18n/messages_en_US.properties +++ b/dinky-common/src/main/resources/i18n/messages_en_US.properties @@ -109,7 +109,7 @@ success=Successfully tenant.not.exist=Tenant Not Exist user.already.exists=User Already Exists git.building=Git Building -ds.work.flow.definition.task.name.exist=Add Failed, Workflow Definition [{}] Already Exists Task Definition [{}] Please Refresh +ds.work.flow.definition.task.name.exist=Workflow Definition [{}] Already Exists Task Definition [{}] , Will Update Operation role.already.exists=Role Already Exists internal.server.error.args=Internal Server Error: {0} kick.out=token has been kicked offline diff --git a/dinky-common/src/main/resources/i18n/messages_zh_CN.properties b/dinky-common/src/main/resources/i18n/messages_zh_CN.properties index 6a0793d2b2..00f0f60653 100644 --- a/dinky-common/src/main/resources/i18n/messages_zh_CN.properties +++ b/dinky-common/src/main/resources/i18n/messages_zh_CN.properties @@ -109,7 +109,7 @@ success=获取成功 tenant.not.exist=租户不存在 user.already.exists=用户名已存在 git.building=此任务正在构建 -ds.work.flow.definition.task.name.exist=添加失败,工作流定义 [{}] 已存在任务定义 [{}] 请刷新 +ds.work.flow.definition.task.name.exist=工作流定义 [{}] 已存在任务定义 [{}] , 将执行更新操作 role.already.exists=角色已存在 internal.server.error.args=服务端异常: {0} kick.out=token 已被踢下线 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 6b93e02196..feea21fc78 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 @@ -41,10 +41,12 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; /** 任务定义 */ @Component @@ -60,8 +62,8 @@ public class TaskClient { * @param taskName 任务定义名称 * @return {@link TaskMainInfo} */ - public TaskMainInfo getTaskMainInfo(Long projectCode, String processName, String taskName) { - List lists = getTaskMainInfos(projectCode, processName, taskName); + public TaskMainInfo getTaskMainInfo(Long projectCode, String processName, String taskName, String taskType) { + List lists = getTaskMainInfos(projectCode, processName, taskName, taskType); for (TaskMainInfo list : lists) { if (list.getTaskName().equalsIgnoreCase(taskName)) { return list; @@ -78,7 +80,7 @@ public TaskMainInfo getTaskMainInfo(Long projectCode, String processName, String * @param taskName 任务定义名称 * @return {@link List} */ - public List getTaskMainInfos(Long projectCode, String processName, String taskName) { + public List getTaskMainInfos(Long projectCode, String processName, String taskName, String taskType) { Map map = new HashMap<>(); map.put("projectCode", projectCode); String format = StrUtil.format( @@ -89,7 +91,7 @@ public List getTaskMainInfos(Long projectCode, String processName, Map pageParams = ParamUtil.getPageParams(); pageParams.put("searchTaskName", taskName); pageParams.put("searchWorkflowName", processName); - pageParams.put("taskType", "DINKY"); + pageParams.put("taskType", taskType); String content = HttpRequest.get(format) .header( @@ -109,9 +111,7 @@ public List getTaskMainInfos(Long projectCode, String processName, } for (JSONObject jsonObject : data.getTotalList()) { - if (processName.equalsIgnoreCase(jsonObject.getStr("processDefinitionName"))) { - lists.add(MyJSONUtil.toBean(jsonObject, TaskMainInfo.class)); - } + lists.add(JSONUtil.toBean(jsonObject, TaskMainInfo.class)); } return lists; } @@ -153,7 +153,7 @@ public TaskDefinition getTaskDefinition(Long projectCode, Long taskCode) { * @return {@link TaskDefinitionLog} */ public TaskDefinitionLog createTaskDefinition( - Long projectCode, Long processCode, String upstreamCodes, String taskDefinitionJsonObj) { + Long projectCode, Long processCode, List upstreamCodes, String taskDefinitionJsonObj) { Map map = new HashMap<>(); map.put("projectCode", projectCode); String format = StrUtil.format( @@ -163,8 +163,8 @@ public TaskDefinitionLog createTaskDefinition( Map pageParams = new HashMap<>(); pageParams.put("processDefinitionCode", processCode); - if (StringUtils.isNotBlank(upstreamCodes)) { - pageParams.put("upstreamCodes", upstreamCodes); + if (CollUtil.isNotEmpty(upstreamCodes)) { + pageParams.put("upstreamCodes", StringUtils.join(upstreamCodes, ",")); } pageParams.put("taskDefinitionJsonObj", taskDefinitionJsonObj); @@ -192,7 +192,7 @@ public TaskDefinitionLog createTaskDefinition( * @return {@link Long} */ public Long updateTaskDefinition( - long projectCode, long taskCode, String upstreamCodes, String taskDefinitionJsonObj) { + long projectCode, long taskCode, List upstreamCodes, String taskDefinitionJsonObj) { Map map = new HashMap<>(); map.put("projectCode", projectCode); map.put("code", taskCode); @@ -202,7 +202,9 @@ public Long updateTaskDefinition( map); Map params = new HashMap<>(); - params.put("upstreamCodes", upstreamCodes); + if (CollUtil.isNotEmpty(upstreamCodes)) { + params.put("upstreamCodes", StringUtils.join(upstreamCodes, ",")); + } params.put("taskDefinitionJsonObj", taskDefinitionJsonObj); String content = HttpRequest.put(format) diff --git a/dinky-scheduler/src/main/java/org/dinky/scheduler/model/DinkyTaskRequest.java b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/DinkyTaskRequest.java new file mode 100644 index 0000000000..a3546af14d --- /dev/null +++ b/dinky-scheduler/src/main/java/org/dinky/scheduler/model/DinkyTaskRequest.java @@ -0,0 +1,48 @@ +/* + * + * 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 org.dinky.data.model.SystemConfiguration; + +import java.util.Arrays; +import java.util.List; + +import javax.validation.constraints.NotNull; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class DinkyTaskRequest extends TaskRequest { + + @ApiModelProperty(value = "自定义参数") + private List localParams; + + @ApiModelProperty(value = "dinky地址") + @NotNull + private String address = SystemConfiguration.getInstances().getDinkyAddr().getValue(); + + @ApiModelProperty(value = "上游任务编号") + List upstreamCodes = Arrays.asList(); + + @ApiModelProperty(value = "dinky任务id", required = true) + @NotNull + private String taskId; +} 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 492daa1b1e..4e1dc395b9 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 @@ -19,11 +19,7 @@ package org.dinky.scheduler.model; -import org.dinky.scheduler.enums.Flag; -import org.dinky.scheduler.enums.Priority; import org.dinky.scheduler.enums.TaskExecuteType; -import org.dinky.scheduler.enums.TaskTimeoutStrategy; -import org.dinky.scheduler.enums.TimeoutFlag; import javax.validation.constraints.NotNull; @@ -55,14 +51,14 @@ public class TaskRequest { private Integer failRetryTimes; @ApiModelProperty(value = "运行标志 yes 正常/no 禁止执行") - private Flag flag; + private String flag; @ApiModelProperty(value = "任务参数 默认DINKY参数") private String taskParams; @NotNull @ApiModelProperty(value = "优先级") - private Priority taskPriority; + private String taskPriority; @ApiModelProperty(value = "任务类型 默认DINKY") private String taskType = "DINKY"; @@ -71,10 +67,10 @@ public class TaskRequest { private Integer timeout; @ApiModelProperty(value = "超时告警") - private TimeoutFlag timeoutFlag; + private String timeoutFlag; @ApiModelProperty(value = "超时通知策略") - private TaskTimeoutStrategy timeoutNotifyStrategy; + private String timeoutNotifyStrategy; @ApiModelProperty(value = "worker分组 默认default") private String workerGroup = "default"; diff --git a/dinky-web/src/components/Icons/CustomIcons.tsx b/dinky-web/src/components/Icons/CustomIcons.tsx index 98df12d06a..7bb597c2db 100644 --- a/dinky-web/src/components/Icons/CustomIcons.tsx +++ b/dinky-web/src/components/Icons/CustomIcons.tsx @@ -36,6 +36,34 @@ export const DangerDeleteIcon = (props: any) => { ); }; +export const PushpinIcon = (props: any) => { + return ( + <> + ( + + + + + )} + /> + + ); +}; + /** * This is a custom icon that is used to indicate a show log action. * @constructor diff --git a/dinky-web/src/locales/en-US/pages.ts b/dinky-web/src/locales/en-US/pages.ts index b9eeb72f1f..267374b83c 100644 --- a/dinky-web/src/locales/en-US/pages.ts +++ b/dinky-web/src/locales/en-US/pages.ts @@ -87,6 +87,33 @@ export default { 'datastudio.middle.qg.gitprojects': 'Git Projects', 'datastudio.middle.qg.resource': 'Resource', 'datastudio.middle.qg.udf': 'UDF', + 'datastudio.header.pushdolphin.title': 'Push task [ {name} ] to DolphinScheduler', + 'datastudio.header.pushdolphin.taskId': 'Dinky task encoding', + 'datastudio.header.pushdolphin.taskName': 'Task name: {name}', + 'datastudio.header.pushdolphin.taskNameExt': + 'Task type: {type} Process definition: {processDefinitionName}', + 'datastudio.header.pushdolphin.upstreamCodes': 'pre-task', + 'datastudio.header.pushdolphin.upstreamCodesTip': + 'After selecting the pre-task, the task will not be executed until the pre-task is successfully executed. Please choose wisely to avoid task circular dependencies. This platform does not do dependency checking', + 'datastudio.header.pushdolphin.taskPriority': 'Task Priority', + 'datastudio.header.pushdolphin.failRetryTimes': 'Number of retries', + 'datastudio.header.pushdolphin.failRetryInterval': 'Failure retry interval (minutes)', + 'datastudio.header.pushdolphin.failRetryIntervalPlaceholder': + 'Please enter the failure retry interval (minutes)', + 'datastudio.header.pushdolphin.delayTime': 'Delayed execution time (minutes)', + 'datastudio.header.pushdolphin.delayTimePlaceholder': + 'Please enter the delay execution time (minutes)', + 'datastudio.header.pushdolphin.timeoutFlag': 'Timeout alarm', + 'datastudio.header.pushdolphin.timeoutFlag.warn': 'Timeout warning', + 'datastudio.header.pushdolphin.timeoutFlag.failed': 'Timeout failed', + 'datastudio.header.pushdolphin.timeoutFlagTip': 'Please select a timeout warning', + 'datastudio.header.pushdolphin.flag': 'Run flag', + 'datastudio.header.pushdolphin.flagTip': 'Please select the run flag', + 'datastudio.header.pushdolphin.timeoutNotifyStrategy': 'Timeout notification strategy', + 'datastudio.header.pushdolphin.timeoutNotifyStrategyTip': + 'Please select a timeout notification strategy', + 'datastudio.header.pushdolphin.timeout': 'Timeout (minutes)', + 'datastudio.header.pushdolphin.timeoutPlaceholder': 'Please enter the timeout time (minutes)', 'datastudio.project.create.folder.name': 'Folder Name', 'datastudio.project.create.folder.name.placeholder': 'Please enter the folder name', 'datastudio.project.create.folder.tip': diff --git a/dinky-web/src/locales/zh-CN/pages.ts b/dinky-web/src/locales/zh-CN/pages.ts index e0e8056f6c..7b1bf25772 100644 --- a/dinky-web/src/locales/zh-CN/pages.ts +++ b/dinky-web/src/locales/zh-CN/pages.ts @@ -82,6 +82,30 @@ export default { 'datastudio.middle.qg.gitprojects': 'Git 项目', 'datastudio.middle.qg.resource': '资源', 'datastudio.middle.qg.udf': 'UDF', + 'datastudio.header.pushdolphin.title': '将任务 [ {name} ]推送至 DolphinScheduler', + 'datastudio.header.pushdolphin.taskId': 'Dinky任务编码', + 'datastudio.header.pushdolphin.taskName': 'Task名称: {name}', + 'datastudio.header.pushdolphin.taskNameExt': + 'Task类型: {type} 所属进程定义: {processDefinitionName}', + 'datastudio.header.pushdolphin.upstreamCodes': '前置任务', + 'datastudio.header.pushdolphin.upstreamCodesTip': + '选择前置任务后,任务将会在前置任务执行成功后才会执行,请合理选择,避免任务循环依赖,本平台不做依赖检查', + 'datastudio.header.pushdolphin.taskPriority': '任务优先级', + 'datastudio.header.pushdolphin.failRetryTimes': '重试次数', + 'datastudio.header.pushdolphin.failRetryInterval': '失败重试间隔(分钟)', + 'datastudio.header.pushdolphin.failRetryIntervalPlaceholder': '请输入失败重试间隔(分钟)', + 'datastudio.header.pushdolphin.delayTime': '延时执行时间(分钟)', + 'datastudio.header.pushdolphin.delayTimePlaceholder': '请输入延时执行时间(分钟)', + 'datastudio.header.pushdolphin.timeoutFlag': '超时告警', + 'datastudio.header.pushdolphin.timeoutFlag.warn': '超时告警', + 'datastudio.header.pushdolphin.timeoutFlag.failed': '超时失败', + 'datastudio.header.pushdolphin.timeoutFlagTip': '请选择超时警告', + 'datastudio.header.pushdolphin.flag': '运行标志', + 'datastudio.header.pushdolphin.flagTip': '请选择运行标志', + 'datastudio.header.pushdolphin.timeoutNotifyStrategy': '超时通知策略', + 'datastudio.header.pushdolphin.timeoutNotifyStrategyTip': '请选择超时通知策略', + 'datastudio.header.pushdolphin.timeout': '超时时间(分钟)', + 'datastudio.header.pushdolphin.timeoutPlaceholder': '请输入超时时间(分钟)', 'datastudio.project.create.folder.name': '目录名称', 'datastudio.project.create.folder.name.placeholder': '请输入目录名称', 'datastudio.project.create.folder.tip': '暂无作业,请点击左上角新建目录', diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/constants.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/constants.tsx new file mode 100644 index 0000000000..bd06adc173 --- /dev/null +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/constants.tsx @@ -0,0 +1,90 @@ +/* + * + * 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 { l } from '@/utils/intl'; +import { Badge, Space } from 'antd'; +import { CheckboxOptionType } from 'antd/es/checkbox/Group'; +import { DefaultOptionType } from 'antd/es/select'; + +/** + * priority list for select | 优先级列表 + */ +export const PriorityList: DefaultOptionType[] = [ + { + label: ( + + + Highest + + ), + value: 'HIGHEST', + key: 'HIGHEST' + }, + { + label: ( + + + High + + ), + value: 'HIGH', + key: 'HIGH' + }, + { + label: ( + + + Medium + + ), + value: 'MEDIUM', + key: 'MEDIUM' + }, + { + label: ( + + + Low + + ), + value: 'LOW', + key: 'LOW' + }, + { + label: ( + + + Lowest + + ), + value: 'LOWEST', + key: 'LOWEST' + } +]; + +export const TimeoutNotifyStrategy: CheckboxOptionType[] = [ + { + label: l('datastudio.header.pushdolphin.timeoutFlag.warn'), + value: 'WARN' + }, + { + label: l('datastudio.header.pushdolphin.timeoutFlag.failed'), + value: 'FAILED' + } +]; diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx new file mode 100644 index 0000000000..8c40293e92 --- /dev/null +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx @@ -0,0 +1,53 @@ +/* + * + * 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 { DolphinTaskDefinition, PushDolphinParams } from '@/types/Studio/data.d'; + +export const transformPushDolphinParams = ( + dolphinTaskDefinition: DolphinTaskDefinition, + pushDolphinParams: PushDolphinParams, + toFormValues: boolean +) => { + if (toFormValues && dolphinTaskDefinition) { + const transformValue: PushDolphinParams = { + ...pushDolphinParams, + description: dolphinTaskDefinition.description, + timeoutFlag: dolphinTaskDefinition.timeoutFlag === 'OPEN', + flag: dolphinTaskDefinition.flag === 'YES', + upstreamCodes: dolphinTaskDefinition.upstreamTaskMap + ? Object.keys(dolphinTaskDefinition.upstreamTaskMap) + : [], + timeoutNotifyStrategy: + dolphinTaskDefinition.timeoutNotifyStrategy === 'WARNFAILED' + ? ['WARN', 'FAILED'] + : [dolphinTaskDefinition.timeoutNotifyStrategy] + }; + return transformValue; + } else { + const falseTransformValue: DolphinTaskDefinition = { + ...dolphinTaskDefinition, + ...pushDolphinParams, + description: pushDolphinParams.description, + timeoutFlag: pushDolphinParams.timeoutFlag ? 'OPEN' : 'CLOSE', + flag: pushDolphinParams.flag ? 'YES' : 'NO', + timeoutNotifyStrategy: (pushDolphinParams.timeoutNotifyStrategy as string[]).join('') + }; + return falseTransformValue; + } +}; diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx new file mode 100644 index 0000000000..3b9d57456f --- /dev/null +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx @@ -0,0 +1,303 @@ +/* + * + * 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'; +import { + ModalForm, + ProFormCheckbox, + ProFormDigit, + ProFormGroup, + ProFormSelect, + ProFormSwitch, + ProFormText, + ProFormTextArea +} from '@ant-design/pro-components'; + +import { + PriorityList, + TimeoutNotifyStrategy +} from '@/pages/DataStudio/HeaderContainer/PushDolphin/constants'; +import { transformPushDolphinParams } from '@/pages/DataStudio/HeaderContainer/PushDolphin/function'; +import { TaskDataType } from '@/pages/DataStudio/model'; +import { + DolphinTaskDefinition, + DolphinTaskMinInfo, + PushDolphinParams +} from '@/types/Studio/data.d'; +import { InitPushDolphinParams } from '@/types/Studio/init.d'; +import { Button, Form, Tag } from 'antd'; +import { DefaultOptionType } from 'antd/es/select'; +import React from 'react'; + +type PushDolphinProps = { + onCancel: () => void; + dolphinTaskList: DolphinTaskMinInfo[]; + dolphinDefinitionTask: Partial; + modalVisible: boolean; + currentDinkyTaskValue: Partial; + loading: boolean; + onSubmit: (values: DolphinTaskDefinition) => void; +}; + +export const PushDolphin: React.FC = (props) => { + const { + onCancel, + onSubmit, + modalVisible, + dolphinTaskList, + dolphinDefinitionTask, + currentDinkyTaskValue, + loading + } = props; + + const [formValues, setFormValues] = React.useState( + transformPushDolphinParams( + dolphinDefinitionTask as DolphinTaskDefinition, + { ...InitPushDolphinParams, taskId: currentDinkyTaskValue?.id ?? '' }, + true + ) as PushDolphinParams + ); + + /** + * init form + */ + const [form] = Form.useForm(); + + /** + * init form context + */ + const formContext = React.useMemo( + () => ({ + resetForm: () => form.resetFields() // 定义 resetForm 方法 + }), + [form] + ); + + /** + * cancel choose + */ + const handleCancel = () => { + onCancel(); + formContext.resetForm(); + }; + + const handlePushDolphinSubmit = async () => { + const values = form.validateFields(); + if (!values) { + return; + } + const transformPushDolphinParamsValue: DolphinTaskDefinition = transformPushDolphinParams( + dolphinDefinitionTask as DolphinTaskDefinition, + formValues, + false + ) as DolphinTaskDefinition; + onSubmit(transformPushDolphinParamsValue); + console.log('transformPushDolphinParamsValue', transformPushDolphinParamsValue); + }; + + const renderFooter = () => { + return [ + , + + ]; + }; + + const buildUpstreamTaskOptions = ( + data: DolphinTaskMinInfo[] | undefined + ): DefaultOptionType[] => { + if (data && data.length > 0) { + return data.map((item) => { + const label = ( + <> + + {l('datastudio.header.pushdolphin.taskName', '', { name: item.taskName })} + + + {l('datastudio.header.pushdolphin.taskNameExt', '', { + type: item.taskType, + processDefinitionName: item.processDefinitionName + })} + + + ); + return { + label: label, + value: item.taskCode.toString(), + key: item.taskCode + }; + }); + } + return []; + }; + + const handleValueChange = (changedValues: any, allValues: any) => { + if (allValues) { + setFormValues({ ...formValues, ...allValues }); + } + }; + + const pushDolphinForm = () => { + return ( + <> + + + + + + + + + + + + + + + + + {/*如果是失败告警,则需要设置告警策略*/} + {formValues.timeoutFlag && ( + <> + + + + + + )} + + + + ); + }; + + return ( + + {...NORMAL_MODAL_OPTIONS} + title={l('datastudio.header.pushdolphin.title', '', { + name: currentDinkyTaskValue?.name ?? '' + })} + open={modalVisible} + form={form} + initialValues={formValues} + modalProps={{ + onCancel: handleCancel, + destroyOnClose: true + }} + submitter={{ render: () => [...renderFooter()] }} + onValuesChange={handleValueChange} + loading={loading} + > + {pushDolphinForm()} + + ); +}; + +export default PushDolphin; diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/function.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/function.tsx index 645fc93b6c..7e5be0a46c 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/function.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/function.tsx @@ -17,8 +17,10 @@ * */ +import { isSql } from '@/pages/DataStudio/HeaderContainer/service'; import { TabsPageType, TaskDataType } from '@/pages/DataStudio/model'; import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants'; +import { DIALECT } from '@/services/constants'; import { EnvironmentOutlined } from '@ant-design/icons'; /** @@ -46,3 +48,14 @@ export const isOnline = (data: TaskDataType | undefined) => { export const isRunning = (data: TaskDataType | undefined) => { return data ? JOB_STATUS.RUNNING == data.status : false; }; + +export const isCanPushDolphin = (data: TaskDataType | undefined) => { + return data + ? JOB_LIFE_CYCLE.PUBLISH === data.step && + !isSql(data?.dialect) && + data?.dialect?.toLowerCase() !== DIALECT.FLINKSQLENV && + data?.dialect?.toLowerCase() !== DIALECT.SCALA && + data?.dialect?.toLowerCase() !== DIALECT.JAVA && + data?.dialect?.toLowerCase() !== DIALECT.PYTHON_LONG + : false; +}; diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx index 02bb88b056..c899f75155 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx @@ -18,33 +18,42 @@ */ import { LoadingBtn } from '@/components/CallBackButton/LoadingBtn'; +import { PushpinIcon } from '@/components/Icons/CustomIcons'; import { FlexCenterDiv } from '@/components/StyledComponents'; import { getCurrentData, getCurrentTab, mapDispatchToProps } from '@/pages/DataStudio/function'; import Explain from '@/pages/DataStudio/HeaderContainer/Explain'; import FlinkGraph from '@/pages/DataStudio/HeaderContainer/FlinkGraph'; import { buildBreadcrumbItems, + isCanPushDolphin, isOnline, isRunning, projectCommonShow } from '@/pages/DataStudio/HeaderContainer/function'; +import PushDolphin from '@/pages/DataStudio/HeaderContainer/PushDolphin'; import { cancelTask, changeTaskLife, debugTask, executeSql, - getJobPlan, isSql + getJobPlan, + isSql } from '@/pages/DataStudio/HeaderContainer/service'; -import { DataStudioTabsItemType, StateType, TabsPageType, VIEW } from '@/pages/DataStudio/model'; +import { + DataStudioTabsItemType, + StateType, + TabsPageType, + TaskDataType, + VIEW +} from '@/pages/DataStudio/model'; import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants'; -import { ConfigStateType } from '@/pages/SettingCenter/GlobalSetting/model'; +import { SysConfigStateType } from '@/pages/SettingCenter/GlobalSetting/model'; import { SettingConfigKeyEnum } from '@/pages/SettingCenter/GlobalSetting/SettingOverView/constants'; -import { handlePutDataJson } from '@/services/BusinessCrud'; +import { handleOption, handlePutDataJson, queryDataByParams } from '@/services/BusinessCrud'; import { DIALECT } from '@/services/constants'; -import { BaseConfigProperties } from '@/types/SettingCenter/data'; +import { DolphinTaskDefinition, DolphinTaskMinInfo } from '@/types/Studio/data.d'; import { l } from '@/utils/intl'; import { SuccessMessageAsync } from '@/utils/messages'; -import { connect } from '@@/exports'; import { ApartmentOutlined, BugOutlined, @@ -56,9 +65,9 @@ import { PauseOutlined, RotateRightOutlined, SaveOutlined, - ScheduleOutlined, - SendOutlined + ScheduleOutlined } from '@ant-design/icons'; +import { connect } from '@umijs/max'; import { Breadcrumb, Descriptions, Modal, Space } from 'antd'; import { ButtonProps } from 'antd/es/button/button'; import React, { memo, useEffect, useState } from 'react'; @@ -83,7 +92,7 @@ type ButtonRoute = { props?: ButtonProps; }; -const HeaderContainer = (props: any) => { +const HeaderContainer = (props: connect) => { const { size, activeBreadcrumbTitle, @@ -91,26 +100,66 @@ const HeaderContainer = (props: any) => { saveTabs, updateJobRunningMsg, queryDsConfig, - dsConfig + enabledDs } = props; const [modal, contextHolder] = Modal.useModal(); - // 检查是否开启 ds 配置 & 如果 - const [enableDs] = useState( - dsConfig.some( - (item: BaseConfigProperties) => - item.key === 'dolphinscheduler.settings.enable' && item.value === 'true' - ) - ); - - const currentData = getCurrentData(panes, activeKey); - const currentTab = getCurrentTab(panes, activeKey) as DataStudioTabsItemType; + const [pushDolphinState, setPushDolphinState] = useState<{ + modalVisible: boolean; + buttonLoading: boolean; + confirmLoading: boolean; + dolphinTaskList: DolphinTaskMinInfo[]; + dolphinDefinitionTask: Partial; + currentDinkyTaskValue: Partial; + }>({ + modalVisible: false, + buttonLoading: false, + confirmLoading: false, + dolphinTaskList: [], + dolphinDefinitionTask: {}, + currentDinkyTaskValue: {} + }); useEffect(() => { queryDsConfig(SettingConfigKeyEnum.DOLPHIN_SCHEDULER.toLowerCase()); }, []); + const currentData = getCurrentData(panes, activeKey); + const currentTab = getCurrentTab(panes, activeKey) as DataStudioTabsItemType; + + const handlePushDolphinOpen = async () => { + const dinkyTaskId = currentData?.id; + const dolphinTaskList: DolphinTaskMinInfo[] | undefined = await queryDataByParams< + DolphinTaskMinInfo[] + >('/api/scheduler/queryUpstreamTasks', { dinkyTaskId }); + const dolphinTaskDefinition: DolphinTaskDefinition | undefined = + await queryDataByParams('/api/scheduler/queryTaskDefinition', { + dinkyTaskId + }); + setPushDolphinState((prevState) => ({ + ...prevState, + buttonLoading: true, + confirmLoading: false, + modalVisible: true, + dolphinTaskList: dolphinTaskList ?? [], + dolphinDefinitionTask: dolphinTaskDefinition ?? {}, + currentDinkyTaskValue: currentData as TaskDataType + })); + }; + + const handlePushDolphinCancel = async () => { + setPushDolphinState((prevState) => ({ + ...prevState, + modalVisible: false, + buttonLoading: false, + dolphinTaskList: [], + confirmLoading: false, + dolphinDefinitionTask: {}, + currentDinkyTaskValue: {} + })); + }; + const handleSave = async () => { const saved = await handlePutDataJson('/api/task', currentData); saveTabs({ ...props.tabs }); @@ -178,7 +227,7 @@ const HeaderContainer = (props: any) => { await SuccessMessageAsync(l('pages.datastudio.editor.exec.success')); currentData.status = JOB_STATUS.RUNNING; // Common sql task is synchronized, so it needs to automatically update the status to finished. - if(isSql(currentData.dialect)){ + if (isSql(currentData.dialect)) { currentData.status = JOB_STATUS.FINISHED; } if (currentTab) currentTab.console.result = res.data.result; @@ -270,10 +319,11 @@ const HeaderContainer = (props: any) => { }, { // 推送海豚, 此处需要将系统设置中的 ds 的配置拿出来做判断 启用才展示 - icon: , + icon: , title: l('button.push'), hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's', - isShow: enableDs + isShow: enabledDs && isCanPushDolphin(currentData), + click: () => handlePushDolphinOpen() }, { // 发布按钮 @@ -416,6 +466,16 @@ const HeaderContainer = (props: any) => { ); }; + const handlePushDolphinSubmit = async (value: DolphinTaskDefinition) => { + setPushDolphinState((prevState) => ({ ...prevState, loading: true })); + await handleOption( + '/api/scheduler/createOrUpdateTaskDefinition', + `推送任务[${currentData?.name}]至 DolphinScheduler`, + value + ); + await handlePushDolphinCancel(); + }; + /** * render */ @@ -424,15 +484,27 @@ const HeaderContainer = (props: any) => { {renderBreadcrumbItems()} {renderRightButtons()} + {pushDolphinState.modalVisible && ( + handlePushDolphinCancel()} + currentDinkyTaskValue={pushDolphinState.currentDinkyTaskValue} + modalVisible={pushDolphinState.modalVisible} + loading={pushDolphinState.confirmLoading} + dolphinDefinitionTask={pushDolphinState.dolphinDefinitionTask} + dolphinTaskList={pushDolphinState.dolphinTaskList} + onSubmit={(values) => handlePushDolphinSubmit(values)} + /> + )} ); }; export default connect( - ({ Studio, Config }: { Studio: StateType; Config: ConfigStateType }) => ({ + ({ Studio, SysConfig }: { Studio: StateType; SysConfig: SysConfigStateType }) => ({ tabs: Studio.tabs, - dsConfig: Config.dsConfig + dsConfig: SysConfig.dsConfig, + enabledDs: SysConfig.enabledDs }), mapDispatchToProps )(memo(HeaderContainer)); diff --git a/dinky-web/src/pages/SettingCenter/GlobalSetting/model.ts b/dinky-web/src/pages/SettingCenter/GlobalSetting/model.ts index 15faf0f1f7..1d19f21703 100644 --- a/dinky-web/src/pages/SettingCenter/GlobalSetting/model.ts +++ b/dinky-web/src/pages/SettingCenter/GlobalSetting/model.ts @@ -23,25 +23,30 @@ import { createModelTypes } from '@/utils/modelUtils'; import { Effect } from '@@/plugin-dva/types'; import { Reducer } from 'umi'; -export type ConfigStateType = { +const SYS_CONFIG = 'SysConfig'; + +export type SysConfigStateType = { dsConfig: BaseConfigProperties[]; + enabledDs: boolean; }; export type ConfigModelType = { namespace: string; - state: ConfigStateType; + state: SysConfigStateType; effects: { queryDsConfig: Effect; }; reducers: { - saveDsConfig: Reducer; + saveDsConfig: Reducer; + updateEnabledDs: Reducer; }; }; const ConfigModel: ConfigModelType = { - namespace: 'Config', + namespace: SYS_CONFIG, state: { - dsConfig: [] + dsConfig: [], + enabledDs: false }, effects: { @@ -51,6 +56,16 @@ const ConfigModel: ConfigModelType = { type: 'saveDsConfig', payload: response || [] }); + if (response && response.length > 0) { + const enabledDs = response.some( + (item: BaseConfigProperties) => + item.key === 'sys.dolphinscheduler.settings.enable' && item.value === true + ); + yield put({ + type: 'updateEnabledDs', + payload: enabledDs + }); + } } }, @@ -60,6 +75,12 @@ const ConfigModel: ConfigModelType = { ...state, dsConfig: payload }; + }, + updateEnabledDs(state, { payload }) { + return { + ...state, + enabledDs: payload + }; } } }; diff --git a/dinky-web/src/types/Studio/data.d.ts b/dinky-web/src/types/Studio/data.d.ts index 21f1acc7e4..befd454d1e 100644 --- a/dinky-web/src/types/Studio/data.d.ts +++ b/dinky-web/src/types/Studio/data.d.ts @@ -227,3 +227,83 @@ export enum JobStatus { RECONNECTING = 'RECONNECTING', UNKNOWN = 'UNKNOWN' } + +/** + * DolphinTaskMinInfo + */ +export interface DolphinTaskMinInfo { + id: number; + taskName: string; + taskCode: number; + taskVersion: number; + taskType: string; + taskCreateTime: Date; + taskUpdateTime: Date; + processDefinitionCode: number; + processDefinitionVersion: number; + processDefinitionName: string; + processReleaseState: string; + upstreamTaskMap: Map; + upstreamTaskCode: number; + upstreamTaskName: string; +} + +export interface TaskParamProperty { + prop: string; + direct: string; + type: string; + value: string; +} + +export interface DolphinTaskDefinition { + id: number; + code: number; + name: string; + version: number; + description: string; + projectCode: number; + userId: number; + taskType: string; + taskParams: Map; + taskParamList: TaskParamProperty[]; + taskParamMap: Map; + flag: string; // 0 no 1 yes + taskPriority: string; // 0 highest 1 high 2 medium 3 low 4 lowest + userName: string; + projectName: string; + workerGroup: string; + environmentCode: number; + failRetryTimes: number; + failRetryInterval: number; + timeoutFlag: string; // 0 close 1 open + timeoutNotifyStrategy: string; // 0 warning 1 failure 2 warning and failure + timeout: number; + delayTime: number; + resourceIds: string; + createTime: Date; + updateTime: Date; + modifyBy: string; + taskGroupId: number; + taskGroupPriority: number; + cpuQuota: number; + memoryMax: number; + taskExecuteType: number; // 0 batch 1 stream + processDefinitionCode: number; + processDefinitionVersion: number; + processDefinitionName: string; + upstreamTaskMap: Map; +} + +export interface PushDolphinParams { + taskId: number | string; + upstreamCodes: string[]; + taskPriority: string; + failRetryTimes: number; + failRetryInterval: number; + delayTime: number; + timeout: number; + timeoutFlag: boolean | string; + flag: boolean | string; + timeoutNotifyStrategy: string[] | string; + description: string; +} diff --git a/dinky-web/src/types/Studio/init.d.ts b/dinky-web/src/types/Studio/init.d.ts index e777d8f57c..95f2ab51ff 100644 --- a/dinky-web/src/types/Studio/init.d.ts +++ b/dinky-web/src/types/Studio/init.d.ts @@ -18,7 +18,8 @@ */ import { InitContextMenuPosition } from '@/types/Public/state.d'; -import { ProjectState } from '@/types/Studio/state.d'; +import {CateLogState, ProjectState} from '@/types/Studio/state.d'; +import {PushDolphinParams} from "@/types/Studio/data"; export const InitProjectState: ProjectState = { rightActiveKey: '', @@ -36,3 +37,36 @@ export const InitProjectState: ProjectState = { isCut: false, value: {} }; + + +export const InitPushDolphinParams: PushDolphinParams ={ + taskId: '', + upstreamCodes: [], + taskPriority: 'MEDIUM', + failRetryTimes: 0, + failRetryInterval: 0, + delayTime: 0, + timeout: 30, + timeoutFlag: false, + flag: false, + timeoutNotifyStrategy: ['WARN'], + description: '', +} + + +export const InitCateLogState: CateLogState = { + catalog: '', + catalogSelect: [], + databaseName: '', + databaseId: -1, + tableName: '', + dialect: '', + fragment: true, + envId: -1, + engine: 'Flink', + treeData: [], + modalVisit: false, + rowData: {}, + loading: false, + columnData: [] +} From 17c30988eeca604b7c439b51418da9d7d3a080c5 Mon Sep 17 00:00:00 2001 From: Zzm0809 Date: Sat, 16 Dec 2023 13:58:38 +0000 Subject: [PATCH 2/2] Spotless Apply --- .../DataStudio/BottomContainer/Result/index.tsx | 2 +- dinky-web/src/types/Studio/init.d.ts | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx b/dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx index 6f4b8f9fd6..152bf6e88c 100644 --- a/dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx +++ b/dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx @@ -26,6 +26,7 @@ import { import { isSql } from '@/pages/DataStudio/HeaderContainer/service'; import { StateType } from '@/pages/DataStudio/model'; import { handleGetOption, handleGetOptionWithoutMsg } from '@/services/BusinessCrud'; +import { DIALECT } from '@/services/constants'; import { API_CONSTANTS } from '@/services/endpoints'; import { transformTableDataToCsv } from '@/utils/function'; import { l } from '@/utils/intl'; @@ -37,7 +38,6 @@ import { FilterConfirmProps } from 'antd/es/table/interface'; import { DataIndex } from 'rc-table/es/interface'; import { useEffect, useRef, useState } from 'react'; import { connect } from 'umi'; -import {DIALECT} from "@/services/constants"; type Data = { [c: string]: any; diff --git a/dinky-web/src/types/Studio/init.d.ts b/dinky-web/src/types/Studio/init.d.ts index 95f2ab51ff..21ac446411 100644 --- a/dinky-web/src/types/Studio/init.d.ts +++ b/dinky-web/src/types/Studio/init.d.ts @@ -18,8 +18,8 @@ */ import { InitContextMenuPosition } from '@/types/Public/state.d'; -import {CateLogState, ProjectState} from '@/types/Studio/state.d'; -import {PushDolphinParams} from "@/types/Studio/data"; +import { PushDolphinParams } from '@/types/Studio/data'; +import { CateLogState, ProjectState } from '@/types/Studio/state.d'; export const InitProjectState: ProjectState = { rightActiveKey: '', @@ -38,8 +38,7 @@ export const InitProjectState: ProjectState = { value: {} }; - -export const InitPushDolphinParams: PushDolphinParams ={ +export const InitPushDolphinParams: PushDolphinParams = { taskId: '', upstreamCodes: [], taskPriority: 'MEDIUM', @@ -50,9 +49,8 @@ export const InitPushDolphinParams: PushDolphinParams ={ timeoutFlag: false, flag: false, timeoutNotifyStrategy: ['WARN'], - description: '', -} - + description: '' +}; export const InitCateLogState: CateLogState = { catalog: '', @@ -69,4 +67,4 @@ export const InitCateLogState: CateLogState = { rowData: {}, loading: false, columnData: [] -} +};