Unverified Commit 383babb2 authored by Pandas886's avatar Pandas886 Committed by GitHub

[Improvement] Optimize paimon to store monitoring data, causing threads not to be released (#3547)

parent 295eb6cd
...@@ -25,11 +25,20 @@ import org.dinky.data.vo.MetricsVO; ...@@ -25,11 +25,20 @@ import org.dinky.data.vo.MetricsVO;
import org.dinky.utils.PaimonUtil; import org.dinky.utils.PaimonUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import cn.hutool.core.text.StrFormatter; import cn.hutool.core.text.StrFormatter;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
/** /**
...@@ -39,38 +48,48 @@ import lombok.extern.slf4j.Slf4j; ...@@ -39,38 +48,48 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class MetricsContextHolder { public class MetricsContextHolder {
@Getter
protected static final MetricsContextHolder instance = new MetricsContextHolder(); protected static final MetricsContextHolder instance = new MetricsContextHolder();
public static MetricsContextHolder getInstances() { private final List<MetricsVO> metricsVOS = new CopyOnWriteArrayList<>();
return instance; private final AtomicLong lastDumpTime = new AtomicLong(System.currentTimeMillis());
}
/** // Create a ThreadFactory with custom naming
* Temporary cache monitoring information, mainly to prevent excessive buffering of write IO, ThreadFactory namedThreadFactory =
* when metricsVOS data reaches 1000 or the time exceeds 5 seconds new ThreadFactoryBuilder().setNameFormat("metrics-send-thread-%d").build();
*/
private final List<MetricsVO> metricsVOS = Collections.synchronizedList(new ArrayList<>());
private final Long lastDumpTime = System.currentTimeMillis(); // Create a custom ThreadPoolExecutor
ExecutorService pool = new ThreadPoolExecutor(
5, // Core pool size
10, // Maximum pool size, allows the pool to expand as needed
60L, // Keep alive time for idle threads
TimeUnit.SECONDS, // Unit of keep alive time
new LinkedBlockingQueue<Runnable>(10), // Use a larger queue to hold excess tasks
namedThreadFactory);
public void sendAsync(String key, MetricsVO o) { public void sendAsync(String key, MetricsVO o) {
CompletableFuture.runAsync(() -> { Object content = o.getContent();
Thread.currentThread().setContextClassLoader(MetricsContextHolder.class.getClassLoader()); if (content == null
|| (content instanceof ConcurrentHashMap && ((ConcurrentHashMap<?, ?>) content).isEmpty())) {
return; // Return early to avoid unnecessary operations
}
pool.execute(() -> {
metricsVOS.add(o); metricsVOS.add(o);
long duration = System.currentTimeMillis() - lastDumpTime; long current = System.currentTimeMillis();
synchronized (metricsVOS) { long duration = current - lastDumpTime.get();
if (metricsVOS.size() > 1000 || duration > 1000 * 5) { // Temporary cache monitoring information, mainly to prevent excessive buffering of write IO,
PaimonUtil.write(PaimonTableConstant.DINKY_METRICS, metricsVOS, MetricsVO.class); // when metricsVOS data reaches 1000 or the time exceeds 15 seconds
if (metricsVOS.size() >= 1000 || duration >= 15000) {
List<MetricsVO> snapshot;
synchronized (this) { // Enter synchronized block only when necessary
snapshot = new ArrayList<>(metricsVOS);
metricsVOS.clear(); metricsVOS.clear();
lastDumpTime.set(current);
} }
PaimonUtil.write(PaimonTableConstant.DINKY_METRICS, snapshot, MetricsVO.class);
} }
String topic = StrFormatter.format("{}/{}", SseTopic.METRICS.getValue(), key); String topic = StrFormatter.format("{}/{}", SseTopic.METRICS.getValue(), key);
SseSessionContextHolder.sendTopic(topic, o); SseSessionContextHolder.sendTopic(topic, o); // Ensure only successfully added metrics are sent
})
.whenComplete((v, t) -> {
if (t != null) {
log.error("send metrics async error", t);
}
}); });
} }
} }
...@@ -73,7 +73,7 @@ public class JobMetricsHandler { ...@@ -73,7 +73,7 @@ public class JobMetricsHandler {
metricsVO.setHeartTime(LocalDateTime.now()); metricsVO.setHeartTime(LocalDateTime.now());
metricsVO.setModel(jobId); metricsVO.setModel(jobId);
metricsVO.setDate(TimeUtil.nowStr("yyyy-MM-dd")); metricsVO.setDate(TimeUtil.nowStr("yyyy-MM-dd"));
MetricsContextHolder.getInstances().sendAsync(metricsVO.getModel(), metricsVO); MetricsContextHolder.getInstance().sendAsync(metricsVO.getModel(), metricsVO);
} catch (Exception e) { } catch (Exception e) {
log.error("Get and save Flink metrics error", e); log.error("Get and save Flink metrics error", e);
} }
......
...@@ -49,7 +49,7 @@ public class SystemMetricsHandler { ...@@ -49,7 +49,7 @@ public class SystemMetricsHandler {
metrics.setHeartTime(now); metrics.setHeartTime(now);
metrics.setModel(MetricsType.LOCAL.getType()); metrics.setModel(MetricsType.LOCAL.getType());
metrics.setDate(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); metrics.setDate(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
MetricsContextHolder.getInstances().sendAsync(metrics.getModel(), metrics); MetricsContextHolder.getInstance().sendAsync(metrics.getModel(), metrics);
log.debug("Collecting jvm information ends."); log.debug("Collecting jvm information ends.");
} }
......
...@@ -7,7 +7,7 @@ This project uses [Ant Design Pro](https://pro.ant.design) for initialization. H ...@@ -7,7 +7,7 @@ This project uses [Ant Design Pro](https://pro.ant.design) for initialization. H
## Environment preparation ## Environment preparation
| Environment | Version | Remarks | | Environment | Version | Remarks |
|-------------|---------|---------| | ----------- | ------- | ------- |
| node | 18+ | | | node | 18+ | |
| npm | 10+ | | | npm | 10+ | |
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
## 环境准备 ## 环境准备
| 环境 | 版本 | 备注 | | 环境 | 版本 | 备注 |
|------|-----|----| | ---- | ---- | ---- |
| node | 18+ | | | node | 18+ | |
| npm | 10+ | | | npm | 10+ | |
......
...@@ -21,7 +21,7 @@ import { l } from '@/utils/intl'; ...@@ -21,7 +21,7 @@ import { l } from '@/utils/intl';
import { ProFormSelect } from '@ant-design/pro-components'; import { ProFormSelect } from '@ant-design/pro-components';
import { ProFormSelectProps } from '@ant-design/pro-form/es/components/Select'; import { ProFormSelectProps } from '@ant-design/pro-form/es/components/Select';
import { Divider, Typography } from 'antd'; import { Divider, Typography } from 'antd';
import React from "react"; import React from 'react';
const { Link } = Typography; const { Link } = Typography;
......
...@@ -17,15 +17,14 @@ ...@@ -17,15 +17,14 @@
* *
*/ */
import {ProFormSelect} from '@ant-design/pro-components'; import { ProFormSelect } from '@ant-design/pro-components';
import {ProFormSelectProps} from '@ant-design/pro-form/es/components/Select'; import { ProFormSelectProps } from '@ant-design/pro-form/es/components/Select';
import {Divider} from 'antd'; import { Divider } from 'antd';
import React from "react"; import React from 'react';
export type FlinkUdfOptionsProps = ProFormSelectProps & {}; export type FlinkUdfOptionsProps = ProFormSelectProps & {};
const FlinkUdfOptionsSelect = (props: FlinkUdfOptionsProps) => { const FlinkUdfOptionsSelect = (props: FlinkUdfOptionsProps) => {
const renderTemplateDropDown = (item: any) => { const renderTemplateDropDown = (item: any) => {
return ( return (
<> <>
...@@ -38,7 +37,7 @@ const FlinkUdfOptionsSelect = (props: FlinkUdfOptionsProps) => { ...@@ -38,7 +37,7 @@ const FlinkUdfOptionsSelect = (props: FlinkUdfOptionsProps) => {
return ( return (
<ProFormSelect <ProFormSelect
{...props} {...props}
fieldProps={{ dropdownRender: (item) => renderTemplateDropDown(item), ...props.fieldProps}} fieldProps={{ dropdownRender: (item) => renderTemplateDropDown(item), ...props.fieldProps }}
/> />
); );
}; };
......
...@@ -92,7 +92,8 @@ export default class LineageDagExt extends LineageDag { ...@@ -92,7 +92,8 @@ export default class LineageDagExt extends LineageDag {
edges: result.edges edges: result.edges
}; };
setTimeout(() => { setTimeout(
() => {
let tmpEdges = result.edges; let tmpEdges = result.edges;
result.edges = []; result.edges = [];
// this.canvas.wrapper.style.visibility = 'hidden'; // this.canvas.wrapper.style.visibility = 'hidden';
...@@ -140,6 +141,8 @@ export default class LineageDagExt extends LineageDag { ...@@ -140,6 +141,8 @@ export default class LineageDagExt extends LineageDag {
this.canvas.on('system.canvas.click', () => { this.canvas.on('system.canvas.click', () => {
this.canvas.unfocus(); this.canvas.unfocus();
}); });
}, _.get(this.props, 'config.delayDraw', 0)); },
_.get(this.props, 'config.delayDraw', 0)
);
} }
} }
...@@ -450,8 +450,10 @@ export default { ...@@ -450,8 +450,10 @@ export default {
'pages.datastudio.label.jobConfig.addConfig.params': 'parameters', 'pages.datastudio.label.jobConfig.addConfig.params': 'parameters',
'pages.datastudio.label.jobConfig.addConfig.value': 'value', 'pages.datastudio.label.jobConfig.addConfig.value': 'value',
'pages.datastudio.label.udf': 'Udf Item', 'pages.datastudio.label.udf': 'Udf Item',
'pages.datastudio.label.udf.tip': 'Inject UDF item, Automatically add statement `create temporary function [functionName] as [className]` at the beginning of the SQL statement', 'pages.datastudio.label.udf.tip':
'pages.datastudio.label.udf.duplicate.tip': 'The class [className] selected this time already exists and duplicate injection is not allowed. Please reselect or cancel injection (delete and change line).', 'Inject UDF item, Automatically add statement `create temporary function [functionName] as [className]` at the beginning of the SQL statement',
'pages.datastudio.label.udf.duplicate.tip':
'The class [className] selected this time already exists and duplicate injection is not allowed. Please reselect or cancel injection (delete and change line).',
'pages.datastudio.label.udf.injectUdf': 'Inject UDF item', 'pages.datastudio.label.udf.injectUdf': 'Inject UDF item',
'pages.datastudio.label.udf.name': 'function name', 'pages.datastudio.label.udf.name': 'function name',
'pages.datastudio.label.udf.className': 'class name', 'pages.datastudio.label.udf.className': 'class name',
...@@ -1006,7 +1008,8 @@ export default { ...@@ -1006,7 +1008,8 @@ export default {
'Support for a single or bulk upload. Strictly prohibited from uploading company data or\n other banned files.', 'Support for a single or bulk upload. Strictly prohibited from uploading company data or\n other banned files.',
'rc.resource.filelist': 'File list', 'rc.resource.filelist': 'File list',
'rc.resource.sync': 'Sync remote files', 'rc.resource.sync': 'Sync remote files',
'rc.resource.sync.confirm': 'Please note that this operation will delete all records in the database and will affect running jobs as well as corresponding resource files referenced in UDF management, resulting in job failure. And UDF cannot be used in UDF management Please operate with caution!! Please confirm if you want to continue?', 'rc.resource.sync.confirm':
'Please note that this operation will delete all records in the database and will affect running jobs as well as corresponding resource files referenced in UDF management, resulting in job failure. And UDF cannot be used in UDF management Please operate with caution!! Please confirm if you want to continue?',
'rc.resource.copy_to_add_custom_jar': 'Copy as ADD CUSTOMJAR syntax', 'rc.resource.copy_to_add_custom_jar': 'Copy as ADD CUSTOMJAR syntax',
'rc.resource.copy_to_add_jar': 'Copy as ADD JAR syntax', 'rc.resource.copy_to_add_jar': 'Copy as ADD JAR syntax',
'rc.resource.copy_to_add_file': 'Copy as ADD FILE syntax', 'rc.resource.copy_to_add_file': 'Copy as ADD FILE syntax',
......
...@@ -429,8 +429,10 @@ export default { ...@@ -429,8 +429,10 @@ export default {
'pages.datastudio.label.jobConfig.addConfig.params': '参数', 'pages.datastudio.label.jobConfig.addConfig.params': '参数',
'pages.datastudio.label.jobConfig.addConfig.value': '值', 'pages.datastudio.label.jobConfig.addConfig.value': '值',
'pages.datastudio.label.udf': '注入UDF算子', 'pages.datastudio.label.udf': '注入UDF算子',
'pages.datastudio.label.udf.tip': '注入UDF算子, 自动在所有语句前注入`create temporary function [functionName] as [className]` 语句', 'pages.datastudio.label.udf.tip':
'pages.datastudio.label.udf.duplicate.tip': '此次选择的类[className]已经存在,不允许重复注入,请重新选择,或者取消注入(删除改行即可)。', '注入UDF算子, 自动在所有语句前注入`create temporary function [functionName] as [className]` 语句',
'pages.datastudio.label.udf.duplicate.tip':
'此次选择的类[className]已经存在,不允许重复注入,请重新选择,或者取消注入(删除改行即可)。',
'pages.datastudio.label.udf.injectUdf': '注入UDF', 'pages.datastudio.label.udf.injectUdf': '注入UDF',
'pages.datastudio.label.udf.name': '函数名称', 'pages.datastudio.label.udf.name': '函数名称',
'pages.datastudio.label.udf.className': '类名', 'pages.datastudio.label.udf.className': '类名',
...@@ -962,7 +964,8 @@ export default { ...@@ -962,7 +964,8 @@ export default {
'rc.resource.upload.tip2': '支持单个或批量上传。严禁上传公司数据或其他禁止上传的文件。', 'rc.resource.upload.tip2': '支持单个或批量上传。严禁上传公司数据或其他禁止上传的文件。',
'rc.resource.filelist': '文件列表', 'rc.resource.filelist': '文件列表',
'rc.resource.sync': '同步目录结构', 'rc.resource.sync': '同步目录结构',
'rc.resource.sync.confirm': '请注意: 该操作会删除数据库内的所有记录,且会关系到运行中的作业,以及UDF管理中引用的对应资源文件.从而导致作业运行失败。以及在 UDF管理中的 UDF 无法被使用. 请谨慎操作!! 请确认是否继续? ', 'rc.resource.sync.confirm':
'请注意: 该操作会删除数据库内的所有记录,且会关系到运行中的作业,以及UDF管理中引用的对应资源文件.从而导致作业运行失败。以及在 UDF管理中的 UDF 无法被使用. 请谨慎操作!! 请确认是否继续? ',
'rc.resource.copy_to_add_custom_jar': '复制为 ADD CUSTOMJAR 语法', 'rc.resource.copy_to_add_custom_jar': '复制为 ADD CUSTOMJAR 语法',
'rc.resource.copy_to_add_jar': '复制为 ADD JAR 语法', 'rc.resource.copy_to_add_jar': '复制为 ADD JAR 语法',
'rc.resource.copy_to_add_file': '复制为 ADD FILE 语法', 'rc.resource.copy_to_add_file': '复制为 ADD FILE 语法',
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
import FlinkOptionsSelect from '@/components/Flink/OptionsSelect'; import FlinkOptionsSelect from '@/components/Flink/OptionsSelect';
import {SAVE_POINT_TYPE} from '@/pages/DataStudio/constants'; import { SAVE_POINT_TYPE } from '@/pages/DataStudio/constants';
import { import {
getCurrentData, getCurrentData,
getCurrentTab, getCurrentTab,
...@@ -52,21 +52,21 @@ import { ...@@ -52,21 +52,21 @@ import {
ProFormText ProFormText
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { useModel } from '@umijs/max'; import { useModel } from '@umijs/max';
import {Alert, Input, Space} from 'antd'; import { Alert, Input, Space } from 'antd';
import { useForm } from 'antd/es/form/Form'; import { useForm } from 'antd/es/form/Form';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import React, {useEffect, useState} from 'react'; import React, { useEffect, useState } from 'react';
import { connect } from 'umi'; import { connect } from 'umi';
import FlinkUdfOptionsSelect from "@/components/Flink/UdfSelect"; import FlinkUdfOptionsSelect from '@/components/Flink/UdfSelect';
import {TaskUdfRefer} from "@/types/Studio/data"; import { TaskUdfRefer } from '@/types/Studio/data';
import {ErrorMessageAsync} from "@/utils/messages"; import { ErrorMessageAsync } from '@/utils/messages';
const JobConfig = (props: any) => { const JobConfig = (props: any) => {
const { const {
sessionCluster, sessionCluster,
clusterConfiguration, clusterConfiguration,
dispatch, dispatch,
tabs: {panes, activeKey}, tabs: { panes, activeKey },
env, env,
group, group,
rightContainer, rightContainer,
...@@ -81,8 +81,12 @@ const JobConfig = (props: any) => { ...@@ -81,8 +81,12 @@ const JobConfig = (props: any) => {
const [selectRunMode, setSelectRunMode] = useState<string>(current?.type ?? RUN_MODE.LOCAL); const [selectRunMode, setSelectRunMode] = useState<string>(current?.type ?? RUN_MODE.LOCAL);
const [currentSelectUdfIndexMap, setCurrentSelectUdfIndexMap] = useState<Map<number, TaskUdfRefer>>( const [currentSelectUdfIndexMap, setCurrentSelectUdfIndexMap] = useState<
new Map(current?.configJson?.udfRefer?.map((item: TaskUdfRefer, index: number) => [index, item]) ?? []) Map<number, TaskUdfRefer>
>(
new Map(
current?.configJson?.udfRefer?.map((item: TaskUdfRefer, index: number) => [index, item]) ?? []
)
); );
const { initialState, setInitialState } = useModel('@@initialState'); const { initialState, setInitialState } = useModel('@@initialState');
...@@ -105,7 +109,7 @@ const JobConfig = (props: any) => { ...@@ -105,7 +109,7 @@ const JobConfig = (props: any) => {
type: STUDIO_MODEL_ASYNC.queryFlinkUdfOptions type: STUDIO_MODEL_ASYNC.queryFlinkUdfOptions
}); });
setSelectRunMode(current?.type ?? RUN_MODE.LOCAL); setSelectRunMode(current?.type ?? RUN_MODE.LOCAL);
form.setFieldsValue({...current, type: current?.type}); form.setFieldsValue({ ...current, type: current?.type });
}, [current]); }, [current]);
const onValuesChange = (change: { [key in string]: any }, all: any) => { const onValuesChange = (change: { [key in string]: any }, all: any) => {
...@@ -130,11 +134,10 @@ const JobConfig = (props: any) => { ...@@ -130,11 +134,10 @@ const JobConfig = (props: any) => {
pane.isModified = true; pane.isModified = true;
dispatch({ dispatch({
type: STUDIO_MODEL.saveTabs, type: STUDIO_MODEL.saveTabs,
payload: {...props.tabs} payload: { ...props.tabs }
}); });
}; };
/** /**
* 处理 selectUdfIndexMap 的状态 | process the state of selectUdfIndexMap * 处理 selectUdfIndexMap 的状态 | process the state of selectUdfIndexMap
* @param index * @param index
...@@ -142,7 +145,7 @@ const JobConfig = (props: any) => { ...@@ -142,7 +145,7 @@ const JobConfig = (props: any) => {
* @param name * @param name
*/ */
function processSelectUdfMapState(index: number, className: string = '', name: string = '') { function processSelectUdfMapState(index: number, className: string = '', name: string = '') {
setCurrentSelectUdfIndexMap(prevState => { setCurrentSelectUdfIndexMap((prevState) => {
const newState = new Map(prevState); const newState = new Map(prevState);
newState.set(index, { newState.set(index, {
className: className, className: className,
...@@ -152,17 +155,19 @@ const JobConfig = (props: any) => { ...@@ -152,17 +155,19 @@ const JobConfig = (props: any) => {
}); });
} }
const handleClassChange = async (value: string, index: number) => { const handleClassChange = async (value: string, index: number) => {
// 检测 这个值是否已经存在 currentSelectUdfIndexMap 的 map 中 || check if the value already exists in the map of currentSelectUdfIndexMap // 检测 这个值是否已经存在 currentSelectUdfIndexMap 的 map 中 || check if the value already exists in the map of currentSelectUdfIndexMap
const values = currentSelectUdfIndexMap.values(); const values = currentSelectUdfIndexMap.values();
for (const taskUdfRefer of values) { for (const taskUdfRefer of values) {
if (taskUdfRefer?.className === value) { if (taskUdfRefer?.className === value) {
await ErrorMessageAsync(l('pages.datastudio.label.udf.duplicate.tip', '', {className: value}), 3); await ErrorMessageAsync(
l('pages.datastudio.label.udf.duplicate.tip', '', { className: value }),
3
);
// clear the value of the form // clear the value of the form
form.setFieldsValue({ form.setFieldsValue({
'configJson': { configJson: {
'udfRefer': { udfRefer: {
[index]: { [index]: {
className: '', className: '',
name: '' name: ''
...@@ -177,8 +182,8 @@ const JobConfig = (props: any) => { ...@@ -177,8 +182,8 @@ const JobConfig = (props: any) => {
const lowerName = simpleClassName.charAt(0).toLowerCase() + simpleClassName.slice(1); const lowerName = simpleClassName.charAt(0).toLowerCase() + simpleClassName.slice(1);
processSelectUdfMapState(index, value, lowerName); processSelectUdfMapState(index, value, lowerName);
form.setFieldsValue({ form.setFieldsValue({
'configJson': { configJson: {
'udfRefer': { udfRefer: {
[index]: { [index]: {
className: value, className: value,
name: lowerName name: lowerName
...@@ -188,20 +193,18 @@ const JobConfig = (props: any) => { ...@@ -188,20 +193,18 @@ const JobConfig = (props: any) => {
}); });
}; };
function handleNameChange(name: string, index: number) { function handleNameChange(name: string, index: number) {
// 拿到 currentSelectUdfIndexMap[index].get(index) 的值 || get the value of currentSelectUdfIndexMap[index].get(index) // 拿到 currentSelectUdfIndexMap[index].get(index) 的值 || get the value of currentSelectUdfIndexMap[index].get(index)
const currentSelectUdfIndexMapValue = currentSelectUdfIndexMap.get(index); const currentSelectUdfIndexMapValue = currentSelectUdfIndexMap.get(index);
// 如果 name 和 currentSelectUdfIndexMapValue?.name 相等 则不做任何操作 || if name and currentSelectUdfIndexMapValue?.name are equal, do nothing // 如果 name 和 currentSelectUdfIndexMapValue?.name 相等 则不做任何操作 || if name and currentSelectUdfIndexMapValue?.name are equal, do nothing
if (currentSelectUdfIndexMapValue?.name && name !== currentSelectUdfIndexMapValue?.name) { if (currentSelectUdfIndexMapValue?.name && name !== currentSelectUdfIndexMapValue?.name) {
// 更新 currentSelectUdfIndexMap 的值 // 更新 currentSelectUdfIndexMap 的值
processSelectUdfMapState(index, currentSelectUdfIndexMapValue?.className, name); processSelectUdfMapState(index, currentSelectUdfIndexMapValue?.className, name);
} }
form.setFieldsValue({ form.setFieldsValue({
'configJson': { configJson: {
'udfRefer': { udfRefer: {
[index]: { [index]: {
className: currentSelectUdfIndexMapValue?.className ?? '', className: currentSelectUdfIndexMapValue?.className ?? '',
name: name name: name
...@@ -236,7 +239,7 @@ const JobConfig = (props: any) => { ...@@ -236,7 +239,7 @@ const JobConfig = (props: any) => {
alertGroupId: -1 alertGroupId: -1
}} }}
className={'data-studio-form'} className={'data-studio-form'}
style={{paddingInline: '15px', overflow: 'scroll', marginTop: 5}} style={{ paddingInline: '15px', overflow: 'scroll', marginTop: 5 }}
form={form} form={form}
submitter={false} submitter={false}
layout='vertical' layout='vertical'
...@@ -248,7 +251,7 @@ const JobConfig = (props: any) => { ...@@ -248,7 +251,7 @@ const JobConfig = (props: any) => {
name='type' name='type'
label={l('global.table.execmode')} label={l('global.table.execmode')}
tooltip={l('pages.datastudio.label.jobConfig.execmode.tip')} tooltip={l('pages.datastudio.label.jobConfig.execmode.tip')}
rules={[{required: true, message: l('pages.datastudio.label.jobConfig.execmode.tip')}]} rules={[{ required: true, message: l('pages.datastudio.label.jobConfig.execmode.tip') }]}
options={buildRunModelOptions()} options={buildRunModelOptions()}
fieldProps={{ fieldProps={{
onChange: (value: string) => { onChange: (value: string) => {
...@@ -264,7 +267,7 @@ const JobConfig = (props: any) => { ...@@ -264,7 +267,7 @@ const JobConfig = (props: any) => {
{isCanRenderClusterInstance(selectRunMode) && ( {isCanRenderClusterInstance(selectRunMode) && (
<> <>
<ProFormSelect <ProFormSelect
style={{width: '100%'}} style={{ width: '100%' }}
placeholder={l('pages.datastudio.label.jobConfig.clusterConfig.tip1', '', { placeholder={l('pages.datastudio.label.jobConfig.clusterConfig.tip1', '', {
type: current?.type type: current?.type
})} })}
...@@ -319,7 +322,7 @@ const JobConfig = (props: any) => { ...@@ -319,7 +322,7 @@ const JobConfig = (props: any) => {
tooltip={l('pages.datastudio.label.jobConfig.flinksql.env.tip1')} tooltip={l('pages.datastudio.label.jobConfig.flinksql.env.tip1')}
options={buildEnvOptions(env)} options={buildEnvOptions(env)}
rules={[ rules={[
{required: true, message: l('pages.datastudio.label.jobConfig.flinksql.env.tip1')} { required: true, message: l('pages.datastudio.label.jobConfig.flinksql.env.tip1') }
]} ]}
showSearch showSearch
allowClear={false} allowClear={false}
...@@ -341,7 +344,7 @@ const JobConfig = (props: any) => { ...@@ -341,7 +344,7 @@ const JobConfig = (props: any) => {
valuePropName='checked' valuePropName='checked'
tooltip={{ tooltip={{
title: l('pages.datastudio.label.jobConfig.fragment.tip'), title: l('pages.datastudio.label.jobConfig.fragment.tip'),
icon: <InfoCircleOutlined/> icon: <InfoCircleOutlined />
}} }}
{...SWITCH_OPTIONS()} {...SWITCH_OPTIONS()}
/> />
...@@ -351,7 +354,7 @@ const JobConfig = (props: any) => { ...@@ -351,7 +354,7 @@ const JobConfig = (props: any) => {
valuePropName='checked' valuePropName='checked'
tooltip={{ tooltip={{
title: l('pages.datastudio.label.jobConfig.batchmode.tip'), title: l('pages.datastudio.label.jobConfig.batchmode.tip'),
icon: <InfoCircleOutlined/> icon: <InfoCircleOutlined />
}} }}
{...SWITCH_OPTIONS()} {...SWITCH_OPTIONS()}
/> />
...@@ -388,7 +391,7 @@ const JobConfig = (props: any) => { ...@@ -388,7 +391,7 @@ const JobConfig = (props: any) => {
name={['configJson', 'customConfig']} name={['configJson', 'customConfig']}
copyIconProps={false} copyIconProps={false}
creatorButtonProps={{ creatorButtonProps={{
style: {width: '100%'}, style: { width: '100%' },
creatorButtonText: l('pages.datastudio.label.jobConfig.addConfig') creatorButtonText: l('pages.datastudio.label.jobConfig.addConfig')
}} }}
> >
...@@ -418,20 +421,18 @@ const JobConfig = (props: any) => { ...@@ -418,20 +421,18 @@ const JobConfig = (props: any) => {
copyIconProps={false} copyIconProps={false}
onAfterRemove={(_, index) => { onAfterRemove={(_, index) => {
// 删除一项之后拿到 index 从 currentSelectUdfIndexMap 中删除对应的值 || get the value from currentSelectUdfIndexMap and delete it // 删除一项之后拿到 index 从 currentSelectUdfIndexMap 中删除对应的值 || get the value from currentSelectUdfIndexMap and delete it
setCurrentSelectUdfIndexMap(prevState => { setCurrentSelectUdfIndexMap((prevState) => {
const newState = new Map(prevState); const newState = new Map(prevState);
newState.delete(index); newState.delete(index);
return newState; return newState;
}); });
}} }}
creatorButtonProps={{ creatorButtonProps={{
style: {width: '100%'}, style: { width: '100%' },
creatorButtonText: l('pages.datastudio.label.udf.injectUdf') creatorButtonText: l('pages.datastudio.label.udf.injectUdf')
}} }}
> >
{( {(_, index) => {
_, index
) => {
return ( return (
<ProFormGroup> <ProFormGroup>
<Space key={'udf' + index} align='baseline'> <Space key={'udf' + index} align='baseline'>
...@@ -446,20 +447,17 @@ const JobConfig = (props: any) => { ...@@ -446,20 +447,17 @@ const JobConfig = (props: any) => {
options={flinkUdfOptions} options={flinkUdfOptions}
onChange={(value: string) => handleClassChange(value, index)} onChange={(value: string) => handleClassChange(value, index)}
/> />
<ProForm.Item <ProForm.Item name={'name'}>
name={'name'}
>
<Input <Input
onChange={(e) => handleNameChange(e.target.value, index)} onChange={(e) => handleNameChange(e.target.value, index)}
placeholder={l('pages.datastudio.label.udf.name')} placeholder={l('pages.datastudio.label.udf.name')}
style={{width: calculatorWidth(rightContainer.width) - 80}} style={{ width: calculatorWidth(rightContainer.width) - 80 }}
/> />
</ProForm.Item> </ProForm.Item>
</Space> </Space>
</ProFormGroup> </ProFormGroup>
); );
} }}
}
</ProFormList> </ProFormList>
</ProForm> </ProForm>
</div> </div>
......
...@@ -36,7 +36,6 @@ export function getFlinkConfigs() { ...@@ -36,7 +36,6 @@ export function getFlinkConfigs() {
export function getFlinkUdfOptions() { export function getFlinkUdfOptions() {
return queryDataByParams(API_CONSTANTS.ALL_UDF_LIST); return queryDataByParams(API_CONSTANTS.ALL_UDF_LIST);
} }
export function querySuggestionData(params: any) { export function querySuggestionData(params: any) {
......
...@@ -28,7 +28,8 @@ import { ...@@ -28,7 +28,8 @@ import {
import { import {
getClusterConfigurationData, getClusterConfigurationData,
getEnvData, getEnvData,
getFlinkConfigs, getFlinkUdfOptions, getFlinkConfigs,
getFlinkUdfOptions,
getSessionData, getSessionData,
querySuggestionData querySuggestionData
} from '@/pages/DataStudio/RightContainer/JobConfig/service'; } from '@/pages/DataStudio/RightContainer/JobConfig/service';
......
...@@ -60,7 +60,7 @@ const ConfigurationModal: React.FC<ConfigurationModalProps & connect> = (props) ...@@ -60,7 +60,7 @@ const ConfigurationModal: React.FC<ConfigurationModalProps & connect> = (props)
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
dispatch({ dispatch({
type:STUDIO_MODEL_ASYNC.queryFlinkConfigOptions type: STUDIO_MODEL_ASYNC.queryFlinkConfigOptions
}); });
} }
form.setFieldsValue(value); form.setFieldsValue(value);
......
...@@ -48,7 +48,7 @@ import { WarningOutlined } from '@ant-design/icons'; ...@@ -48,7 +48,7 @@ import { WarningOutlined } from '@ant-design/icons';
import { ProCard } from '@ant-design/pro-components'; import { ProCard } from '@ant-design/pro-components';
import { history } from '@umijs/max'; import { history } from '@umijs/max';
import { useAsyncEffect } from 'ahooks'; import { useAsyncEffect } from 'ahooks';
import {Button, Modal, Result} from 'antd'; import { Button, Modal, Result } from 'antd';
import { MenuInfo } from 'rc-menu/es/interface'; import { MenuInfo } from 'rc-menu/es/interface';
import React, { useCallback, useEffect, useRef, useState } from 'react'; import React, { useCallback, useEffect, useRef, useState } from 'react';
import { connect } from 'umi'; import { connect } from 'umi';
...@@ -246,7 +246,6 @@ const ResourceOverView: React.FC<connect> = (props) => { ...@@ -246,7 +246,6 @@ const ResourceOverView: React.FC<connect> = (props) => {
await refreshTree(); await refreshTree();
} }
}); });
}; };
/** /**
......
...@@ -47,7 +47,7 @@ export type TaskUdfConfig = { ...@@ -47,7 +47,7 @@ export type TaskUdfConfig = {
export type TaskUdfRefer = { export type TaskUdfRefer = {
name: string; name: string;
className: string; className: string;
} };
export type ConfigItem = { export type ConfigItem = {
key: string; key: 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