Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flink 1.18 set #3061

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,7 +78,9 @@ private void parseConfig() {
public Optional<? extends TableResult> execute(CustomTableEnvironment tEnv) {
try {
if (null != Class.forName("org.apache.log4j.Logger")) {
parseAndLoadConfiguration(statement, tEnv);
if (this.isValid()) {
callSet(new SetOperation(this.getKey(), this.getValue()), tEnv);
}
return Optional.of(TABLE_RESULT_OK);
}
} catch (ClassNotFoundException e) {
Expand All @@ -98,26 +98,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;
Expand All @@ -132,20 +112,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);
Expand Down
179 changes: 90 additions & 89 deletions dinky-web/src/pages/DevOps/JobDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};

/**
Expand All @@ -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;
Loading