From dfabee346741f250ce5a2a2d710d07feb1fdb5d0 Mon Sep 17 00:00:00 2001 From: licho <lecho.sun@gmail.com> Date: Wed, 24 Jan 2024 22:40:14 +0800 Subject: [PATCH 1/2] fix: flink 1.18 set Signed-off-by: licho <lecho.sun@gmail.com> --- .../dinky/trans/ddl/CustomSetOperation.java | 39 ++----------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/dinky-client/dinky-client-base/src/main/java/org/dinky/trans/ddl/CustomSetOperation.java b/dinky-client/dinky-client-base/src/main/java/org/dinky/trans/ddl/CustomSetOperation.java index 1834228206..d29c43b5fa 100644 --- a/dinky-client/dinky-client-base/src/main/java/org/dinky/trans/ddl/CustomSetOperation.java +++ b/dinky-client/dinky-client-base/src/main/java/org/dinky/trans/ddl/CustomSetOperation.java @@ -80,8 +80,9 @@ private void parseConfig() { public Optional<? extends TableResult> execute(CustomTableEnvironment tEnv) { try { if (null != Class.forName("org.apache.log4j.Logger")) { - parseAndLoadConfiguration(statement, tEnv); - return Optional.of(TABLE_RESULT_OK); + if (this.isValid()) { + callSet(new SetOperation(this.getKey(), this.getValue()), tEnv); + } return Optional.of(TABLE_RESULT_OK); } } catch (ClassNotFoundException e) { logger.error("Class not found: org.apache.log4j.Logger"); @@ -98,26 +99,6 @@ public Optional<? extends TableResult> execute(CustomTableEnvironment tEnv) { return Optional.of(TABLE_RESULT_OK); } - public boolean parseAndLoadConfiguration(String statement, CustomTableEnvironment tEnv) { - List<Operation> operations = tEnv.getParser().parse(statement); - for (Operation operation : operations) { - if (operation instanceof SetOperation) { - callSet((SetOperation) operation, tEnv); - return true; - } else if (operation instanceof ResetOperation) { - callReset((ResetOperation) operation, tEnv); - return true; - } else if (operation instanceof CustomSetOperation) { - CustomSetOperation customSetOperation = (CustomSetOperation) operation; - if (customSetOperation.isValid()) { - callSet(new SetOperation(customSetOperation.getKey(), customSetOperation.getValue()), tEnv); - } - return true; - } - } - return false; - } - private void callSet(SetOperation setOperation, CustomTableEnvironment environment) { if (!setOperation.getKey().isPresent() || !setOperation.getValue().isPresent()) { return; @@ -132,20 +113,6 @@ private void callSet(SetOperation setOperation, CustomTableEnvironment environme setConfiguration(environment, Collections.singletonMap(key, value)); } - private void callReset(ResetOperation resetOperation, CustomTableEnvironment environment) { - final Optional<String> keyOptional = resetOperation.getKey(); - if (!keyOptional.isPresent()) { - return; - } - - String key = keyOptional.get().trim(); - if (Asserts.isNullString(key)) { - return; - } - - setConfiguration(environment, Collections.singletonMap(key, null)); - } - private void setConfiguration(CustomTableEnvironment environment, Map<String, String> config) { Configuration configuration = Configuration.fromMap(config); environment.getStreamExecutionEnvironment().getConfig().configure(configuration, null); From b843156383de4e235ff873f3914b0751291c05ef Mon Sep 17 00:00:00 2001 From: leechor <leechor@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:43:10 +0000 Subject: [PATCH 2/2] Spotless Apply --- .../dinky/trans/ddl/CustomSetOperation.java | 5 +- .../src/pages/DevOps/JobDetail/index.tsx | 179 +++++++++--------- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/dinky-client/dinky-client-base/src/main/java/org/dinky/trans/ddl/CustomSetOperation.java b/dinky-client/dinky-client-base/src/main/java/org/dinky/trans/ddl/CustomSetOperation.java index d29c43b5fa..686d3db814 100644 --- a/dinky-client/dinky-client-base/src/main/java/org/dinky/trans/ddl/CustomSetOperation.java +++ b/dinky-client/dinky-client-base/src/main/java/org/dinky/trans/ddl/CustomSetOperation.java @@ -29,8 +29,6 @@ import org.apache.flink.configuration.Configuration; import org.apache.flink.table.api.TableConfig; import org.apache.flink.table.api.TableResult; -import org.apache.flink.table.operations.Operation; -import org.apache.flink.table.operations.command.ResetOperation; import org.apache.flink.table.operations.command.SetOperation; import java.util.Collections; @@ -82,7 +80,8 @@ public Optional<? extends TableResult> execute(CustomTableEnvironment tEnv) { if (null != Class.forName("org.apache.log4j.Logger")) { if (this.isValid()) { callSet(new SetOperation(this.getKey(), this.getValue()), tEnv); - } return Optional.of(TABLE_RESULT_OK); + } + return Optional.of(TABLE_RESULT_OK); } } catch (ClassNotFoundException e) { logger.error("Class not found: org.apache.log4j.Logger"); diff --git a/dinky-web/src/pages/DevOps/JobDetail/index.tsx b/dinky-web/src/pages/DevOps/JobDetail/index.tsx index 6992d02e34..5b195a4a48 100644 --- a/dinky-web/src/pages/DevOps/JobDetail/index.tsx +++ b/dinky-web/src/pages/DevOps/JobDetail/index.tsx @@ -28,27 +28,27 @@ import JobMetrics from '@/pages/DevOps/JobDetail/JobMetrics'; import JobOperator from '@/pages/DevOps/JobDetail/JobOperator/JobOperator'; import JobConfigTab from '@/pages/DevOps/JobDetail/JobOverview/JobOverview'; import JobVersionTab from '@/pages/DevOps/JobDetail/JobVersion/JobVersionTab'; -import {refeshJobInstance} from '@/pages/DevOps/JobDetail/srvice'; -import {Jobs} from '@/types/DevOps/data'; -import {l} from '@/utils/intl'; -import {ClusterOutlined, FireOutlined, RocketOutlined} from '@ant-design/icons'; -import {PageContainer} from '@ant-design/pro-components'; -import {Tag} from 'antd'; -import {useState} from 'react'; -import {useLocation} from 'umi'; -import {history} from "@@/core/history"; +import { refeshJobInstance } from '@/pages/DevOps/JobDetail/srvice'; +import { Jobs } from '@/types/DevOps/data'; +import { l } from '@/utils/intl'; +import { history } from '@@/core/history'; +import { ClusterOutlined, FireOutlined, RocketOutlined } from '@ant-design/icons'; +import { PageContainer } from '@ant-design/pro-components'; +import { Tag } from 'antd'; +import { useState } from 'react'; +import { useLocation } from 'umi'; /** * Enum defining different operators for the JobDetail component. */ const OperatorEnum = { - JOB_BASE_INFO: 'job_base_info', - JOB_LOGS: 'job_logs', - JOB_VERSION: 'job_version', - JOB_CHECKPOINTS: 'job_checkpoints', - JOB_ALERT: 'job_alert', - JOB_METRICS: 'job_monitor', - JOB_LINEAGE: 'job_lineage' + JOB_BASE_INFO: 'job_base_info', + JOB_LOGS: 'job_logs', + JOB_VERSION: 'job_version', + JOB_CHECKPOINTS: 'job_checkpoints', + JOB_ALERT: 'job_alert', + JOB_METRICS: 'job_monitor', + JOB_LINEAGE: 'job_lineage' }; /** @@ -58,85 +58,86 @@ const OperatorEnum = { * @returns {JSX.Element} - The rendered JobDetail component. */ const JobDetail = (props: any) => { - const params = useLocation(); - const id = params.search.split('=')[1]; - if (!id) { - history.push(`/devops/`); - } + const params = useLocation(); + const id = params.search.split('=')[1]; + if (!id) { + history.push(`/devops/`); + } - const {data, run} = useHookRequest(refeshJobInstance, { - defaultParams: [id, false], - pollingInterval: 3000 - }); + const { data, run } = useHookRequest(refeshJobInstance, { + defaultParams: [id, false], + pollingInterval: 3000 + }); - const jobInfoDetail = data as Jobs.JobInfoDetail; + const jobInfoDetail = data as Jobs.JobInfoDetail; - const [tabKey, setTabKey] = useState<string>(OperatorEnum.JOB_BASE_INFO); + const [tabKey, setTabKey] = useState<string>(OperatorEnum.JOB_BASE_INFO); - // Define the components for each job operator - const JobOperatorItems = { - [OperatorEnum.JOB_BASE_INFO]: <JobConfigTab jobDetail={jobInfoDetail}/>, - [OperatorEnum.JOB_LOGS]: <JobLogsTab jobDetail={jobInfoDetail}/>, - [OperatorEnum.JOB_VERSION]: <JobVersionTab jobDetail={jobInfoDetail}/>, - [OperatorEnum.JOB_CHECKPOINTS]: <CheckPoints jobDetail={jobInfoDetail}/>, - [OperatorEnum.JOB_METRICS]: <JobMetrics jobDetail={jobInfoDetail}/>, - [OperatorEnum.JOB_LINEAGE]: <JobLineage jobDetail={jobInfoDetail}/>, - [OperatorEnum.JOB_ALERT]: <AlertHistory jobDetail={jobInfoDetail}/> - }; + // Define the components for each job operator + const JobOperatorItems = { + [OperatorEnum.JOB_BASE_INFO]: <JobConfigTab jobDetail={jobInfoDetail} />, + [OperatorEnum.JOB_LOGS]: <JobLogsTab jobDetail={jobInfoDetail} />, + [OperatorEnum.JOB_VERSION]: <JobVersionTab jobDetail={jobInfoDetail} />, + [OperatorEnum.JOB_CHECKPOINTS]: <CheckPoints jobDetail={jobInfoDetail} />, + [OperatorEnum.JOB_METRICS]: <JobMetrics jobDetail={jobInfoDetail} />, + [OperatorEnum.JOB_LINEAGE]: <JobLineage jobDetail={jobInfoDetail} />, + [OperatorEnum.JOB_ALERT]: <AlertHistory jobDetail={jobInfoDetail} /> + }; - // Define the tabs config for job operators - const JobOperatorTabs = [ - { - tab: l('devops.jobinfo.config.JobInfo'), - key: OperatorEnum.JOB_BASE_INFO - }, - {tab: l('devops.jobinfo.config.JobLogs'), key: OperatorEnum.JOB_LOGS}, - { - tab: l('devops.jobinfo.config.JobVersion'), - key: OperatorEnum.JOB_VERSION - }, - { - tab: l('devops.jobinfo.config.JobCheckpoints'), - key: OperatorEnum.JOB_CHECKPOINTS - }, - { - tab: l('devops.jobinfo.config.JobMonitor'), - key: OperatorEnum.JOB_METRICS - }, - { - tab: l('devops.jobinfo.config.JobLineage'), - key: OperatorEnum.JOB_LINEAGE - }, - {tab: l('devops.jobinfo.config.JobAlert'), key: OperatorEnum.JOB_ALERT} - ]; - console.log(!!data) + // Define the tabs config for job operators + const JobOperatorTabs = [ + { + tab: l('devops.jobinfo.config.JobInfo'), + key: OperatorEnum.JOB_BASE_INFO + }, + { tab: l('devops.jobinfo.config.JobLogs'), key: OperatorEnum.JOB_LOGS }, + { + tab: l('devops.jobinfo.config.JobVersion'), + key: OperatorEnum.JOB_VERSION + }, + { + tab: l('devops.jobinfo.config.JobCheckpoints'), + key: OperatorEnum.JOB_CHECKPOINTS + }, + { + tab: l('devops.jobinfo.config.JobMonitor'), + key: OperatorEnum.JOB_METRICS + }, + { + tab: l('devops.jobinfo.config.JobLineage'), + key: OperatorEnum.JOB_LINEAGE + }, + { tab: l('devops.jobinfo.config.JobAlert'), key: OperatorEnum.JOB_ALERT } + ]; + console.log(!!data); - return ( - <PageContainer loading={!data} - title={jobInfoDetail?.instance?.name} - subTitle={<JobLifeCycleTag status={jobInfoDetail?.instance?.step}/>} - ghost={false} - extra={<JobOperator jobDetail={jobInfoDetail} refesh={(isForce) => run(id, isForce)}/>} - onBack={() => window.history.back()} - breadcrumb={{}} - tabList={JobOperatorTabs} - onTabChange={(key) => setTabKey(key)} - tags={[ - <StatusTag status={jobInfoDetail?.instance?.status}/>, - <Tag key={'tg1'} color='blue'> - <FireOutlined/> {jobInfoDetail?.instance?.jid} - </Tag>, - <Tag key={'tg2'} color='blue'> - <RocketOutlined/> {jobInfoDetail?.history?.type} - </Tag>, - <Tag key={'tg3'} color='green'> - <ClusterOutlined/> {jobInfoDetail?.clusterInstance?.alias} - </Tag> - ]} - > - {JobOperatorItems[tabKey]} - </PageContainer> - ); + return ( + <PageContainer + loading={!data} + title={jobInfoDetail?.instance?.name} + subTitle={<JobLifeCycleTag status={jobInfoDetail?.instance?.step} />} + ghost={false} + extra={<JobOperator jobDetail={jobInfoDetail} refesh={(isForce) => run(id, isForce)} />} + onBack={() => window.history.back()} + breadcrumb={{}} + tabList={JobOperatorTabs} + onTabChange={(key) => setTabKey(key)} + tags={[ + <StatusTag status={jobInfoDetail?.instance?.status} />, + <Tag key={'tg1'} color='blue'> + <FireOutlined /> {jobInfoDetail?.instance?.jid} + </Tag>, + <Tag key={'tg2'} color='blue'> + <RocketOutlined /> {jobInfoDetail?.history?.type} + </Tag>, + <Tag key={'tg3'} color='green'> + <ClusterOutlined /> {jobInfoDetail?.clusterInstance?.alias} + </Tag> + ]} + > + {JobOperatorItems[tabKey]} + </PageContainer> + ); }; export default JobDetail;