From acec1e209627cb215b177fe0b920ef7ce0011978 Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Sat, 23 Dec 2023 17:53:08 +0800 Subject: [PATCH 1/7] Fix added flinksqlenv after show bug (#2726) * Spotless Apply * Spotless Apply * fix-addedflinksqlenv-after-showbug * Spotless Apply --------- Co-authored-by: Zzm0809 --- .../pages/DataStudio/LeftContainer/Project/index.tsx | 4 ++++ dinky-web/src/pages/DataStudio/model.ts | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx b/dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx index c21931e823..af6012d9e1 100644 --- a/dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx +++ b/dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx @@ -46,6 +46,7 @@ import { handlePutDataByParams, handleRemoveById } from '@/services/BusinessCrud'; +import { DIALECT } from '@/services/constants'; import { API_CONSTANTS } from '@/services/endpoints'; import { Catalogue } from '@/types/Studio/data.d'; import { InitProjectState } from '@/types/Studio/init.d'; @@ -222,6 +223,9 @@ const Project: React.FC = (props: connect) => { ...prevState })); dispatch({ type: STUDIO_MODEL_ASYNC.queryProject }); + if (values.type && values.type.toLowerCase() === DIALECT.FLINKSQLENV) { + dispatch({ type: STUDIO_MODEL_ASYNC.queryEnv }); + } if (projectState.isEdit) { const { id } = values; const currentTabs = getTabByTaskId(panes, id); diff --git a/dinky-web/src/pages/DataStudio/model.ts b/dinky-web/src/pages/DataStudio/model.ts index 1f3ac5e958..c35e330be8 100644 --- a/dinky-web/src/pages/DataStudio/model.ts +++ b/dinky-web/src/pages/DataStudio/model.ts @@ -20,6 +20,7 @@ import { getFooterValue, isDataStudioTabsItemType } from '@/pages/DataStudio/function'; import { getTaskData } from '@/pages/DataStudio/LeftContainer/Project/service'; import { + getEnvData, getFlinkConfigs, querySuggessionData } from '@/pages/DataStudio/RightContainer/JobConfig/service'; @@ -303,6 +304,7 @@ export type ModelType = { queryProject: Effect; queryFlinkConfigOptions: Effect; querySuggestions: Effect; + queryEnv: Effect; }; reducers: { updateToolContentHeight: Reducer; @@ -411,6 +413,14 @@ const Model: ModelType = { payload: response }); }, + *queryEnv({ payload }, { call, put }) { + const response: EnvType[] = yield call(getEnvData, payload); + console.log(response); + yield put({ + type: 'saveEnv', + payload: response + }); + }, *queryFlinkConfigOptions({ payload }, { call, put }) { const response: [] = yield call(getFlinkConfigs, payload); yield put({ From 2d673126a0c81f074c429b295a4da90643fabbe8 Mon Sep 17 00:00:00 2001 From: gaoyan Date: Sat, 23 Dec 2023 20:48:22 +0800 Subject: [PATCH 2/7] Add normal stop (#2727) * fix log error * Add a normal stop --- .../org/dinky/controller/APIController.java | 6 +- .../org/dinky/controller/TaskController.java | 4 +- .../java/org/dinky/service/TaskService.java | 2 +- .../dinky/service/impl/TaskServiceImpl.java | 6 +- .../main/java/org/dinky/job/JobManager.java | 24 ++++--- .../DataStudio/HeaderContainer/service.tsx | 20 ++++-- .../JobDetail/JobOperator/JobOperator.tsx | 63 ++++++++----------- dinky-web/src/services/endpoints.tsx | 2 +- 8 files changed, 67 insertions(+), 60 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 4a0d1c6b94..80f9df38c3 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/APIController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/APIController.java @@ -95,8 +95,10 @@ public Result submitTask(@RequestBody TaskSubmitDto submitDto) throws @GetMapping("/cancel") // @Log(title = "Cancel Flink Job", businessType = BusinessType.TRIGGER) @ApiOperation("Cancel Flink Job") - public Result cancel(@RequestParam Integer id) { - return Result.succeed(taskService.cancelTaskJob(taskService.getTaskInfoById(id)), Status.EXECUTE_SUCCESS); + public Result cancel( + @RequestParam Integer id, @RequestParam(defaultValue = "false") boolean withSavePoint) { + return Result.succeed( + taskService.cancelTaskJob(taskService.getTaskInfoById(id), withSavePoint), Status.EXECUTE_SUCCESS); } /** diff --git a/dinky-admin/src/main/java/org/dinky/controller/TaskController.java b/dinky-admin/src/main/java/org/dinky/controller/TaskController.java index 9966b34bf1..e7a5c2d329 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/TaskController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/TaskController.java @@ -106,8 +106,8 @@ public Result debugTask(@RequestBody TaskDTO task) throws Exception { @GetMapping("/cancel") @Log(title = "Cancel Flink Job", businessType = BusinessType.TRIGGER) @ApiOperation("Cancel Flink Job") - public Result cancel(@RequestParam Integer id) { - if (taskService.cancelTaskJob(taskService.getTaskInfoById(id))) { + public Result cancel(@RequestParam Integer id, @RequestParam(defaultValue = "false") boolean withSavePoint) { + if (taskService.cancelTaskJob(taskService.getTaskInfoById(id), withSavePoint)) { return Result.succeed(Status.EXECUTE_SUCCESS); } else { return Result.failed(Status.EXECUTE_FAILED); diff --git a/dinky-admin/src/main/java/org/dinky/service/TaskService.java b/dinky-admin/src/main/java/org/dinky/service/TaskService.java index 0bad25193c..6fd411e55b 100644 --- a/dinky-admin/src/main/java/org/dinky/service/TaskService.java +++ b/dinky-admin/src/main/java/org/dinky/service/TaskService.java @@ -114,7 +114,7 @@ public interface TaskService extends ISuperService { * @param task The {@link TaskDTO} object representing the task to cancel. * @return true if the task job is successfully cancelled, false otherwise. */ - boolean cancelTaskJob(TaskDTO task); + boolean cancelTaskJob(TaskDTO task, boolean withSavePoint); /** * Get the stream graph of the given task job. diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java index 7b6157afb0..cb8855ba06 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java @@ -367,7 +367,7 @@ public JobResult restartTask(Integer id, String savePointPath) throws Exception if (!Dialect.isCommonSql(task.getDialect()) && Asserts.isNotNull(task.getJobInstanceId())) { String status = jobInstanceService.getById(task.getJobInstanceId()).getStatus(); if (!JobStatus.isDone(status)) { - cancelTaskJob(task); + cancelTaskJob(task, true); } } return submitTask( @@ -375,7 +375,7 @@ public JobResult restartTask(Integer id, String savePointPath) throws Exception } @Override - public boolean cancelTaskJob(TaskDTO task) { + public boolean cancelTaskJob(TaskDTO task, boolean withSavePoint) { if (Dialect.isCommonSql(task.getDialect())) { return true; } @@ -385,7 +385,7 @@ public boolean cancelTaskJob(TaskDTO task) { Assert.notNull(clusterInstance, Status.CLUSTER_NOT_EXIST.getMessage()); JobManager jobManager = JobManager.build(buildJobConfig(task)); - return jobManager.cancel(jobInstance.getJid()); + return jobManager.cancel(jobInstance.getJid(), withSavePoint); } @Override diff --git a/dinky-core/src/main/java/org/dinky/job/JobManager.java b/dinky-core/src/main/java/org/dinky/job/JobManager.java index 8163dc552a..2c53a6d2c0 100644 --- a/dinky-core/src/main/java/org/dinky/job/JobManager.java +++ b/dinky-core/src/main/java/org/dinky/job/JobManager.java @@ -28,6 +28,7 @@ import org.dinky.context.RowLevelPermissionsContext; import org.dinky.data.annotations.ProcessStep; import org.dinky.data.enums.ProcessStepType; +import org.dinky.data.exception.BusException; import org.dinky.data.model.SystemConfiguration; import org.dinky.data.result.ErrorResult; import org.dinky.data.result.ExplainResult; @@ -378,27 +379,32 @@ public String getJobPlanJson(String statement) { .getJsonPlan(); } - public boolean cancel(String jobId) { + public boolean cancel(String jobId, boolean withSavePoint) { if (useGateway && !useRestAPI) { config.getGatewayConfig() .setFlinkConfig(FlinkConfig.build(jobId, ActionType.CANCEL.getValue(), null, null)); Gateway.build(config.getGatewayConfig()).savepointJob(); return true; - } else if (useRestAPI) { + } else if (useRestAPI && withSavePoint) { try { // Try to savepoint, if it fails, it will stop normally(尝试进行savepoint,如果失败,即普通停止) savepoint(jobId, SavePointType.CANCEL, null); return true; } catch (Exception e) { - return FlinkAPI.build(config.getAddress()).stop(jobId); + log.warn("Stop with savcePoint failed: {}, will try normal rest api stop", e.getMessage()); + return cancelNormal(jobId); } } else { - try { - return FlinkAPI.build(config.getAddress()).stop(jobId); - } catch (Exception e) { - log.error("停止作业时集群不存在: " + e); - } - return false; + return cancelNormal(jobId); + } + } + + public boolean cancelNormal(String jobId) { + try { + return FlinkAPI.build(config.getAddress()).stop(jobId); + } catch (Exception e) { + log.error("stop flink job failed:", e); + throw new BusException(e.getMessage()); } } diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/service.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/service.tsx index 9a86f6fe19..58070156d0 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/service.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/service.tsx @@ -17,7 +17,8 @@ * */ -import { handleGetOption, handleOption } from '@/services/BusinessCrud'; +import {handleGetOption, handleOption} from '@/services/BusinessCrud'; +import {API_CONSTANTS} from "@/services/endpoints"; export async function explainSql(title: string, params: any) { return handleOption('/api/task/explainSql', title, params); @@ -32,13 +33,22 @@ export async function debugTask(title: string, params: any) { } export async function executeSql(title: string, id: number) { - return handleGetOption('/api/task/submitTask', title, { id }); + return handleGetOption('/api/task/submitTask', title, {id}); } -export function cancelTask(title: string, id: number) { - return handleGetOption('api/task/cancel', title, { id }); +export function cancelTask(title: string, id: number, withSavePoint: boolean = true) { + return handleGetOption(API_CONSTANTS.CANCEL_JOB, title, {id, withSavePoint}); } +export function restartTask(title: string, id: number, isOnLine:boolean) { + return handleGetOption(API_CONSTANTS.RESTART_TASK, title, {id, isOnLine}); +} +export function savePointTask(title: string, taskId: number, savePointType:string) { + return handleGetOption(API_CONSTANTS.SAVEPOINT, title, {taskId, savePointType}); +} + + + export function changeTaskLife(title = '', id: number, life: number) { - return handleGetOption('api/task/changeTaskLife', title, { taskId: id, lifeCycle: life }); + return handleGetOption('api/task/changeTaskLife', title, {taskId: id, lifeCycle: life}); } diff --git a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx index 7155908b9d..4e96a10469 100644 --- a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx +++ b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx @@ -17,15 +17,15 @@ * */ -import { cancelTask } from '@/pages/DataStudio/HeaderContainer/service'; -import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants'; -import { isStatusDone } from '@/pages/DevOps/function'; -import { getData, postAll } from '@/services/api'; -import { API_CONSTANTS } from '@/services/endpoints'; -import { Jobs } from '@/types/DevOps/data'; -import { l } from '@/utils/intl'; -import { EllipsisOutlined, RedoOutlined } from '@ant-design/icons'; -import { Button, Dropdown, message, Modal, Space } from 'antd'; +import {cancelTask, restartTask, savePointTask} from '@/pages/DataStudio/HeaderContainer/service'; +import {JOB_LIFE_CYCLE} from '@/pages/DevOps/constants'; +import {isStatusDone} from '@/pages/DevOps/function'; +import {getData, postAll} from '@/services/api'; +import {API_CONSTANTS} from '@/services/endpoints'; +import {Jobs} from '@/types/DevOps/data'; +import {l} from '@/utils/intl'; +import {EllipsisOutlined, RedoOutlined} from '@ant-design/icons'; +import {Button, Dropdown, message, Modal, Space} from 'antd'; const operatorType = { RESTART_JOB: 'restart', @@ -40,52 +40,37 @@ export type OperatorType = { refesh: (isForce: boolean) => void; }; const JobOperator = (props: OperatorType) => { - const { jobDetail, refesh } = props; + const {jobDetail, refesh} = props; const webUri = `/api/flink/${jobDetail?.history?.jobManagerAddress}/#/job/running/${jobDetail?.instance?.jid}/overview`; const handleJobOperator = (key: string) => { Modal.confirm({ - title: l('devops.jobinfo.job.key', '', { key: key }), - content: l('devops.jobinfo.job.keyConfirm', '', { key: key }), + title: l('devops.jobinfo.job.key', '', {key: key}), + content: l('devops.jobinfo.job.keyConfirm', '', {key: key}), okText: l('button.confirm'), cancelText: l('button.cancel'), onOk: async () => { if (key == operatorType.CANCEL_JOB) { - postAll(API_CONSTANTS.CANCEL_JOB, { - clusterId: jobDetail?.clusterInstance?.id, - jobId: jobDetail?.instance?.jid - }); + cancelTask('', jobDetail?.instance?.taskId, false); } else if (key == operatorType.RESTART_JOB) { - getData(API_CONSTANTS.RESTART_TASK, { - id: jobDetail?.instance?.taskId, - isOnLine: jobDetail?.instance?.step == JOB_LIFE_CYCLE.PUBLISH - }); + restartTask('', jobDetail?.instance?.taskId, jobDetail?.instance?.step == JOB_LIFE_CYCLE.PUBLISH) } else if (key == operatorType.SAVEPOINT_CANCEL) { - getData(API_CONSTANTS.SAVEPOINT, { - taskId: jobDetail?.instance?.taskId, - savePointType: 'cancel' - }); + savePointTask('', jobDetail?.instance?.taskId, 'cancel') } else if (key == operatorType.SAVEPOINT_STOP) { - getData(API_CONSTANTS.SAVEPOINT, { - taskId: jobDetail?.instance?.taskId, - savePointType: 'stop' - }); + savePointTask('', jobDetail?.instance?.taskId, 'stop') } else if (key == operatorType.SAVEPOINT_TRIGGER) { - getData(API_CONSTANTS.SAVEPOINT, { - taskId: jobDetail?.instance?.taskId, - savePointType: 'trigger' - }); - } else { + savePointTask('', jobDetail?.instance?.taskId, 'trigger') + } else if (key == operatorType.AUTO_STOP) { cancelTask('', jobDetail?.instance?.taskId); } - message.success(l('devops.jobinfo.job.key.success', '', { key: key })); + message.success(l('devops.jobinfo.job.key.success', '', {key: key})); } }); }; return ( - diff --git a/dinky-web/src/services/endpoints.tsx b/dinky-web/src/services/endpoints.tsx index ee951f1d8b..838899fd38 100644 --- a/dinky-web/src/services/endpoints.tsx +++ b/dinky-web/src/services/endpoints.tsx @@ -239,7 +239,7 @@ export enum API_CONSTANTS { GET_TASKMANAGER_LIST = 'api/jobInstance/getTaskManagerList', GET_TASKMANAGER_LOG = 'api/jobInstance/getTaskManagerLog', GET_JOB_METRICS_ITEMS = 'api/jobInstance/getJobMetricsItems', - CANCEL_JOB = '/api/studio/cancel', + CANCEL_JOB = '/api/task/cancel', // /api/studio/getLineage STUDIO_GET_LINEAGE = '/api/studio/getLineage', // /api/jobInstance/getLineage From 5df10a4adc8ed08a91a28784beefac92183fa43c Mon Sep 17 00:00:00 2001 From: gaoyan Date: Sun, 24 Dec 2023 15:28:18 +0800 Subject: [PATCH 3/7] Added job information remapping (#2730) * fix log error * Added job information remapping --- .../controller/ClusterInstanceController.java | 4 +- .../controller/JobInstanceController.java | 14 +++ dinky-web/src/locales/en-US/pages.ts | 6 + dinky-web/src/locales/zh-CN/pages.ts | 5 + .../JobDetail/JobOperator/JobOperator.tsx | 44 ++++--- .../components/EditJobInstanceForm.tsx | 119 ++++++++++++++++++ .../JobHistoryList/JobHistoryList.tsx | 2 +- dinky-web/src/pages/DevOps/JobList/index.tsx | 2 +- dinky-web/src/pages/Metrics/Job/service.tsx | 2 +- dinky-web/src/services/endpoints.tsx | 2 +- 10 files changed, 175 insertions(+), 25 deletions(-) create mode 100644 dinky-web/src/pages/DevOps/JobDetail/JobOperator/components/EditJobInstanceForm.tsx diff --git a/dinky-admin/src/main/java/org/dinky/controller/ClusterInstanceController.java b/dinky-admin/src/main/java/org/dinky/controller/ClusterInstanceController.java index 0fed00a281..31a533f840 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/ClusterInstanceController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/ClusterInstanceController.java @@ -85,7 +85,9 @@ public class ClusterInstanceController { mode = SaMode.OR) public Result saveOrUpdateClusterInstance(@RequestBody ClusterInstanceDTO clusterInstanceDTO) throws Exception { - clusterInstanceDTO.setAutoRegisters(false); + if (clusterInstanceDTO.getAutoRegisters() == null) { + clusterInstanceDTO.setAutoRegisters(false); + } clusterInstanceService.registersCluster(clusterInstanceDTO); return Result.succeed(Status.SAVE_SUCCESS); } diff --git a/dinky-admin/src/main/java/org/dinky/controller/JobInstanceController.java b/dinky-admin/src/main/java/org/dinky/controller/JobInstanceController.java index 325e288280..c7eee0a44e 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/JobInstanceController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/JobInstanceController.java @@ -23,6 +23,7 @@ import org.dinky.assertion.Asserts; import org.dinky.data.annotations.Log; import org.dinky.data.enums.BusinessType; +import org.dinky.data.enums.Status; import org.dinky.data.model.ID; import org.dinky.data.model.devops.TaskManagerConfiguration; import org.dinky.data.model.ext.JobInfoDetail; @@ -40,6 +41,7 @@ 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; @@ -69,6 +71,18 @@ public class JobInstanceController { private final JobInstanceService jobInstanceService; + @PutMapping + @Log(title = "update JobInstance Job Id", businessType = BusinessType.INSERT_OR_UPDATE) + @ApiOperation("update JobInstance Job Id") + public Result updateJobInstanceJobId(@RequestBody JobInstance jobInstance) { + boolean updated = jobInstanceService.updateById(jobInstance); + if (updated) { + return Result.succeed(Status.SAVE_SUCCESS); + } else { + return Result.failed(Status.SAVE_FAILED); + } + } + /** * 动态查询列表 */ diff --git a/dinky-web/src/locales/en-US/pages.ts b/dinky-web/src/locales/en-US/pages.ts index 89cb1a4542..bf1bde07ac 100644 --- a/dinky-web/src/locales/en-US/pages.ts +++ b/dinky-web/src/locales/en-US/pages.ts @@ -210,6 +210,12 @@ export default { 'devops.jobinfo.version.latestVersion': 'Current Version', 'devops.jobinfo.version.rollBack': 'Roll bcak this version', 'devops.jobinfo.version.versionList': 'Job Version', + 'devops.jobinfo.remap.title': 'Remap the cluster information', + 'devops.jobinfo.remap.cluster.title': 'Cluster instance mapping information', + 'devops.jobinfo.remap.cluster.title.help': + '(Note: This operation will modify the configuration of the cluster instance simultaneously.)', + 'devops.jobinfo.remap.job.title': 'Job mapping information', + 'devops.joblist.detail': 'Job Detail', 'devops.joblist.history': 'History', 'devops.joblist.joblist': 'JobList', diff --git a/dinky-web/src/locales/zh-CN/pages.ts b/dinky-web/src/locales/zh-CN/pages.ts index aa6329c489..3c5111cf42 100644 --- a/dinky-web/src/locales/zh-CN/pages.ts +++ b/dinky-web/src/locales/zh-CN/pages.ts @@ -200,6 +200,11 @@ export default { 'devops.jobinfo.version.latestVersion': '当前版本', 'devops.jobinfo.version.rollBack': '回滚到此版本', 'devops.jobinfo.version.versionList': '版本列表', + 'devops.jobinfo.remap.title': '重新映射集群信息', + 'devops.jobinfo.remap.cluster.title': '集群实例映射信息', + 'devops.jobinfo.remap.cluster.title.help': ' (注意:此操作会同步修改集群实例配置)', + 'devops.jobinfo.remap.job.title': 'Job映射信息', + 'devops.joblist.detail': '详情', 'devops.joblist.history': '历史', 'devops.joblist.joblist': '任务列表', diff --git a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx index 4e96a10469..3ac8567ba0 100644 --- a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx +++ b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx @@ -17,15 +17,14 @@ * */ -import {cancelTask, restartTask, savePointTask} from '@/pages/DataStudio/HeaderContainer/service'; -import {JOB_LIFE_CYCLE} from '@/pages/DevOps/constants'; -import {isStatusDone} from '@/pages/DevOps/function'; -import {getData, postAll} from '@/services/api'; -import {API_CONSTANTS} from '@/services/endpoints'; -import {Jobs} from '@/types/DevOps/data'; -import {l} from '@/utils/intl'; -import {EllipsisOutlined, RedoOutlined} from '@ant-design/icons'; -import {Button, Dropdown, message, Modal, Space} from 'antd'; +import { cancelTask, restartTask, savePointTask } from '@/pages/DataStudio/HeaderContainer/service'; +import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants'; +import { isStatusDone } from '@/pages/DevOps/function'; +import EditJobInstanceForm from '@/pages/DevOps/JobDetail/JobOperator/components/EditJobInstanceForm'; +import { Jobs } from '@/types/DevOps/data'; +import { l } from '@/utils/intl'; +import { EllipsisOutlined, RedoOutlined } from '@ant-design/icons'; +import { Button, Dropdown, message, Modal, Space } from 'antd'; const operatorType = { RESTART_JOB: 'restart', @@ -40,37 +39,42 @@ export type OperatorType = { refesh: (isForce: boolean) => void; }; const JobOperator = (props: OperatorType) => { - const {jobDetail, refesh} = props; + const { jobDetail, refesh } = props; const webUri = `/api/flink/${jobDetail?.history?.jobManagerAddress}/#/job/running/${jobDetail?.instance?.jid}/overview`; const handleJobOperator = (key: string) => { Modal.confirm({ - title: l('devops.jobinfo.job.key', '', {key: key}), - content: l('devops.jobinfo.job.keyConfirm', '', {key: key}), + title: l('devops.jobinfo.job.key', '', { key: key }), + content: l('devops.jobinfo.job.keyConfirm', '', { key: key }), okText: l('button.confirm'), cancelText: l('button.cancel'), onOk: async () => { if (key == operatorType.CANCEL_JOB) { cancelTask('', jobDetail?.instance?.taskId, false); } else if (key == operatorType.RESTART_JOB) { - restartTask('', jobDetail?.instance?.taskId, jobDetail?.instance?.step == JOB_LIFE_CYCLE.PUBLISH) + restartTask( + '', + jobDetail?.instance?.taskId, + jobDetail?.instance?.step == JOB_LIFE_CYCLE.PUBLISH + ); } else if (key == operatorType.SAVEPOINT_CANCEL) { - savePointTask('', jobDetail?.instance?.taskId, 'cancel') + savePointTask('', jobDetail?.instance?.taskId, 'cancel'); } else if (key == operatorType.SAVEPOINT_STOP) { - savePointTask('', jobDetail?.instance?.taskId, 'stop') + savePointTask('', jobDetail?.instance?.taskId, 'stop'); } else if (key == operatorType.SAVEPOINT_TRIGGER) { - savePointTask('', jobDetail?.instance?.taskId, 'trigger') + savePointTask('', jobDetail?.instance?.taskId, 'trigger'); } else if (key == operatorType.AUTO_STOP) { cancelTask('', jobDetail?.instance?.taskId); } - message.success(l('devops.jobinfo.job.key.success', '', {key: key})); + message.success(l('devops.jobinfo.job.key.success', '', { key: key })); } }); }; return ( - diff --git a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/components/EditJobInstanceForm.tsx b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/components/EditJobInstanceForm.tsx new file mode 100644 index 0000000000..a4bf0644bd --- /dev/null +++ b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/components/EditJobInstanceForm.tsx @@ -0,0 +1,119 @@ +/* + * + * 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 { CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/Instance/components/contants'; +import { validatorJMHAAdderess } from '@/pages/RegCenter/Cluster/Instance/components/function'; +import { handleAddOrUpdate } from '@/services/BusinessCrud'; +import { API_CONSTANTS } from '@/services/endpoints'; +import { Jobs } from '@/types/DevOps/data'; +import { l } from '@/utils/intl'; +import { EditOutlined } from '@ant-design/icons'; +import { + DrawerForm, + ProFormSelect, + ProFormText, + ProFormTextArea +} from '@ant-design/pro-components'; +import { Button, Divider, Form, Typography } from 'antd'; +const { Text } = Typography; + +const EditJobInstanceForm = (props: { + jobDetail: Jobs.JobInfoDetail; + refeshJob: (isForce: boolean) => void; +}) => { + const [form] = Form.useForm(); + const { jobDetail, refeshJob } = props; + + const handleSubmit = async (values: any) => { + const cluster = { + id: jobDetail.clusterInstance.id, + hosts: values.hosts, + autoRegisters: jobDetail.clusterInstance.autoRegisters + }; + const instance = { id: jobDetail.instance.id, jid: values.jid }; + await handleAddOrUpdate(API_CONSTANTS.CLUSTER_INSTANCE, cluster); + await handleAddOrUpdate(API_CONSTANTS.JOB_INSTANCE, instance); + refeshJob(true); + return true; + }; + + return ( + } />} + onFinish={handleSubmit} + > + + {l('devops.jobinfo.remap.cluster.title')} + {l('devops.jobinfo.remap.cluster.title.help')} + + + + + + + + validatorJMHAAdderess(rule, hostsValue) + } + ]} + placeholder={l('rc.ci.jmhaPlaceholder')} + /> + + + + {l('devops.jobinfo.remap.job.title')} + + + + ); +}; +export default EditJobInstanceForm; diff --git a/dinky-web/src/pages/DevOps/JobList/components/JobHistoryList/JobHistoryList.tsx b/dinky-web/src/pages/DevOps/JobList/components/JobHistoryList/JobHistoryList.tsx index 17a8c982d0..16e57b8606 100644 --- a/dinky-web/src/pages/DevOps/JobList/components/JobHistoryList/JobHistoryList.tsx +++ b/dinky-web/src/pages/DevOps/JobList/components/JobHistoryList/JobHistoryList.tsx @@ -89,7 +89,7 @@ const JobHistoryList = (props: HistoryProps) => { columns={jobListColumns} actionRef={actionRef} request={(params) => - queryList(API_CONSTANTS.GET_JOB_LIST, { + queryList(API_CONSTANTS.JOB_INSTANCE, { ...params, filter: { task_id: [taskId] } }) diff --git a/dinky-web/src/pages/DevOps/JobList/index.tsx b/dinky-web/src/pages/DevOps/JobList/index.tsx index 2e47170cd6..7eaf7f68e9 100644 --- a/dinky-web/src/pages/DevOps/JobList/index.tsx +++ b/dinky-web/src/pages/DevOps/JobList/index.tsx @@ -137,7 +137,7 @@ const JobList = () => { actions: [