Unverified Commit 5df10a4a authored by gaoyan's avatar gaoyan Committed by GitHub

Added job information remapping (#2730)

* fix log error * Added job information remapping
parent 2d673126
...@@ -85,7 +85,9 @@ public class ClusterInstanceController { ...@@ -85,7 +85,9 @@ public class ClusterInstanceController {
mode = SaMode.OR) mode = SaMode.OR)
public Result<Void> saveOrUpdateClusterInstance(@RequestBody ClusterInstanceDTO clusterInstanceDTO) public Result<Void> saveOrUpdateClusterInstance(@RequestBody ClusterInstanceDTO clusterInstanceDTO)
throws Exception { throws Exception {
if (clusterInstanceDTO.getAutoRegisters() == null) {
clusterInstanceDTO.setAutoRegisters(false); clusterInstanceDTO.setAutoRegisters(false);
}
clusterInstanceService.registersCluster(clusterInstanceDTO); clusterInstanceService.registersCluster(clusterInstanceDTO);
return Result.succeed(Status.SAVE_SUCCESS); return Result.succeed(Status.SAVE_SUCCESS);
} }
......
...@@ -23,6 +23,7 @@ import org.dinky.api.FlinkAPI; ...@@ -23,6 +23,7 @@ import org.dinky.api.FlinkAPI;
import org.dinky.assertion.Asserts; import org.dinky.assertion.Asserts;
import org.dinky.data.annotations.Log; import org.dinky.data.annotations.Log;
import org.dinky.data.enums.BusinessType; import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status;
import org.dinky.data.model.ID; import org.dinky.data.model.ID;
import org.dinky.data.model.devops.TaskManagerConfiguration; import org.dinky.data.model.devops.TaskManagerConfiguration;
import org.dinky.data.model.ext.JobInfoDetail; import org.dinky.data.model.ext.JobInfoDetail;
...@@ -40,6 +41,7 @@ import java.util.Set; ...@@ -40,6 +41,7 @@ import java.util.Set;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -69,6 +71,18 @@ import lombok.extern.slf4j.Slf4j; ...@@ -69,6 +71,18 @@ import lombok.extern.slf4j.Slf4j;
public class JobInstanceController { public class JobInstanceController {
private final JobInstanceService jobInstanceService; private final JobInstanceService jobInstanceService;
@PutMapping
@Log(title = "update JobInstance Job Id", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("update JobInstance Job Id")
public Result<Void> updateJobInstanceJobId(@RequestBody JobInstance jobInstance) {
boolean updated = jobInstanceService.updateById(jobInstance);
if (updated) {
return Result.succeed(Status.SAVE_SUCCESS);
} else {
return Result.failed(Status.SAVE_FAILED);
}
}
/** /**
* 动态查询列表 * 动态查询列表
*/ */
......
...@@ -210,6 +210,12 @@ export default { ...@@ -210,6 +210,12 @@ export default {
'devops.jobinfo.version.latestVersion': 'Current Version', 'devops.jobinfo.version.latestVersion': 'Current Version',
'devops.jobinfo.version.rollBack': 'Roll bcak this version', 'devops.jobinfo.version.rollBack': 'Roll bcak this version',
'devops.jobinfo.version.versionList': 'Job 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.detail': 'Job Detail',
'devops.joblist.history': 'History', 'devops.joblist.history': 'History',
'devops.joblist.joblist': 'JobList', 'devops.joblist.joblist': 'JobList',
......
...@@ -200,6 +200,11 @@ export default { ...@@ -200,6 +200,11 @@ export default {
'devops.jobinfo.version.latestVersion': '当前版本', 'devops.jobinfo.version.latestVersion': '当前版本',
'devops.jobinfo.version.rollBack': '回滚到此版本', 'devops.jobinfo.version.rollBack': '回滚到此版本',
'devops.jobinfo.version.versionList': '版本列表', '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.detail': '详情',
'devops.joblist.history': '历史', 'devops.joblist.history': '历史',
'devops.joblist.joblist': '任务列表', 'devops.joblist.joblist': '任务列表',
......
...@@ -17,15 +17,14 @@ ...@@ -17,15 +17,14 @@
* *
*/ */
import {cancelTask, restartTask, savePointTask} from '@/pages/DataStudio/HeaderContainer/service'; import { cancelTask, restartTask, savePointTask } from '@/pages/DataStudio/HeaderContainer/service';
import {JOB_LIFE_CYCLE} from '@/pages/DevOps/constants'; import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants';
import {isStatusDone} from '@/pages/DevOps/function'; import { isStatusDone } from '@/pages/DevOps/function';
import {getData, postAll} from '@/services/api'; import EditJobInstanceForm from '@/pages/DevOps/JobDetail/JobOperator/components/EditJobInstanceForm';
import {API_CONSTANTS} from '@/services/endpoints'; import { Jobs } from '@/types/DevOps/data';
import {Jobs} from '@/types/DevOps/data'; import { l } from '@/utils/intl';
import {l} from '@/utils/intl'; import { EllipsisOutlined, RedoOutlined } from '@ant-design/icons';
import {EllipsisOutlined, RedoOutlined} from '@ant-design/icons'; import { Button, Dropdown, message, Modal, Space } from 'antd';
import {Button, Dropdown, message, Modal, Space} from 'antd';
const operatorType = { const operatorType = {
RESTART_JOB: 'restart', RESTART_JOB: 'restart',
...@@ -40,37 +39,42 @@ export type OperatorType = { ...@@ -40,37 +39,42 @@ export type OperatorType = {
refesh: (isForce: boolean) => void; refesh: (isForce: boolean) => void;
}; };
const JobOperator = (props: OperatorType) => { 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 webUri = `/api/flink/${jobDetail?.history?.jobManagerAddress}/#/job/running/${jobDetail?.instance?.jid}/overview`;
const handleJobOperator = (key: string) => { const handleJobOperator = (key: string) => {
Modal.confirm({ Modal.confirm({
title: l('devops.jobinfo.job.key', '', {key: key}), title: l('devops.jobinfo.job.key', '', { key: key }),
content: l('devops.jobinfo.job.keyConfirm', '', {key: key}), content: l('devops.jobinfo.job.keyConfirm', '', { key: key }),
okText: l('button.confirm'), okText: l('button.confirm'),
cancelText: l('button.cancel'), cancelText: l('button.cancel'),
onOk: async () => { onOk: async () => {
if (key == operatorType.CANCEL_JOB) { if (key == operatorType.CANCEL_JOB) {
cancelTask('', jobDetail?.instance?.taskId, false); cancelTask('', jobDetail?.instance?.taskId, false);
} else if (key == operatorType.RESTART_JOB) { } 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) { } else if (key == operatorType.SAVEPOINT_CANCEL) {
savePointTask('', jobDetail?.instance?.taskId, 'cancel') savePointTask('', jobDetail?.instance?.taskId, 'cancel');
} else if (key == operatorType.SAVEPOINT_STOP) { } else if (key == operatorType.SAVEPOINT_STOP) {
savePointTask('', jobDetail?.instance?.taskId, 'stop') savePointTask('', jobDetail?.instance?.taskId, 'stop');
} else if (key == operatorType.SAVEPOINT_TRIGGER) { } else if (key == operatorType.SAVEPOINT_TRIGGER) {
savePointTask('', jobDetail?.instance?.taskId, 'trigger') savePointTask('', jobDetail?.instance?.taskId, 'trigger');
} else if (key == operatorType.AUTO_STOP) { } else if (key == operatorType.AUTO_STOP) {
cancelTask('', jobDetail?.instance?.taskId); 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 ( return (
<Space> <Space>
<Button icon={<RedoOutlined/>} onClick={() => refesh(true)}/> <EditJobInstanceForm jobDetail={jobDetail} refeshJob={refesh} />
<Button icon={<RedoOutlined />} onClick={() => refesh(true)} />
<Button key='flinkwebui' href={webUri} target={'_blank'}> <Button key='flinkwebui' href={webUri} target={'_blank'}>
FlinkWebUI FlinkWebUI
...@@ -124,8 +128,8 @@ const JobOperator = (props: OperatorType) => { ...@@ -124,8 +128,8 @@ const JobOperator = (props: OperatorType) => {
] ]
}} }}
> >
<Button key='4' style={{padding: '0 8px'}}> <Button key='4' style={{ padding: '0 8px' }}>
<EllipsisOutlined/> <EllipsisOutlined />
</Button> </Button>
</Dropdown> </Dropdown>
</> </>
......
/*
*
* 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 (
<DrawerForm
title={l('devops.jobinfo.remap.title')}
form={form}
initialValues={{ ...jobDetail?.clusterInstance, ...jobDetail?.instance }}
trigger={<Button icon={<EditOutlined />} />}
onFinish={handleSubmit}
>
<Divider orientation={'left'} style={{ margin: '8px 0' }}>
{l('devops.jobinfo.remap.cluster.title')}
<Text type='danger'> {l('devops.jobinfo.remap.cluster.title.help')}</Text>
</Divider>
<ProFormText
name='name'
label={l('rc.ci.name')}
disabled
rules={[{ required: true, message: l('rc.ci.namePlaceholder') }]}
placeholder={l('rc.ci.namePlaceholder')}
/>
<ProFormText
name='alias'
label={l('rc.ci.alias')}
disabled
placeholder={l('rc.ci.aliasPlaceholder')}
/>
<ProFormSelect
name='type'
label={l('rc.ci.type')}
disabled
options={CLUSTER_INSTANCE_TYPE}
rules={[{ required: true, message: l('rc.ci.typePlaceholder') }]}
placeholder={l('rc.ci.typePlaceholder')}
/>
<ProFormTextArea
name='hosts'
label={l('rc.ci.jmha')}
tooltip={l('rc.ci.jmha.tips')}
validateTrigger={['onChange']}
rules={[
{
required: true,
validator: (rule, hostsValue) => validatorJMHAAdderess(rule, hostsValue)
}
]}
placeholder={l('rc.ci.jmhaPlaceholder')}
/>
<ProFormTextArea
name='note'
label={l('global.table.note')}
disabled
placeholder={l('global.table.notePlaceholder')}
/>
<Divider orientation={'left'} style={{ margin: '8px 0' }}>
{l('devops.jobinfo.remap.job.title')}
</Divider>
<ProFormText name='jid' label='Job Id' placeholder={l('rc.ci.aliasPlaceholder')} />
</DrawerForm>
);
};
export default EditJobInstanceForm;
...@@ -89,7 +89,7 @@ const JobHistoryList = (props: HistoryProps) => { ...@@ -89,7 +89,7 @@ const JobHistoryList = (props: HistoryProps) => {
columns={jobListColumns} columns={jobListColumns}
actionRef={actionRef} actionRef={actionRef}
request={(params) => request={(params) =>
queryList(API_CONSTANTS.GET_JOB_LIST, { queryList(API_CONSTANTS.JOB_INSTANCE, {
...params, ...params,
filter: { task_id: [taskId] } filter: { task_id: [taskId] }
}) })
......
...@@ -137,7 +137,7 @@ const JobList = () => { ...@@ -137,7 +137,7 @@ const JobList = () => {
actions: [<Button icon={<RedoOutlined />} onClick={() => tableRef.current?.reload()} />] actions: [<Button icon={<RedoOutlined />} onClick={() => tableRef.current?.reload()} />]
}} }}
request={async (params, sorter, filter: any) => request={async (params, sorter, filter: any) =>
queryList(API_CONSTANTS.GET_JOB_LIST, { queryList(API_CONSTANTS.JOB_INSTANCE, {
...params, ...params,
sorter, sorter,
filter filter
......
...@@ -26,7 +26,7 @@ import { API_CONSTANTS } from '@/services/endpoints'; ...@@ -26,7 +26,7 @@ import { API_CONSTANTS } from '@/services/endpoints';
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
export async function getFlinkRunTask() { export async function getFlinkRunTask() {
return queryList(API_CONSTANTS.GET_JOB_LIST, { return queryList(API_CONSTANTS.JOB_INSTANCE, {
filter: {}, filter: {},
currentPage: 1, currentPage: 1,
status: 'RUNNING', status: 'RUNNING',
......
...@@ -225,7 +225,7 @@ export enum API_CONSTANTS { ...@@ -225,7 +225,7 @@ export enum API_CONSTANTS {
PROCESS_LOG = '/api/process/getProcess', PROCESS_LOG = '/api/process/getProcess',
// ---- devops // ---- devops
GET_JOB_LIST = '/api/jobInstance', JOB_INSTANCE = '/api/jobInstance',
GET_JOB_INSTANCE_BY_TASK_ID = '/api/jobInstance/getJobInstanceByTaskId', GET_JOB_INSTANCE_BY_TASK_ID = '/api/jobInstance/getJobInstanceByTaskId',
GET_JOB_BY_ID = '/api/jobInstance/getOneById', GET_JOB_BY_ID = '/api/jobInstance/getOneById',
GET_LATEST_HISTORY_BY_ID = '/api/history/getLatestHistoryById', GET_LATEST_HISTORY_BY_ID = '/api/history/getLatestHistoryById',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment