Skip to content

Commit

Permalink
Added job information remapping (DataLinkDC#2730)
Browse files Browse the repository at this point in the history
* fix log error

* Added job information remapping
  • Loading branch information
gaoyan1998 authored Dec 24, 2023
1 parent 2d67312 commit 5df10a4
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public class ClusterInstanceController {
mode = SaMode.OR)
public Result<Void> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<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);
}
}

/**
* 动态查询列表
*/
Expand Down
6 changes: 6 additions & 0 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions dinky-web/src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '任务列表',
Expand Down
44 changes: 24 additions & 20 deletions dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 (
<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'}>
FlinkWebUI
Expand Down Expand Up @@ -124,8 +128,8 @@ const JobOperator = (props: OperatorType) => {
]
}}
>
<Button key='4' style={{padding: '0 8px'}}>
<EllipsisOutlined/>
<Button key='4' style={{ padding: '0 8px' }}>
<EllipsisOutlined />
</Button>
</Dropdown>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<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;
Original file line number Diff line number Diff line change
Expand Up @@ -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] }
})
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/pages/DevOps/JobList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const JobList = () => {
actions: [<Button icon={<RedoOutlined />} onClick={() => tableRef.current?.reload()} />]
}}
request={async (params, sorter, filter: any) =>
queryList(API_CONSTANTS.GET_JOB_LIST, {
queryList(API_CONSTANTS.JOB_INSTANCE, {
...params,
sorter,
filter
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/pages/Metrics/Job/service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { API_CONSTANTS } from '@/services/endpoints';
* @returns {Promise<any>}
*/
export async function getFlinkRunTask() {
return queryList(API_CONSTANTS.GET_JOB_LIST, {
return queryList(API_CONSTANTS.JOB_INSTANCE, {
filter: {},
currentPage: 1,
status: 'RUNNING',
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/services/endpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export enum API_CONSTANTS {
PROCESS_LOG = '/api/process/getProcess',

// ---- devops
GET_JOB_LIST = '/api/jobInstance',
JOB_INSTANCE = '/api/jobInstance',
GET_JOB_INSTANCE_BY_TASK_ID = '/api/jobInstance/getJobInstanceByTaskId',
GET_JOB_BY_ID = '/api/jobInstance/getOneById',
GET_LATEST_HISTORY_BY_ID = '/api/history/getLatestHistoryById',
Expand Down

0 comments on commit 5df10a4

Please sign in to comment.