Unverified Commit c5c61b37 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

refactor: delete Cluster alias (#1602)

* refactor: delete Cluster alias * format code * format code * format code * format code
parent c81c66ed
......@@ -139,8 +139,11 @@ public class Job2MysqlHandler implements JobHandler {
clusterService.registersCluster(
Cluster.autoRegistersCluster(
job.getJobManagerAddress(),
job.getJobId(),
job.getJobConfig().getJobName() + LocalDateTime.now(),
job.getJobId()
+ "_"
+ job.getJobConfig().getJobName()
+ "_"
+ LocalDateTime.now(),
job.getType().getLongValue(),
clusterConfigurationId,
taskId));
......@@ -153,8 +156,11 @@ public class Job2MysqlHandler implements JobHandler {
clusterService.registersCluster(
Cluster.autoRegistersCluster(
job.getJobManagerAddress(),
job.getJobId(),
job.getJobConfig().getJobName() + LocalDateTime.now(),
job.getJobId()
+ "_"
+ job.getJobConfig().getJobName()
+ "_"
+ LocalDateTime.now(),
job.getType().getLongValue(),
null,
taskId));
......
......@@ -21,8 +21,6 @@ package org.dinky.model;
import org.dinky.db.model.SuperEntity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
......@@ -43,9 +41,6 @@ public class Cluster extends SuperEntity {
private Integer tenantId;
@TableField(fill = FieldFill.INSERT)
private String alias;
private String type;
private String hosts;
......@@ -67,13 +62,11 @@ public class Cluster extends SuperEntity {
public static Cluster autoRegistersCluster(
String hosts,
String name,
String alias,
String type,
Integer clusterConfigurationId,
Integer taskId) {
Cluster cluster = new Cluster();
cluster.setName(name);
cluster.setAlias(alias);
cluster.setHosts(hosts);
cluster.setType(type);
cluster.setClusterConfigurationId(clusterConfigurationId);
......
......@@ -183,9 +183,12 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
return registersCluster(
Cluster.autoRegistersCluster(
gatewayResult.getWebURL().replace("http://", ""),
gatewayResult.getAppId(),
gatewayResult.getAppId()
+ "_"
+ clusterConfiguration.getName()
+ "_"
+ LocalDateTime.now(),
clusterConfiguration.getName() + LocalDateTime.now(),
gatewayConfig.getType().getLongValue(),
id,
null));
}
......
......@@ -344,7 +344,7 @@ public class StudioServiceImpl implements StudioService {
sessionDTO.getType(),
true,
cluster.getId(),
cluster.getAlias(),
cluster.getName(),
clusterService.buildEnvironmentAddress(
true, sessionDTO.getClusterId()));
return JobManager.createSession(sessionDTO.getSession(), sessionConfig, createUser);
......
......@@ -154,12 +154,7 @@ import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
/**
* 任务 服务实现类
*
* @author wenmo
* @since 2021-05-24
*/
/** TaskServiceImpl */
@Service
@RequiredArgsConstructor
public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implements TaskService {
......@@ -414,7 +409,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
if (task.getClusterId() != null) {
Cluster cluster = clusterService.getById(task.getClusterId());
if (cluster != null) {
task.setClusterName(cluster.getAlias());
task.setClusterName(cluster.getName());
}
}
......
......@@ -6,7 +6,6 @@
<resultMap id="BaseResultMap" type="org.dinky.model.Cluster">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="alias" property="alias" />
<result column="type" property="type" />
<result column="hosts" property="hosts" />
<result column="job_manager_host" property="jobManagerHost" />
......@@ -23,7 +22,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, name, alias, type,hosts,job_manager_host,version, status,note,auto_registers,cluster_configuration_id,task_id, enabled, create_time, update_time
id, name, type,hosts,job_manager_host,version, status,note,auto_registers,cluster_configuration_id,task_id, enabled, create_time, update_time
</sql>
......@@ -37,9 +36,6 @@
<if test='param.name!=null and param.name!=""'>
and a.name like "%${param.name}%"
</if>
<if test='param.alias!=null and param.alias!=""'>
and a.alias like "%${param.alias}%"
</if>
<if test='param.createTime!=null and param.createTime!=""'>
and a.create_time <![CDATA[>=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s')
</if>
......
......@@ -115,7 +115,6 @@ CREATE TABLE `dinky_cluster` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`tenant_id` int(11) NOT NULL DEFAULT 1 COMMENT 'tenant id',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'cluster instance name',
`alias` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'cluster instance alias',
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'cluster types',
`hosts` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'cluster hosts',
`job_manager_host` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Job Manager Host',
......
......@@ -70,5 +70,6 @@ ALTER TABLE dinky_user_tenant RENAME INDEX `dlink_user_role_un` TO `user_tenant_
ALTER TABLE dinky_catalogue RENAME INDEX `dlink_catalogue_un` TO `catalogue_un_idx1`;
ALTER TABLE dinky_schema_history RENAME INDEX `dlink_schema_history_s_idx` TO `schema_history_idx`;
ALTER TABLE dinky_cluster DROP COLUMN `alias`;
ALTER TABLE dinky_fragment DROP COLUMN `alias`;
ALTER TABLE dinky_database DROP COLUMN `alias`;
/*
*
* 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 {Button, Drawer, Empty, Modal, Table, Tooltip} from "antd";
import ProDescriptions from '@ant-design/pro-descriptions';
import {StateType} from "@/pages/DataStudio/model";
import {connect} from "umi";
import React, {useState} from "react";
import {PlusOutlined, ReloadOutlined} from '@ant-design/icons';
import {showCluster} from "../../StudioEvent/DDL";
import {handleAddOrUpdate, handleRemove} from "@/components/Common/crud";
import ClusterForm from "@/pages/RegistrationCenter/ClusterManage/Cluster/components/ClusterForm";
import {Scrollbars} from 'react-custom-scrollbars';
import {l} from "@/utils/intl";
const url = '/api/cluster';
const StudioCluster = (props: any) => {
const {cluster, toolHeight, dispatch} = props;
const [createModalVisible, handleCreateModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [row, setRow] = useState<{}>({});
const getColumns = () => {
return [{
title: "集群名",
dataIndex: "alias",
key: "alias",
sorter: true,
render: (dom, entity) => {
return <a onClick={() => setRow(entity)}>{dom}</a>;
},
}];
};
const getAllColumns = () => {
return [{
title: "ID",
dataIndex: "id",
key: "id",
}, {
title: '唯一标识',
dataIndex: 'name',
}, {
title: "集群名",
dataIndex: "alias",
},
{
title: '类型',
dataIndex: 'type',
filters: [
{
text: 'Yarn Session',
value: 'yarn-session',
},
{
text: 'Standalone',
value: 'standalone',
},
{
text: 'Yarn Per-Job',
value: 'yarn-per-job',
},
{
text: 'Yarn Application',
value: 'yarn-application',
},
{
text: 'Kubernetes Session',
value: 'kubernetes-session',
},
{
text: 'Kubernetes Application',
value: 'kubernetes-application',
},
],
filterMultiple: false,
valueEnum: {
'yarn-session': {text: 'Yarn Session'},
'standalone': {text: 'Standalone'},
'yarn-per-job': {text: 'Yarn Per-Job'},
'yarn-application': {text: 'Yarn Application'},
'kubernetes-session': {text: 'Kubernetes Session'},
'kubernetes-application': {text: 'Kubernetes Application'},
},
},
{
title: 'JobManager HA 地址',
dataIndex: 'hosts',
valueType: 'textarea',
},
{
title: '当前 JobManager 地址',
dataIndex: 'jobManagerHost',
}, {
title: '版本',
dataIndex: 'version',
},
{
title: '状态',
dataIndex: 'status',
filters: [
{
text: '正常',
value: 1,
},
{
text: '异常',
value: 0,
},
],
filterMultiple: false,
valueEnum: {
1: {text: '正常', status: 'Success'},
0: {text: '异常', status: 'Error'},
},
},
{
title: l('global.table.note'),
valueType: 'textarea',
dataIndex: 'note',
},
{
title: l('global.table.isEnable'),
dataIndex: 'enabled',
filters: [
{
text: l('status.enabled'),
value: 1,
},
{
text: l('status.disabled'),
value: 0,
},
],
filterMultiple: false,
valueEnum: {
true: {text: l('status.enabled'), status: 'Success'},
false: {text: l('status.disabled'), status: 'Error'},
},
},
{
title: '注册方式',
dataIndex: 'autoRegisters',
filters: [
{
text: '自动',
value: 1,
},
{
text: '手动',
value: 0,
},
],
filterMultiple: false,
valueEnum: {
true: {text: '自动', status: 'Success'},
false: {text: '手动', status: 'Error'},
},
},
{
title: '集群配置ID',
dataIndex: 'clusterConfigurationId',
}, {
title: '作业ID',
dataIndex: 'taskId',
},
{
title: l('global.table.createTime'),
dataIndex: 'createTime',
valueType: 'dateTime',
},
{
title: l('global.table.lastUpdateTime'),
dataIndex: 'updateTime',
valueType: 'dateTime',
},
{
title: l('global.table.operate'),
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<Button type="dashed" onClick={() => onModifyCluster(record)}>
{l('button.edit')}
</Button>, <Button danger onClick={() => onDeleteCluster(record)}>
{l('button.delete')}
</Button>
],
},];
};
const onRefreshCluster = () => {
showCluster(dispatch);
};
const onCreateCluster = () => {
handleCreateModalVisible(true);
};
const onModifyCluster = (record) => {
setRow(record);
handleUpdateModalVisible(true);
};
const onDeleteCluster = (record) => {
Modal.confirm({
title: '删除集群',
content: `确定删除该集群【${record.alias}】吗?`,
okText: l('button.confirm'),
cancelText: l('button.cancel'),
onOk: async () => {
await handleRemove(url, [record]);
setRow({});
onRefreshCluster();
}
});
};
return (
<>
<Tooltip title="新建 Flink 集群">
<Button
type="text"
icon={<PlusOutlined/>}
onClick={onCreateCluster}
/>
</Tooltip>
<Tooltip title="刷新 Flink 集群">
<Button
type="text"
icon={<ReloadOutlined/>}
onClick={onRefreshCluster}
/>
</Tooltip>
<Scrollbars style={{height: (toolHeight - 32)}}>
{cluster.length > 0 ? (
<Table dataSource={cluster} columns={getColumns()} size="small"/>) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE}/>)}
<ClusterForm
onSubmit={async (value) => {
const success = await handleAddOrUpdate("api/cluster", value);
if (success) {
handleCreateModalVisible(false);
showCluster(dispatch);
}
}}
onCancel={() => {
handleCreateModalVisible(false);
}}
modalVisible={createModalVisible}
values={{}}
/>
{row && Object.keys(row).length ? (<ClusterForm
onSubmit={async (value) => {
const success = await handleAddOrUpdate("api/cluster", value);
if (success) {
handleUpdateModalVisible(false);
setRow({});
onRefreshCluster();
}
}}
onCancel={() => {
handleUpdateModalVisible(false);
}}
modalVisible={updateModalVisible}
values={row}
/>) : undefined}
<Drawer
width={600}
visible={!!row?.id}
onClose={() => {
setRow({});
}}
closable={false}
>
{row?.name && (
<ProDescriptions
column={2}
title={row?.name}
request={async () => ({
data: row || {},
})}
params={{
id: row?.name,
}}
columns={getAllColumns()}
/>
)}
</Drawer>
</Scrollbars>
</>
);
};
export default connect(({Studio}: { Studio: StateType }) => ({
cluster: Studio.cluster,
toolHeight: Studio.toolHeight,
}))(StudioCluster);
......@@ -46,9 +46,6 @@ const StudioLeftTool = (props: any) => {
<TabPane tab={<span><MessageOutlined/> {l('pages.datastudio.label.session')}</span>} key="Connectors">
<StudioConnector/>
</TabPane>
{/*<TabPane tab={<span><ClusterOutlined/> {l('pages.datastudio.label.cluster')}</span>} key="Cluster">*/}
{/* <StudioCluster/>*/}
{/*</TabPane>*/}
<TabPane tab={<span><AppstoreOutlined/> {l('pages.datastudio.label.meta')}</span>} key="MetaData">
<StudioMetaData/>
</TabPane>
......
......@@ -60,7 +60,7 @@ const StudioSetting = (props: any) => {
const itemList = [];
for (const item of sessionCluster) {
const tag = (<><Tag
color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.alias === "" ? item.name : item.alias}</>);
color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.name}</>);
itemList.push(<Option key={item.id} value={item.id} label={tag}>
{tag}
</Option>)
......
......@@ -490,7 +490,6 @@ export default {
'pages.rc.clusterManagement': 'Cluster Instance Management',
'pages.rc.cluster.instanceName': 'Instance name',
'pages.rc.cluster.alias': 'Alias',
'pages.rc.cluster.type': 'Type',
'pages.rc.cluster.jobManagerAddress': 'JobManger Address',
'pages.rc.cluster.version': 'Version',
......@@ -513,7 +512,6 @@ export default {
'pages.rc.cluster.jobManagerHaAddressPlaceholderText': 'Add the RestApi address of the JobManager of the Flink cluster. In HA mode, the addresses are separated by commas, for example: 192.168.123.101:8081,192.168.123.102:8081,192.168.123.103:8081',
'pages.rc.cluster.jobManagerHaAddressPlaceholder': 'Please enter the JobManager HA address!',
'pages.rc.cluster.typePlaceholder': 'Please select cluster type!',
'pages.rc.cluster.aliasPlaceholder': 'Please enter alias!',
'pages.rc.cluster.namePlaceholder': 'Please enter name!',
'pages.rc.clusterConfigManagement': 'Cluster Config Management',
......
......@@ -494,7 +494,6 @@ export default {
'pages.rc.clusterManagement': '集群实例管理',
'pages.rc.cluster.instanceName': '实例名称',
'pages.rc.cluster.alias': '别名',
'pages.rc.cluster.type': '类型',
'pages.rc.cluster.jobManagerAddress': 'JobManger 地址',
'pages.rc.cluster.version': '版本',
......@@ -519,7 +518,6 @@ export default {
'pages.rc.cluster.jobManagerHaAddressPlaceholderText': '添加 Flink 集群的 JobManager 的 RestApi 地址。当 HA 模式时,地址间用英文逗号分隔,例如:192.168.123.101:8081,192.168.123.102:8081,192.168.123.103:8081',
'pages.rc.cluster.jobManagerHaAddressPlaceholder': '请输入 JobManager HA 地址!',
'pages.rc.cluster.typePlaceholder': '请选择集群类型!',
'pages.rc.cluster.aliasPlaceholder': '请输入别名!',
'pages.rc.cluster.namePlaceholder': '请输入名称!',
'pages.rc.clusterConfigManagement': '集群配置管理',
......
......@@ -44,7 +44,6 @@ const ClusterForm: React.FC<ClusterFormProps> = (props) => {
const [formVals, setFormVals] = useState<Partial<ClusterTableListItem>>({
id: props.values.id,
name: props.values.name,
alias: props.values.alias,
type: props.values.type,
hosts: props.values.hosts,
note: props.values.note,
......@@ -84,12 +83,6 @@ const ClusterForm: React.FC<ClusterFormProps> = (props) => {
<Input placeholder={l('pages.rc.cluster.namePlaceholder') }/>
</Form.Item>
<Form.Item
name="alias"
label={l('pages.rc.cluster.alias')}
>
<Input placeholder={l('pages.rc.cluster.aliasPlaceholder') }/>
</Form.Item>
<Form.Item
name="type"
label={l('pages.rc.cluster.type')}
......
......@@ -111,7 +111,7 @@ const ClusterTableList: React.FC<{}> = (props: any) => {
<Dropdown
overlay={
<Menu onClick={({key}) => editAndDelete(key, item)}>
{item.autoRegisters == 1 ? (<Menu.Item key="stop">{l('button.stop')}</Menu.Item>) : undefined}
{item.autoRegisters === true ? (<Menu.Item key="stop">{l('button.stop')}</Menu.Item>) : undefined}
<Menu.Item key="edit">{l('button.edit')}</Menu.Item>
<Menu.Item key="delete">{l('button.delete')}</Menu.Item>
</Menu>
......@@ -139,12 +139,6 @@ const ClusterTableList: React.FC<{}> = (props: any) => {
hideInForm: true,
hideInSearch: true,
},
{
title: l('pages.rc.cluster.alias'),
sorter: true,
dataIndex: 'alias',
hideInTable: false,
},
{
title: l('pages.rc.cluster.type'),
sorter: true,
......
......@@ -44,10 +44,10 @@ export type AlertInstanceTableListItem = {
export type ClusterTableListItem = {
id: number,
name: string,
alias: string,
type: string,
hosts: string,
jobManagerHost: string,
autoRegisters: boolean,
version: string,
status: number,
note: string,
......
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