Commit a6ad2058 authored by godkaikai's avatar godkaikai

执行历史

parent a3f5b303
......@@ -28,14 +28,14 @@ public class StudioExecuteDTO {
private String savePointPath;
public JobConfig getJobConfig() {
return new JobConfig(useResult, useSession, getSession(), useRemote, clusterId, taskId, jobName, fragment, maxRowNum, checkPoint, parallelism, savePointPath);
return new JobConfig(useResult, useSession, session, useRemote, clusterId, taskId, jobName, fragment, maxRowNum, checkPoint, parallelism, savePointPath);
}
public String getSession() {
/*public String getSession() {
if(useRemote) {
return clusterId + "_" + session;
}else{
return "0_" + session;
}
}
}*/
}
......@@ -28,7 +28,7 @@ public class Job2MysqlHandler implements JobHandler {
history.setClusterId(job.getJobConfig().getClusterId());
history.setJobManagerAddress(job.getJobManagerAddress());
history.setJobName(job.getJobConfig().getJobName());
history.setSession(job.getJobConfig().getSessionKey());
history.setSession(job.getJobConfig().getSession());
history.setStatus(job.getStatus().ordinal());
history.setStartTime(job.getStartTime());
history.setTaskId(job.getJobConfig().getTaskId());
......@@ -54,9 +54,10 @@ public class Job2MysqlHandler implements JobHandler {
History history = new History();
history.setId(job.getId());
history.setJobId(job.getJobId());
history.setStatement(job.getStatement());
history.setStatus(job.getStatus().ordinal());
history.setEndTime(job.getEndTime());
history.setResult(JSONUtil.toJsonStr(job.getResult()));
// history.setResult(JSONUtil.toJsonStr(job.getResult()));
historyService.updateById(history);
return true;
}
......
......@@ -38,4 +38,8 @@ public class History implements Serializable {
@TableField(exist = false)
private String statusText;
@TableField(exist = false)
private String clusterAlias;
@TableField(exist = false)
private String taskAlias;
}
......@@ -30,9 +30,11 @@
<select id="selectForProTable" resultType="com.dlink.model.History">
select
a.*
a.*,
(select b.alias FROM dlink_cluster b where b.id=a.cluster_id) as clusterAlias,
(select c.alias FROM dlink_task c where c.id=a.task_id) as taskAlias
from
dlink_cluster a
dlink_history a
<where>
1=1
<if test='param.name!=null and param.name!=""'>
......
......@@ -17,7 +17,7 @@ public class JobConfig {
private boolean useResult;
private boolean useSession;
private String sessionKey;
private String session;
private boolean useRemote;
private Integer clusterId;
private String host;
......@@ -29,12 +29,12 @@ public class JobConfig {
private Integer parallelism;
private String savePointPath;
public JobConfig(boolean useResult, boolean useSession, String sessionKey, boolean useRemote, Integer clusterId,
public JobConfig(boolean useResult, boolean useSession, String session, boolean useRemote, Integer clusterId,
Integer taskId, String jobName, boolean useSqlFragment, Integer maxRowNum, Integer checkpoint,
Integer parallelism, String savePointPath) {
this.useResult = useResult;
this.useSession = useSession;
this.sessionKey = sessionKey;
this.session = session;
this.useRemote = useRemote;
this.clusterId = clusterId;
this.taskId = taskId;
......@@ -46,10 +46,10 @@ public class JobConfig {
this.savePointPath = savePointPath;
}
public JobConfig(boolean useResult, boolean useSession, String sessionKey, boolean useRemote, Integer clusterId) {
public JobConfig(boolean useResult, boolean useSession, String session, boolean useRemote, Integer clusterId) {
this.useResult = useResult;
this.useSession = useSession;
this.sessionKey = sessionKey;
this.session = session;
this.useRemote = useRemote;
this.clusterId = clusterId;
}
......
......@@ -117,12 +117,12 @@ public class JobManager extends RunTime {
private Executor createExecutorWithSession() {
if(config.isUseSession()) {
ExecutorEntity executorEntity = SessionPool.get(config.getSessionKey());
ExecutorEntity executorEntity = SessionPool.get(config.getSession());
if (executorEntity != null) {
executor = executorEntity.getExecutor();
} else {
createExecutor();
SessionPool.push(new ExecutorEntity(config.getSessionKey(), executor));
SessionPool.push(new ExecutorEntity(config.getSession(), executor));
}
}else {
createExecutor();
......@@ -134,7 +134,7 @@ public class JobManager extends RunTime {
public boolean init() {
handler = JobHandler.build();
String host = config.getHost();
if (config.isUseRemote() && host != null && !("").equals(host)) {
if (host != null && !("").equals(host)) {
String[] strs = host.split(NetConstant.COLON);
if (strs.length >= 2) {
jobManagerHost = strs[0];
......
.code{
width: 100%;
max-height: 500px;
display: block;
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: rgb(246, 248, 250);
border-radius: 3px;
}
import {Typography, Divider, Badge, Empty} from "antd";
import {StateType} from "@/pages/FlinkSqlStudio/model";
import {connect} from "umi";
const { Title, Paragraph, Text, Link } = Typography;
const StudioHistory2 = (props:any) => {
const {current} = props;
return (
<Typography>
{current.console.result.map((item)=> {
return (<Paragraph>
<blockquote><Link href={`http://${item.flinkHost}:${item.flinkPort}`} target="_blank">
[{item.sessionId}:{item.flinkHost}:{item.flinkPort}]
</Link> <Divider type="vertical" />{item.finishDate}
<Divider type="vertical" />
{!item.success ? <><Badge status="error"/><Text type="danger">Error</Text></> :
<><Badge status="success"/><Text type="success">Success</Text></>}
<Divider type="vertical" />
{item.jobName&&<Text code>{item.jobName}</Text>}
{item.jobId&&<Text code>{item.jobId}</Text>}
<Text keyboard>{item.time}ms</Text></blockquote>
{item.statement && (<pre style={{height:'40px'}}>{item.statement}</pre>)}
{item.msg ? item.msg : ''}
{item.error && (<pre style={{height:'100px'}}>{item.error}</pre>)}
</Paragraph>)
})}
{current.console.result.length==0?<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />:''}
</Typography>
);
};
export default connect(({ Studio }: { Studio: StateType }) => ({
current: Studio.current,
}))(StudioHistory2);
......@@ -5,6 +5,7 @@ import {useState} from "react";
// import Highlighter from 'react-highlight-words';
import { SearchOutlined } from '@ant-design/icons';
import {showJobData} from "@/components/Studio/StudioEvent/DQL";
import ProTable from '@ant-design/pro-table';
const { Option } = Select;
const { Title, Paragraph, Text, Link } = Typography;
......@@ -96,36 +97,11 @@ const StudioTable = (props:any) => {
return datas;
};
const onChange=(val:string)=>{
showJobData(val,dispatch);
};
return (
<Typography>
<Form.Item label="当前执行记录" tooltip="选择最近的执行记录,仅包含成功的记录">
<Select
style={{ width: '100%' }}
placeholder="选择最近的执行记录"
optionLabelProp="label"
onChange={onChange}
>
{current.console.result.map((item,index)=> {
if(item.status=='SUCCESS'&&item.jobId) {
let tag = (<> <Tooltip placement="topLeft" title={item.statement}>
<Tag color="processing">{item.startTime}</Tag>
<Tag color="processing">{item.endTime}</Tag>
<Text underline>[{item.jobConfig.sessionKey}:{item.jobConfig.host}]</Text>
{item.jobConfig.jobName&&<Text code>{item.jobConfig.jobName}</Text>}
{item.jobId&&<Text code>{item.jobId}</Text>}
{item.statement}</Tooltip></>);
return (<Option value={item.jobId} label={tag}>
{tag}
</Option>)
}
})}
</Select>
</Form.Item>
{result&&result.jobId&&!result.isDestroyed?(<Table dataSource={result.rowData} columns={getColumns(result.columns)} />):(<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />)}
{result&&result.jobId&&!result.isDestroyed?
(<ProTable dataSource={result.rowData} columns={getColumns(result.columns)} search={false}
/>):(<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />)}
</Typography>
);
};
......
import {Tabs, Empty} from "antd";
import {BarsOutlined,DatabaseOutlined,AppstoreOutlined,ClusterOutlined,ApiOutlined,FireOutlined,FunctionOutlined} from "@ant-design/icons";
import {BarsOutlined,DatabaseOutlined,AppstoreOutlined,ClusterOutlined,MessageOutlined,FireOutlined,FunctionOutlined} from "@ant-design/icons";
import {StateType} from "@/pages/FlinkSqlStudio/model";
import {connect} from "umi";
import styles from "./index.less";
......@@ -27,7 +27,7 @@ const StudioLeftTool = (props:any) => {
<TabPane tab={<span><ClusterOutlined /> 集群</span>} key="Cluster" >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane>
<TabPane tab={<span><ApiOutlined /> 连接器</span>} key="Connectors" >
<TabPane tab={<span><MessageOutlined /> 会话</span>} key="Connectors" >
<StudioConnector />
</TabPane>
<TabPane tab={<span><FireOutlined /> 任务</span>} key="FlinkTask" >
......
......@@ -13,6 +13,7 @@ import { postDataArray} from "@/components/Common/crud";
import {executeSql} from "@/pages/FlinkSqlStudio/service";
import StudioHelp from "./StudioHelp";
import {showTables} from "@/components/Studio/StudioEvent/DDL";
import {timeout} from "d3-timer";
const menu = (
<Menu>
......@@ -23,7 +24,7 @@ const menu = (
const StudioMenu = (props: any) => {
const {tabs,current,currentPath,form,dispatch} = props;
const {tabs,current,currentPath,form,refs,dispatch} = props;
const execute = () => {
let selectsql =null;
......@@ -57,6 +58,9 @@ const StudioMenu = (props: any) => {
key:taskKey,
icon: <SmileOutlined style={{ color: '#108ee9' }} />,
});
setTimeout(()=>{
refs?.history?.current?.reload();
},2000);
const result = executeSql(param);
result.then(res=>{
notification.close(taskKey);
......@@ -284,5 +288,6 @@ export default connect(({Studio}: { Studio: StateType }) => ({
current: Studio.current,
currentPath: Studio.currentPath,
tabs: Studio.tabs,
refs: Studio.refs,
// monaco: Studio.monaco,
}))(StudioMenu);
......@@ -71,6 +71,51 @@ const StudioConfig = (props: any) => {
>
<Input placeholder="自定义作业名" />
</Form.Item>
<Row>
<Col span={10}>
<Form.Item
label="共享会话" className={styles.form_item} name="useSession" valuePropName="checked"
tooltip={{ title: '开启共享会话,将进行 Flink Catalog 的共享', icon: <InfoCircleOutlined /> }}
>
<Switch checkedChildren="启用" unCheckedChildren="禁用"
/>
</Form.Item>
</Col>
<Col span={14}>
<Form.Item
label="会话 Key" tooltip="设置共享会话的 Key" name="session"
className={styles.form_item}>
<Select
placeholder="选择会话"
allowClear
onChange={onChangeClusterSession}
dropdownRender={menu => (
<div>
{menu}
<Divider style={{ margin: '4px 0' }} />
<div style={{ display: 'flex', flexWrap: 'nowrap', padding: 8 }}>
<Input style={{ flex: 'auto' }} value={newSesstion}
onChange={(e)=>{
setNewSesstion(e.target.value);
}}
/>
<a
style={{ flex: 'none', padding: '8px', display: 'block', cursor: 'pointer' }}
onClick={addSession}
>
<PlusOutlined />
</a>
</div>
</div>
)}
>
{session.map(item => (
<Option key={item}>{item}</Option>
))}
</Select>
</Form.Item>
</Col>
</Row>
<Row>
<Col span={12}>
<Form.Item
......@@ -97,51 +142,6 @@ const StudioConfig = (props: any) => {
<Switch checkedChildren="启用" unCheckedChildren="禁用"
/>
</Form.Item>
<Row>
<Col span={10}>
<Form.Item
label="共享会话" className={styles.form_item} name="useSession" valuePropName="checked"
tooltip={{ title: '开启共享会话,将进行 Flink Catalog 的共享', icon: <InfoCircleOutlined /> }}
>
<Switch checkedChildren="启用" unCheckedChildren="禁用"
/>
</Form.Item>
</Col>
<Col span={14}>
<Form.Item
label="会话 Key" tooltip="设置共享会话的 Key" name="session"
className={styles.form_item}>
<Select
placeholder="选择会话"
allowClear
onChange={onChangeClusterSession}
dropdownRender={menu => (
<div>
{menu}
<Divider style={{ margin: '4px 0' }} />
<div style={{ display: 'flex', flexWrap: 'nowrap', padding: 8 }}>
<Input style={{ flex: 'auto' }} value={newSesstion}
onChange={(e)=>{
setNewSesstion(e.target.value);
}}
/>
<a
style={{ flex: 'none', padding: '8px', display: 'block', cursor: 'pointer' }}
onClick={addSession}
>
<PlusOutlined />
</a>
</div>
</div>
)}
>
{session.map(item => (
<Option key={item}>{item}</Option>
))}
</Select>
</Form.Item>
</Col>
</Row>
</Form>
</>
);
......
......@@ -24,8 +24,23 @@
padding: 0px;
}
/* --- card 内偏移样式 --- start */
/* --- list toolbar隐藏滚动条 --- start */
.ant-pro-table-list-toolbar {
overflow-x: hidden;
overflow-y: hidden;
line-height: 1;
}
/* --- list toolbar隐藏滚动条 --- start */
/* --- list toolbar修改内偏移 --- start */
.ant-pro-table-list-toolbar-container {
padding: 0;
}
/* --- list toolbar修改内偏移 --- start */
/* --- prodescription item宽度 --- start */
.ant-descriptions-item-content {
width: 100%;
}
/* --- prodescription item宽度 --- start */
}
/* --- tabs 垂直样式 --- start */
......
......@@ -93,6 +93,9 @@ export type StateType = {
session: string[];
result:{};
rightClickMenu?: boolean;
refs:{
history:any;
};
};
export type ModelType = {
......@@ -196,7 +199,10 @@ const Model: ModelType = {
},
session: [],
result:{},
rightClickMenu: false
rightClickMenu: false,
refs:{
history:{},
}
},
effects: {
......
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