Commit e6641382 authored by wenmo's avatar wenmo

新增FlinkJar Dialect的管理

parent 17b315ac
package com.dlink.service.impl;
import com.dlink.api.FlinkAPI;
import com.dlink.assertion.Assert;
import com.dlink.assertion.Asserts;
import com.dlink.config.Dialect;
import com.dlink.dto.*;
......@@ -15,10 +16,7 @@ import com.dlink.job.JobManager;
import com.dlink.job.JobResult;
import com.dlink.metadata.driver.Driver;
import com.dlink.metadata.result.JdbcSelectResult;
import com.dlink.model.Cluster;
import com.dlink.model.DataBase;
import com.dlink.model.Savepoints;
import com.dlink.model.Task;
import com.dlink.model.*;
import com.dlink.result.IResult;
import com.dlink.result.SelectResult;
import com.dlink.result.SqlExplainResult;
......@@ -92,7 +90,8 @@ public class StudioServiceImpl implements StudioService {
}
config.setAddress(clusterService.buildEnvironmentAddress(config.isUseRemote(), studioExecuteDTO.getClusterId()));
}
initUDF(config,studioExecuteDTO.getStatement());
// To initialize java udf, but it has a bug in the product environment now.
// initUDF(config,studioExecuteDTO.getStatement());
JobManager jobManager = JobManager.build(config);
JobResult jobResult = jobManager.executeSql(studioExecuteDTO.getStatement());
RunTimeUtil.recovery(jobManager);
......@@ -162,7 +161,8 @@ public class StudioServiceImpl implements StudioService {
}
config.setAddress(clusterService.buildEnvironmentAddress(config.isUseRemote(), studioExecuteDTO.getClusterId()));
}
initUDF(config,studioExecuteDTO.getStatement());
// To initialize java udf, but it has a bug in the product environment now.
// initUDF(config,studioExecuteDTO.getStatement());
JobManager jobManager = JobManager.buildPlanMode(config);
return jobManager.explainSql(studioExecuteDTO.getStatement()).getSqlExplainResults();
}
......
......@@ -111,10 +111,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
}
}
private boolean isJarTask(Task task) {
return (GatewayType.YARN_APPLICATION.equalsValue(task.getType()) || GatewayType.KUBERNETES_APPLICATION.equalsValue(task.getType())) && Asserts.isNotNull(task.getJarId());
}
@Override
public Task getTaskInfoById(Integer id) {
Task task = this.getById(id);
......@@ -279,7 +275,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
}
private JobConfig buildJobConfig(Task task) {
boolean isJarTask = isJarTask(task);
boolean isJarTask = Dialect.FLINKJAR.equalsVal(task.getDialect());
if (!isJarTask && Asserts.isNotNull(task.getEnvId()) && task.getEnvId() != 0) {
Task envTask = getTaskInfoById(task.getEnvId());
if (Asserts.isNotNull(envTask) && Asserts.isNotNullString(envTask.getStatement())) {
......
......@@ -10,7 +10,7 @@ import com.dlink.assertion.Asserts;
**/
public enum Dialect {
FLINKSQL("FlinkSql"),FLINKSQLENV("FlinkSqlEnv"),SQL("Sql"),JAVA("Java"),
FLINKSQL("FlinkSql"),FLINKJAR("FlinkJar"),FLINKSQLENV("FlinkSqlEnv"),SQL("Sql"),JAVA("Java"),
MYSQL("Mysql"),ORACLE("Oracle"),SQLSERVER("SqlServer"),POSTGRESQL("PostGreSql"),CLICKHOUSE("ClickHouse"),
DORIS("Doris");
......
......@@ -491,6 +491,9 @@ ADD COLUMN `env_id` int(11) NULL COMMENT '环境ID' AFTER `jar_id`;
ALTER TABLE `dlink_database`
ADD COLUMN `flink_config` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '环境ID' AFTER `note`;
-- ----------------------------
-- 0.6.0-SNAPSHOT 2022-02-02
-- ----------------------------
-- ----------------------------
-- Table structure for dlink_job_instance
-- ----------------------------
......@@ -515,4 +518,10 @@ create table dlink_job_instance
ALTER TABLE `dlink_task`
ADD COLUMN `step` int(11) NULL COMMENT '作业生命周期' AFTER `note`;
-- ----------------------------
-- 0.6.0-SNAPSHOT 2022-02-03
-- ----------------------------
update dlink_task set dialect = 'FlinkJar' where jar_id is not null;
update dlink_catalogue set type = 'FlinkJar' where task_id in (select id as task_id from dlink_task where jar_id is not null);
SET FOREIGN_KEY_CHECKS = 1;
......@@ -512,7 +512,7 @@ const StudioMenu = (props: any) => {
onClick={execute}
/>
</Tooltip>)}
{(!current.task.dialect||current.task.dialect === DIALECT.FLINKSQL||isSql( current.task.dialect )) &&(<>
{(!current.task.dialect||current.task.dialect === DIALECT.FLINKSQL||current.task.dialect === DIALECT.FLINKJAR||isSql( current.task.dialect )) &&(<>
<Tooltip title="提交当前的作业到集群,提交前请手动保存">
<Button
type="text"
......
@import '~antd/es/style/themes/default.less';
.form_setting{
padding-left: 10px;
}
.form_item{
margin-bottom: 5px;
}
......@@ -38,17 +38,6 @@ const StudioSetting = (props: any) => {
return itemList;
};
const getJarOptions = () => {
const itemList = [];
for (const item of jars) {
const tag = (<><Tag color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.alias}</>);
itemList.push(<Option key={item.id} value={item.id} label={tag}>
{tag}
</Option>)
}
return itemList;
};
const getEnvOptions = () => {
const itemList = [<Option key={0} value={0} label='无'>
......@@ -161,20 +150,6 @@ const StudioSetting = (props: any) => {
</Form.Item>
</Col>
</Row>) : undefined}
{(current.task.type === RUN_MODE.YARN_APPLICATION || current.task.type === RUN_MODE.KUBERNETES_APPLICATION) ? (
<Form.Item label="可执行 Jar"
tooltip={`选择可执行 Jar 进行 ${current.task.type} 模式的远程提交 Jar 任务。当该参数项存在值时,将只提交可执行 Jar.`}
name="jarId"
className={styles.form_item}>
<Select
style={{width: '100%'}}
placeholder="选择可执行Jar,非必填"
allowClear
optionLabelProp="label"
>
{getJarOptions()}
</Select>
</Form.Item>) : undefined}
<Form.Item
label="作业名" className={styles.form_item} name="jobName"
tooltip='设置任务名称,默认为作业名'
......
import {Tabs, Empty, Form} from "antd";
import {SettingOutlined,ScheduleOutlined,AuditOutlined} from "@ant-design/icons";
import {SettingOutlined,ScheduleOutlined} from "@ant-design/icons";
import {StateType} from "@/pages/FlinkSqlStudio/model";
import {connect} from "umi";
import StudioConfig from "./StudioConfig";
......@@ -8,6 +8,7 @@ import StudioSavePoint from "./StudioSavePoint";
import StudioEnvSetting from "./StudioEnvSetting";
import StudioSqlConfig from "./StudioSqlConfig";
import StudioUDFInfo from "./StudioUDFInfo";
import StudioJarSetting from "./StudioJarSetting";
import StudioGuide from "./StudioGuide";
import {DIALECT, isSql} from "@/components/Studio/conf";
......@@ -21,6 +22,9 @@ const StudioRightTool = (props: any) => {
if(isSql(current.task.dialect)){
return renderSqlContent();
}
if(DIALECT.FLINKJAR === current.task.dialect){
return renderJarContent();
}
if(DIALECT.FLINKSQLENV === current.task.dialect){
return renderEnvContent();
}
......@@ -38,6 +42,14 @@ const StudioRightTool = (props: any) => {
</>)
};
const renderJarContent = () => {
return (<>
<TabPane tab={<span><SettingOutlined /> 作业配置</span>} key="StudioJarSetting" >
<StudioJarSetting form={form}/>
</TabPane>
</>)
};
const renderEnvContent = () => {
return (<>
<TabPane tab={<span><SettingOutlined /> 作业配置</span>} key="StudioEnvSetting" >
......
......@@ -52,6 +52,7 @@ const SimpleTaskForm: React.FC<UpdateFormProps> = (props) => {
>
<Select defaultValue={DIALECT.FLINKSQL} value={DIALECT.FLINKSQL}>
<Option value={DIALECT.FLINKSQL}>{DIALECT.FLINKSQL}</Option>
<Option value={DIALECT.FLINKJAR}>{DIALECT.FLINKJAR}</Option>
<Option value={DIALECT.FLINKSQLENV}>{DIALECT.FLINKSQLENV}</Option>
<Option value={DIALECT.MYSQL}>{DIALECT.MYSQL}</Option>
<Option value={DIALECT.ORACLE}>{DIALECT.ORACLE}</Option>
......
......@@ -10,6 +10,7 @@ export const RUN_MODE = {
export const DIALECT = {
FLINKSQL:'FlinkSql',
FLINKJAR:'FlinkJar',
FLINKSQLENV:'FlinkSqlEnv',
SQL:'Sql',
MYSQL:'Mysql',
......
......@@ -7,6 +7,8 @@ export const getIcon = (type: string)=>{
switch (type){
case DIALECT.SQL:
return (<Icon component={SqlSvg} />);
case DIALECT.FLINKJAR:
return (<Icon component={FlinkJarSvg} />);
case DIALECT.MYSQL:
return (<Icon component={MysqlSvg} />);
case DIALECT.ORACLE:
......@@ -129,6 +131,14 @@ export const SqlSvg = () => (
</svg>
);
export const FlinkJarSvg = () => (
<svg t="1643818254563" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
p-id="6735" width={svgSize} height={svgSize}>
<path
d="M320.192 64c76.864 0 141.632 28.48 186.496 84.096 34.112 42.24 52.224 95.68 52.224 140.992 0 38.144-8.768 66.688-33.536 107.52l-7.936 12.608-7.232 10.88 13.824-7.936c12.352-6.912 25.728-13.888 40.768-21.248l15.616-7.552 16.768-7.936a212.8 212.8 0 0 0 89.408-79.36c4.288-6.848 8.064-13.888 11.328-20.992l4.48-10.752 74.944-149.376 62.336 144 13.696 9.408c7.424 5.312 15.104 11.264 22.592 17.536l11.008 9.536 8.32 7.808c41.472 41.088 67.584 85.952 64.448 140.544-2.048 36.16-17.472 66.048-47.36 83.008-5.696 3.2-10.88 5.44-15.232 7.04-15.744 5.76-31.36 7.936-49.152 8.256-5.184 0.064-9.92 0-15.424-0.192l-9.024-0.384-10.304-0.448a36.48 36.48 0 0 0-7.872 0.512l-2.368 0.64-1.664 0.512 1.408 4.032 1.152 2.368 35.776 109.056h-106.624l-0.96 2.304-0.384 3.328c0.32 3.456 2.112 7.36 7.04 12.48l4.288 4.096 6.912 6.528c20.16 20.16 33.408 46.208 32.32 79.744a110.656 110.656 0 0 1-36.864 77.184l-8.512 7.168 4.672-3.968L827.52 960 640 959.936V896h42.304a69.376 69.376 0 0 1-12.48-26.624l-1.28-7.296a67.2 67.2 0 0 1 21.76-56.96l6.4-5.44 5.696-5.056a37.12 37.12 0 0 0 11.072-23.936 34.752 34.752 0 0 0-10.88-24.96l-3.456-3.264-8.128-7.744c-17.792-18.368-27.584-38.784-29.312-60.928a92.16 92.16 0 0 1 21.76-65.28c11.52-14.08 32.128-23.04 52.864-23.04 2.752 0 5.504 0.256 8.32 0.576a101.312 101.312 0 0 1-7.808-18.944 77.952 77.952 0 0 1 2.56-54.272c12.096-27.392 40.64-44.352 74.688-46.08l9.408-0.128h29.376c10.048 0 20.096 0 28.16-2.944 5.632-2.112 13.76-5.824 14.848-26.048 1.92-33.6-22.848-65.28-43.712-85.952l-9.856-9.088-9.6-8.128-12.032-9.152-10.24-7.104-17.344-11.072a37.44 37.44 0 0 1-10.752-13.248l-2.112-5.44-1.216-3.904c-5.824 15.36-13.44 30.848-22.848 45.952a294.848 294.848 0 0 1-124.352 110.336c-47.424 22.08-85.568 41.664-117.76 65.664-32.96 24.64-58.88 53.504-81.472 90.88-13.184 21.76-18.048 48.768-18.88 74.624H304.192c0.064-17.152 2.048-34.816 5.952-52.736 9.472-44.16 30.208-90.24 63.168-140.16l12.928-18.944 32-44.16 16.96-23.744c27.264-39.168 48.64-76.16 48.64-109.312 0-23.68-9.472-63.232-36.608-96.896C416.192 147.584 371.712 128 314.88 128c-82.56 0-123.328 32.768-141.696 55.552 25.024 26.24 37.12 54.144 37.632 86.272 0.512 30.912-10.048 61.184-23.552 95.04l-5.952 14.72-9.792 24.512c-19.968 50.88-40.768 113.728-43.392 200-0.768 24 0.64 46.656 4.032 67.904H67.904a424.96 424.96 0 0 1-3.648-72.64c2.56-83.648 16.384-139.968 48-221.248l9.088-22.848 8.256-20.672 6.144-16.512c1.728-4.864 3.2-9.216 4.352-13.184l1.536-5.568 2.112-9.664c0.704-4.48 0.96-8.32 0.896-12.16a42.56 42.56 0 0 0-10.816-27.968l-5.248-6.016-44.928-47.104 40.896-50.752C164.8 95.744 230.4 64 320.192 64zM184.768 761.6v119.488l-0.128 8.96a103.04 103.04 0 0 1-3.968 27.136 51.072 51.072 0 0 1-20.096 26.432c-9.728 6.656-22.464 9.984-38.4 9.984-18.56 0-32.96-5.184-43.008-15.616-10.048-10.432-15.104-25.792-15.168-45.952l35.904-4.096 0.576 7.488a38.208 38.208 0 0 0 4.224 15.424 20.48 20.48 0 0 0 18.816 10.176c8.448 0 14.464-2.432 17.984-7.296 3.52-4.864 5.312-14.912 5.312-30.208V761.6h37.952zM320 761.6l75.584 188.8h-41.472l-16.448-42.88h-75.52l-15.552 42.88h-40.448l73.6-188.8H320z m176.192 0l9.6 0.128c15.296 0.512 26.752 2.112 34.368 4.928a43.392 43.392 0 0 1 21.952 18.112 54.4 54.4 0 0 1 8.192 29.76 50.368 50.368 0 0 1-12.48 35.072c-8.32 9.216-20.736 15.04-37.312 17.472 8.256 4.8 15.04 10.048 20.416 15.808 5.376 5.76 12.608 16 21.696 30.72l23.04 36.8h-45.568l-27.584-41.088-4.608-6.912a203.008 203.008 0 0 0-15.488-20.864 29.248 29.248 0 0 0-11.456-7.808 62.848 62.848 0 0 0-19.2-2.176h-7.68v78.848h-38.144V761.6h80.256z m-196.8 44.032l-25.472 70.08h51.52l-26.048-70.08z m154.688-12.096v47.872h28.16c18.304 0 29.696-0.768 34.24-2.304a20.48 20.48 0 0 0 10.688-7.936 24.576 24.576 0 0 0 3.84-14.208c0-6.4-1.664-11.52-5.056-15.36a23.36 23.36 0 0 0-14.336-7.424 228.992 228.992 0 0 0-20.608-0.64h-36.928z m343.68-433.536c20.608 0 35.968 17.472 36.864 38.08 0.96 20.48-17.6 38.08-36.864 38.08-20.672 0-35.968-17.408-36.864-38.08-0.96-20.48 17.6-38.08 36.864-38.08z"
p-id="6736" fill="#D77083"></path>
</svg>
);
export const MysqlSvg = () => (
<svg t="1641038977488" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
p-id="3761" width={svgSize} height={svgSize}>
......
......@@ -644,6 +644,9 @@ export default (): React.ReactNode => {
<li>
<Link>新增 作业生命周期管理</Link>
</li>
<li>
<Link>新增 FlinkJar Dialect 的管理</Link>
</li>
</ul>
</Paragraph>
</Timeline.Item>
......
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