Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaowei
dlink
Commits
03ce78a5
Commit
03ce78a5
authored
Jul 04, 2021
by
wenmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会话重构
parent
c0a20894
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
122 additions
and
55 deletions
+122
-55
JobManager.java
dlink-core/src/main/java/com/dlink/job/JobManager.java
+3
-18
ExecutorEntity.java
...-core/src/main/java/com/dlink/session/ExecutorEntity.java
+23
-12
SessionPool.java
dlink-core/src/main/java/com/dlink/session/SessionPool.java
+4
-0
DDL.ts
dlink-web/src/components/Studio/StudioEvent/DDL.ts
+5
-5
index.tsx
...omponents/Studio/StudioLeftTool/StudioConnector/index.tsx
+87
-20
No files found.
dlink-core/src/main/java/com/dlink/job/JobManager.java
View file @
03ce78a5
...
@@ -101,21 +101,6 @@ public class JobManager extends RunTime {
...
@@ -101,21 +101,6 @@ public class JobManager extends RunTime {
}
}
}
}
/*private boolean checkSession() {
if (config != null) {
String session = config.getSession();
if (session != null && !"".equals(session)) {
String[] keys = session.split("_");
if (keys.length > 1 && !"".equals(keys[1])) {
isSession = true;
return true;
}
}
}
isSession = false;
return false;
}*/
private
Executor
createExecutorWithSession
()
{
private
Executor
createExecutorWithSession
()
{
if
(
config
.
isUseSession
())
{
if
(
config
.
isUseSession
())
{
ExecutorEntity
executorEntity
=
SessionPool
.
get
(
config
.
getSession
());
ExecutorEntity
executorEntity
=
SessionPool
.
get
(
config
.
getSession
());
...
@@ -355,7 +340,7 @@ public class JobManager extends RunTime {
...
@@ -355,7 +340,7 @@ public class JobManager extends RunTime {
return
ResultPool
.
get
(
jobId
);
return
ResultPool
.
get
(
jobId
);
}
}
/*public static void cancel(String jobId
){
public
static
void
createSession
(
String
session
){
SelectResult selectResult = ResultPool.get(jobId);
}
*/
}
}
}
dlink-core/src/main/java/com/dlink/session/ExecutorEntity.java
View file @
03ce78a5
package
com
.
dlink
.
session
;
package
com
.
dlink
.
session
;
import
com.dlink.executor.Executor
;
import
com.dlink.executor.Executor
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.time.LocalDateTime
;
/**
/**
* FlinkEntity
* FlinkEntity
...
@@ -8,28 +12,35 @@ import com.dlink.executor.Executor;
...
@@ -8,28 +12,35 @@ import com.dlink.executor.Executor;
* @author wenmo
* @author wenmo
* @since 2021/5/25 14:45
* @since 2021/5/25 14:45
**/
**/
@Setter
@Getter
public
class
ExecutorEntity
{
public
class
ExecutorEntity
{
private
String
sessionId
;
private
String
sessionId
;
private
SessionType
type
;
private
boolean
useRemote
;
private
String
address
;
private
String
createUser
;
private
LocalDateTime
createTime
;
private
Executor
executor
;
private
Executor
executor
;
public
enum
SessionType
{
PUBLIC
,
PRIVATE
}
public
ExecutorEntity
(
String
sessionId
,
Executor
executor
)
{
public
ExecutorEntity
(
String
sessionId
,
Executor
executor
)
{
this
.
sessionId
=
sessionId
;
this
.
sessionId
=
sessionId
;
this
.
executor
=
executor
;
this
.
executor
=
executor
;
}
}
public
String
getSessionId
()
{
public
ExecutorEntity
(
String
sessionId
,
SessionType
type
,
boolean
useRemote
,
String
address
,
String
createUser
,
LocalDateTime
createTime
,
Executor
executor
)
{
return
sessionId
;
}
public
void
setSessionId
(
String
sessionId
)
{
this
.
sessionId
=
sessionId
;
this
.
sessionId
=
sessionId
;
}
this
.
type
=
type
;
this
.
useRemote
=
useRemote
;
public
Executor
getExecutor
()
{
this
.
address
=
address
;
return
executor
;
this
.
createUser
=
createUser
;
}
this
.
createTime
=
createTime
;
public
void
setExecutor
(
Executor
executor
)
{
this
.
executor
=
executor
;
this
.
executor
=
executor
;
}
}
}
}
dlink-core/src/main/java/com/dlink/session/SessionPool.java
View file @
03ce78a5
...
@@ -44,4 +44,8 @@ public class SessionPool {
...
@@ -44,4 +44,8 @@ public class SessionPool {
}
}
return
null
;
return
null
;
}
}
public
static
List
<
ExecutorEntity
>
list
(){
return
executorList
;
}
}
}
dlink-web/src/components/Studio/StudioEvent/DDL.ts
View file @
03ce78a5
...
@@ -49,16 +49,16 @@ export function removeTable(tablename:string,task:TaskType,dispatch:any) {
...
@@ -49,16 +49,16 @@ export function removeTable(tablename:string,task:TaskType,dispatch:any) {
});
});
}
}
export
function
clearSession
(
task
:
TaskType
,
dispatch
:
any
)
{
export
function
clearSession
(
session
:
string
,
task
:
TaskType
,
dispatch
:
any
)
{
Modal
.
confirm
({
Modal
.
confirm
({
title
:
'确认清空会话【'
+
task
.
session
+
'】?'
,
title
:
'确认清空会话【'
+
session
+
'】?'
,
okText
:
'确认'
,
okText
:
'确认'
,
cancelText
:
'取消'
,
cancelText
:
'取消'
,
onOk
:
async
()
=>
{
onOk
:
async
()
=>
{
let
session
=
{
let
para
=
{
id
:
task
.
session
,
id
:
session
,
};
};
const
res
=
handleRemove
(
'/api/studio/clearSession'
,[
session
]);
const
res
=
handleRemove
(
'/api/studio/clearSession'
,[
para
]);
res
.
then
((
result
)
=>
{
res
.
then
((
result
)
=>
{
showTables
(
task
,
dispatch
);
showTables
(
task
,
dispatch
);
});
});
...
...
dlink-web/src/components/Studio/StudioLeftTool/StudioConnector/index.tsx
View file @
03ce78a5
...
@@ -4,12 +4,14 @@ import {StateType} from "@/pages/FlinkSqlStudio/model";
...
@@ -4,12 +4,14 @@ import {StateType} from "@/pages/FlinkSqlStudio/model";
import
{
connect
}
from
"umi"
;
import
{
connect
}
from
"umi"
;
import
{
useState
}
from
"react"
;
import
{
useState
}
from
"react"
;
import
styles
from
"./index.less"
;
import
styles
from
"./index.less"
;
import
{
SearchOutlined
,
DownOutlined
,
DeleteOutlined
,
CommentOutlined
}
from
'@ant-design/icons'
;
import
{
SearchOutlined
,
DownOutlined
,
DeleteOutlined
,
CommentOutlined
,
MessageOutlined
}
from
'@ant-design/icons'
;
import
React
from
"react"
;
import
React
from
"react"
;
import
{
executeDDL
}
from
"@/pages/FlinkSqlStudio/service"
;
import
{
handleRemove
}
from
"@/components/Common/crud"
;
import
{
removeTable
,
showTables
,
clearSession
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
{
removeTable
,
showTables
,
clearSession
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
{
ModalForm
,
}
from
'@ant-design/pro-form'
;
import
ProDescriptions
from
'@ant-design/pro-descriptions'
;
import
ProTable
from
'@ant-design/pro-table'
;
const
StudioConnector
=
(
props
:
any
)
=>
{
const
StudioConnector
=
(
props
:
any
)
=>
{
...
@@ -19,7 +21,8 @@ const StudioConnector = (props:any) => {
...
@@ -19,7 +21,8 @@ const StudioConnector = (props:any) => {
const
[
searchText
,
setSearchText
]
=
useState
<
string
>
(
''
);
const
[
searchText
,
setSearchText
]
=
useState
<
string
>
(
''
);
const
[
searchedColumn
,
setSearchedColumn
]
=
useState
<
string
>
(
''
);
const
[
searchedColumn
,
setSearchedColumn
]
=
useState
<
string
>
(
''
);
const
[
modalVisit
,
setModalVisit
]
=
useState
(
false
);
const
[
modalVisit
,
setModalVisit
]
=
useState
(
false
);
const
[
row
,
setRow
]
=
useState
<
{}
>
();
const
[
type
,
setType
]
=
useState
<
number
>
();
const
[
sessionData
,
setSessionData
]
=
useState
<
{}
>
();
const
getColumnSearchProps
=
(
dIndex
)
=>
({
const
getColumnSearchProps
=
(
dIndex
)
=>
({
filterDropdown
:
({
setSelectedKeys
,
selectedKeys
,
confirm
,
clearFilters
})
=>
(
filterDropdown
:
({
setSelectedKeys
,
selectedKeys
,
confirm
,
clearFilters
})
=>
(
...
@@ -111,25 +114,20 @@ const StudioConnector = (props:any) => {
...
@@ -111,25 +114,20 @@ const StudioConnector = (props:any) => {
}
}
};
};
const
keySessionsEvent
=
(
key
,
item
)
=>
{
if
(
key
==
'delete'
){
clearSession
(
item
.
session
,
current
.
task
,
dispatch
);
}
else
{
message
.
warn
(
"敬请期待"
);
}
};
const
getTables
=
()
=>
{
const
getTables
=
()
=>
{
showTables
(
current
.
task
,
dispatch
);
showTables
(
current
.
task
,
dispatch
);
};
};
const
onClearSession
=
()
=>
{
const
onClearSession
=
()
=>
{
/*let newLoadings = [...loadings];
clearSession
(
current
.
task
.
session
,
current
.
task
,
dispatch
);
newLoadings[2] = true;
setLoadings(newLoadings);
let session = {
id:current.task.clusterId+'_'+current.task.session,
};
const res = handleRemove('/api/studio/clearSession',[session]);
res.then((result)=>{
getTables();
let newLoadings = [...loadings];
newLoadings[2] = false;
setLoadings(newLoadings);
});*/
clearSession
(
current
.
task
,
dispatch
);
};
};
const
getColumns
=
()
=>
{
const
getColumns
=
()
=>
{
...
@@ -162,9 +160,49 @@ const StudioConnector = (props:any) => {
...
@@ -162,9 +160,49 @@ const StudioConnector = (props:any) => {
return
columns
;
return
columns
;
};
};
const
getSessionsColumns
=
()
=>
{
let
columns
:
any
=
[{
title
:
"会话 Key"
,
dataIndex
:
"session"
,
key
:
"session"
,
sorter
:
true
,
...
getColumnSearchProps
(
"session"
),
},{
title
:
'操作'
,
dataIndex
:
'option'
,
valueType
:
'option'
,
render
:
(
_
,
record
)
=>
[
<
a
onClick=
{
()
=>
{
message
.
warn
(
'敬请期待'
);
}
}
>
描述
</
a
>,<
Divider
type=
"vertical"
/>,<
a
onClick=
{
()
=>
{
keySessionsEvent
(
'delete'
,
record
);
}
}
>
删除
</
a
>
],
},];
return
columns
;
};
const
showSessions
=
()
=>
{
};
return
(
return
(
<>
<>
<
div
style=
{
{
float
:
"right"
}
}
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"切换会话"
>
<
Button
type=
"text"
icon=
{
<
CommentOutlined
/>
}
onClick=
{
showSessions
}
/>
</
Tooltip
>
<
Tooltip
title=
"刷新连接器"
>
<
Tooltip
title=
"刷新连接器"
>
<
Button
<
Button
type=
"text"
type=
"text"
...
@@ -181,11 +219,40 @@ const StudioConnector = (props:any) => {
...
@@ -181,11 +219,40 @@ const StudioConnector = (props:any) => {
</
Tooltip
>
</
Tooltip
>
</
div
>
</
div
>
<
Breadcrumb
className=
{
styles
[
"session-path"
]
}
>
<
Breadcrumb
className=
{
styles
[
"session-path"
]
}
>
<
Comment
Outlined
/>
<
Message
Outlined
/>
<
Divider
type=
"vertical"
/>
<
Divider
type=
"vertical"
/>
<
Breadcrumb
.
Item
>
{
currentSessionCluster
.
session
}
</
Breadcrumb
.
Item
>
<
Breadcrumb
.
Item
>
{
currentSessionCluster
.
session
}
</
Breadcrumb
.
Item
>
</
Breadcrumb
>
</
Breadcrumb
>
{
currentSessionCluster
.
connectors
&&
currentSessionCluster
.
connectors
.
length
>
0
?(<
Table
dataSource=
{
currentSessionCluster
.
connectors
}
columns=
{
getColumns
()
}
size=
"small"
/>):(<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>)
}
{
currentSessionCluster
.
connectors
&&
currentSessionCluster
.
connectors
.
length
>
0
?(<
Table
dataSource=
{
currentSessionCluster
.
connectors
}
columns=
{
getColumns
()
}
size=
"small"
/>):(<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>)
}
<
ModalForm
// title="新建表单"
visible=
{
modalVisit
}
onFinish=
{
async
()
=>
{
setSessionData
(
undefined
);
}
}
onVisibleChange=
{
setModalVisit
}
submitter=
{
{
submitButtonProps
:
{
style
:
{
display
:
'none'
,
},
},
}
}
>
{
type
==
1
&&
(<
ProDescriptions
column=
{
2
}
title=
'全部共享会话'
>
<
ProDescriptions
.
Item
span=
{
2
}
>
{
sessionData
?
(<
Table
dataSource=
{
sessionData
}
columns=
{
getSessionsColumns
}
size=
"small"
/>):(<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>)
}
</
ProDescriptions
.
Item
>
</
ProDescriptions
>
)
}
</
ModalForm
>
</>
</>
);
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment