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
4b6db6d8
Commit
4b6db6d8
authored
Jul 07, 2021
by
godkaikai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会话创建
parent
a5426c4e
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
154 additions
and
76 deletions
+154
-76
ClusterController.java
...src/main/java/com/dlink/controller/ClusterController.java
+3
-3
ClusterService.java
...admin/src/main/java/com/dlink/service/ClusterService.java
+4
-0
ClusterServiceImpl.java
.../main/java/com/dlink/service/impl/ClusterServiceImpl.java
+18
-8
StudioServiceImpl.java
...c/main/java/com/dlink/service/impl/StudioServiceImpl.java
+14
-16
pom.xml
dlink-core/pom.xml
+3
-3
dlink.sql
dlink-doc/sql/dlink.sql
+1
-0
crud.ts
dlink-web/src/components/Common/crud.ts
+9
-1
SessionForm.tsx
...StudioLeftTool/StudioConnector/components/SessionForm.tsx
+50
-22
data.d.ts
...omponents/Studio/StudioLeftTool/StudioConnector/data.d.ts
+5
-5
index.tsx
...omponents/Studio/StudioLeftTool/StudioConnector/index.tsx
+34
-3
model.ts
dlink-web/src/pages/FlinkSqlStudio/model.ts
+13
-15
No files found.
dlink-admin/src/main/java/com/dlink/controller/ClusterController.java
View file @
4b6db6d8
...
...
@@ -80,10 +80,10 @@ public class ClusterController {
}
/**
* 获取
指定ID的信息
* 获取
可用的集群列表
*/
@
Pos
tMapping
(
"/listEnabledAll"
)
public
Result
listEnabledAll
()
throws
Exception
{
@
Ge
tMapping
(
"/listEnabledAll"
)
public
Result
listEnabledAll
()
{
List
<
Cluster
>
clusters
=
clusterService
.
listEnabledAll
();
return
Result
.
succeed
(
clusters
,
"获取成功"
);
}
...
...
dlink-admin/src/main/java/com/dlink/service/ClusterService.java
View file @
4b6db6d8
...
...
@@ -19,5 +19,9 @@ public interface ClusterService extends ISuperService<Cluster> {
String
buildEnvironmentAddress
(
boolean
useRemote
,
Integer
id
);
String
buildRemoteEnvironmentAddress
(
Integer
id
);
String
buildLocalEnvironmentAddress
();
List
<
Cluster
>
listEnabledAll
();
}
dlink-admin/src/main/java/com/dlink/service/impl/ClusterServiceImpl.java
View file @
4b6db6d8
...
...
@@ -44,16 +44,26 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
@Override
public
String
buildEnvironmentAddress
(
boolean
useRemote
,
Integer
id
)
{
if
(
useRemote
)
{
return
getJobManagerAddress
(
getById
(
id
)
);
return
buildRemoteEnvironmentAddress
(
id
);
}
else
{
try
{
InetAddress
inetAddress
=
InetAddress
.
getLocalHost
();
if
(
inetAddress
!=
null
)
{
return
inetAddress
.
getHostAddress
()+
NetConstant
.
COLON
+
FlinkConstant
.
PORT
;
}
}
catch
(
UnknownHostException
e
)
{
e
.
printStackTrace
();
return
buildLocalEnvironmentAddress
();
}
}
@Override
public
String
buildRemoteEnvironmentAddress
(
Integer
id
)
{
return
getJobManagerAddress
(
getById
(
id
));
}
@Override
public
String
buildLocalEnvironmentAddress
()
{
try
{
InetAddress
inetAddress
=
InetAddress
.
getLocalHost
();
if
(
inetAddress
!=
null
)
{
return
inetAddress
.
getHostAddress
()+
NetConstant
.
COLON
+
FlinkConstant
.
PORT
;
}
}
catch
(
UnknownHostException
e
)
{
e
.
printStackTrace
();
}
return
FlinkConstant
.
LOCAL_HOST
;
}
...
...
dlink-admin/src/main/java/com/dlink/service/impl/StudioServiceImpl.java
View file @
4b6db6d8
package
com
.
dlink
.
service
.
impl
;
import
com.dlink.assertion.Assert
;
import
com.dlink.cluster.FlinkCluster
;
import
com.dlink.constant.FlinkConstant
;
import
com.dlink.dto.SessionDTO
;
import
com.dlink.dto.StudioDDLDTO
;
import
com.dlink.dto.StudioExecuteDTO
;
import
com.dlink.exception.BusException
;
import
com.dlink.exception.JobException
;
import
com.dlink.executor.Executor
;
import
com.dlink.executor.ExecutorSetting
;
import
com.dlink.explainer.ca.CABuilder
;
import
com.dlink.explainer.ca.TableCANode
;
import
com.dlink.job.JobConfig
;
...
...
@@ -17,7 +10,6 @@ import com.dlink.job.JobManager;
import
com.dlink.job.JobResult
;
import
com.dlink.model.Cluster
;
import
com.dlink.result.IResult
;
import
com.dlink.result.RunResult
;
import
com.dlink.result.SelectResult
;
import
com.dlink.service.ClusterService
;
import
com.dlink.service.StudioService
;
...
...
@@ -27,8 +19,6 @@ import com.dlink.session.SessionPool;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.List
;
/**
...
...
@@ -66,12 +56,20 @@ public class StudioServiceImpl implements StudioService {
@Override
public
boolean
createSession
(
SessionDTO
sessionDTO
,
String
createUser
)
{
Cluster
cluster
=
clusterService
.
getById
(
sessionDTO
.
getClusterId
());
SessionConfig
sessionConfig
=
SessionConfig
.
build
(
sessionDTO
.
getType
(),
sessionDTO
.
isUseRemote
(),
cluster
.
getId
(),
cluster
.
getAlias
(),
clusterService
.
buildEnvironmentAddress
(
sessionDTO
.
isUseRemote
(),
sessionDTO
.
getClusterId
()));
return
JobManager
.
createSession
(
sessionDTO
.
getSession
(),
sessionConfig
,
createUser
);
if
(
sessionDTO
.
isUseRemote
())
{
Cluster
cluster
=
clusterService
.
getById
(
sessionDTO
.
getClusterId
());
SessionConfig
sessionConfig
=
SessionConfig
.
build
(
sessionDTO
.
getType
(),
true
,
cluster
.
getId
(),
cluster
.
getAlias
(),
clusterService
.
buildEnvironmentAddress
(
true
,
sessionDTO
.
getClusterId
()));
return
JobManager
.
createSession
(
sessionDTO
.
getSession
(),
sessionConfig
,
createUser
);
}
else
{
SessionConfig
sessionConfig
=
SessionConfig
.
build
(
sessionDTO
.
getType
(),
false
,
null
,
null
,
clusterService
.
buildEnvironmentAddress
(
false
,
null
));
return
JobManager
.
createSession
(
sessionDTO
.
getSession
(),
sessionConfig
,
createUser
);
}
}
@Override
...
...
dlink-core/pom.xml
View file @
4b6db6d8
...
...
@@ -37,17 +37,17 @@
<dependency>
<groupId>
com.dlink
</groupId>
<artifactId>
dlink-client-1.12
</artifactId>
<
!--<scope>provided</scope>--
>
<
scope>
provided
</scope
>
</dependency>
<dependency>
<groupId>
com.dlink
</groupId>
<artifactId>
dlink-connector-jdbc
</artifactId>
<
!--<scope>provided</scope>--
>
<
scope>
provided
</scope
>
</dependency>
<dependency>
<groupId>
com.dlink
</groupId>
<artifactId>
dlink-function
</artifactId>
<
!--<scope>provided</scope>--
>
<
scope>
provided
</scope
>
</dependency>
</dependencies>
</project>
\ No newline at end of file
dlink-doc/sql/dlink.sql
View file @
4b6db6d8
...
...
@@ -315,6 +315,7 @@ CREATE TABLE `dlink_history` (
`job_name`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'作业名'
,
`job_manager_address`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'JM地址'
,
`status`
int
(
1
)
NOT
NULL
DEFAULT
0
COMMENT
'状态'
,
`type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'类型'
,
`statement`
text
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
COMMENT
'语句集'
,
`error`
text
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
COMMENT
'异常信息'
,
`result`
text
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
COMMENT
'结果集'
,
...
...
dlink-web/src/components/Common/crud.ts
View file @
4b6db6d8
import
request
from
"umi-request"
;
import
{
TableListParams
}
from
"@/components/Common/data"
;
import
{
message
,
Modal
}
from
"antd"
;
import
{
submitTask
}
from
"@/pages/Dlink/Task/service"
;
export
async
function
queryData
(
url
:
string
,
params
?:
TableListParams
)
{
return
request
(
url
,
{
...
...
@@ -12,6 +11,15 @@ export async function queryData(url:string,params?: TableListParams) {
});
}
export
async
function
getData
(
url
:
string
,
params
?:
any
)
{
return
request
(
url
,
{
method
:
'GET'
,
params
:
{
...
params
,
},
});
}
export
async
function
removeData
(
url
:
string
,
params
:
any
[])
{
return
request
(
url
,
{
method
:
'DELETE'
,
...
...
dlink-web/src/components/Studio/StudioLeftTool/StudioConnector/components/SessionForm.tsx
View file @
4b6db6d8
import
React
,
{
use
Effect
,
use
State
}
from
'react'
;
import
{
Form
,
Button
,
Input
,
Modal
}
from
'antd'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Form
,
Button
,
Input
,
Modal
,
Select
,
Switch
}
from
'antd'
;
import
type
{
SessionItem
}
from
'../data.d'
;
import
{
SessionItem
}
from
'../data.d'
;
import
{
connect
}
from
"umi"
;
import
{
StateType
}
from
"@/pages/FlinkSqlStudio/model"
;
export
type
UpdateFormProps
=
{
onCancel
:
(
flag
?:
boolean
,
formVals
?:
Partial
<
SessionItem
>
)
=>
void
;
onSubmit
:
(
values
:
Partial
<
SessionItem
>
)
=>
void
;
updateModalVisible
:
boolean
;
isCreate
:
boolean
;
values
:
Partial
<
SessionItem
>
;
};
const
FormItem
=
Form
.
Item
;
const
{
Item
}
=
Form
;
const
{
Option
}
=
Select
;
const
formLayout
=
{
labelCol
:
{
span
:
7
},
...
...
@@ -21,9 +23,11 @@ const formLayout = {
const
SessionForm
:
React
.
FC
<
UpdateFormProps
>
=
(
props
)
=>
{
const
[
formVals
,
setFormVals
]
=
useState
<
Partial
<
SessionItem
>>
({
session
:
props
.
values
.
session
,
type
:
props
.
values
.
sessionConfig
?.
type
,
useRemote
:
props
.
values
.
sessionConfig
?.
useRemote
,
address
:
props
.
values
.
sessionConfig
?.
address
,
type
:
props
.
values
.
type
,
useRemote
:
props
.
values
.
useRemote
,
clusterId
:
props
.
values
.
clusterId
,
clusterName
:
props
.
values
.
clusterName
,
address
:
props
.
values
.
address
,
createUser
:
props
.
values
.
createUser
,
createTime
:
props
.
values
.
createTime
,
});
...
...
@@ -35,7 +39,6 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
onCancel
:
handleUpdateModalVisible
,
updateModalVisible
,
values
,
isCreate
,
}
=
props
;
const
submitForm
=
async
()
=>
{
...
...
@@ -47,18 +50,41 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
const
renderContent
=
()
=>
{
return
(
<>
<
Form
Item
<
Item
name=
"session"
label=
"名称"
rules=
{
[{
required
:
true
,
message
:
'请输入唯一名称!'
}]
}
>
<
Input
placeholder=
"请输入"
/>
</
Form
Item
>
<
Form
Item
name=
"
alias
"
label=
"
别名
"
</
Item
>
<
Item
name=
"
type
"
label=
"
访问权限
"
rules=
{
[{
required
:
true
,
message
:
'请输入别名!'
}]
}
>
<
Input
placeholder=
"请输入"
/>
</
FormItem
>
<
Select
defaultValue=
"PUBLIC"
>
<
Option
value=
"PUBLIC"
>
共享
</
Option
>
<
Option
value=
"PRIVATE"
>
私密
</
Option
>
</
Select
>
</
Item
>
<
Item
name=
"useRemote"
label=
"是否远程"
rules=
{
[{
required
:
true
,
message
:
'禁用则为本地模式'
}]
}
>
<
Switch
checkedChildren=
"启用"
unCheckedChildren=
"禁用"
defaultChecked=
{
formVals
.
useRemote
}
/>
</
Item
>
<
Item
name=
"clusterId"
label=
"集群"
rules=
{
[{
required
:
true
,
message
:
'请输入别名!'
}]
}
>
<
Select
style=
{
{
width
:
'100%'
}
}
placeholder=
"选择Flink集群"
defaultValue=
{
0
}
optionLabelProp=
"label"
>
</
Select
>
</
Item
>
</>
);
};
...
...
@@ -79,7 +105,7 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
width=
{
640
}
bodyStyle=
{
{
padding
:
'32px 40px 48px'
}
}
destroyOnClose
title=
{
isCreate
?
'创建新作业'
:
(
'重命名作业-'
+
formVals
.
name
)
}
title=
{
'创建新会话'
}
visible=
{
updateModalVisible
}
footer=
{
renderFooter
()
}
onCancel=
{
()
=>
handleUpdateModalVisible
()
}
...
...
@@ -88,10 +114,10 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
{
...
formLayout
}
form=
{
form
}
initialValues=
{
{
id
:
formVals
.
id
,
name
:
formVals
.
nam
e
,
alias
:
formVals
.
alias
,
parentId
:
formVals
.
parent
Id
,
session
:
formVals
.
session
,
type
:
formVals
.
typ
e
,
useRemote
:
formVals
.
useRemote
,
clusterId
:
formVals
.
cluster
Id
,
}
}
>
{
renderContent
()
}
...
...
@@ -100,4 +126,6 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
);
};
export
default
SessionForm
;
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
cluster
:
Studio
.
cluster
,
}))(
SessionForm
);
dlink-web/src/components/Studio/StudioLeftTool/StudioConnector/data.d.ts
View file @
4b6db6d8
export
type
SessionItem
=
{
session
:
string
,
sessionConfig
:
{
type
:
string
,
useRemote
:
boolean
,
clusterId
:
number
,
}
,
type
:
string
,
useRemote
:
boolean
,
clusterId
:
number
,
clusterName
:
string
,
address
:
string
,
createUser
:
string
,
createTime
:
string
,
};
dlink-web/src/components/Studio/StudioLeftTool/StudioConnector/index.tsx
View file @
4b6db6d8
...
...
@@ -12,6 +12,8 @@ import {
}
from
'@ant-design/pro-form'
;
import
ProDescriptions
from
'@ant-design/pro-descriptions'
;
import
ProTable
from
'@ant-design/pro-table'
;
import
{
getData
,
handleAddOrUpdate
}
from
"@/components/Common/crud"
;
import
SessionForm
from
"@/components/Studio/StudioLeftTool/StudioConnector/components/SessionForm"
;
const
StudioConnector
=
(
props
:
any
)
=>
{
...
...
@@ -23,6 +25,8 @@ const StudioConnector = (props:any) => {
const
[
modalVisit
,
setModalVisit
]
=
useState
(
false
);
const
[
type
,
setType
]
=
useState
<
number
>
();
const
[
sessionData
,
setSessionData
]
=
useState
<
{}
>
();
const
[
createSessionModalVisible
,
handleCreateSessionModalVisible
]
=
useState
<
boolean
>
(
false
);
const
getColumnSearchProps
=
(
dIndex
)
=>
({
filterDropdown
:
({
setSelectedKeys
,
selectedKeys
,
confirm
,
clearFilters
})
=>
(
...
...
@@ -189,8 +193,18 @@ const StudioConnector = (props:any) => {
},];
return
columns
;
};
const
showSessions
=
()
=>
{
const
createSessions
=
()
=>
{
handleCreateSessionModalVisible
(
true
);
};
const
showSessions
=
()
=>
{
setModalVisit
(
true
);
setType
(
1
);
const
res
=
getData
(
"api/studio/listSession"
);
res
.
then
((
result
)
=>
{
setSessionData
(
result
.
datas
);
});
};
return
(
...
...
@@ -207,7 +221,7 @@ const StudioConnector = (props:any) => {
<
Button
type=
"text"
icon=
{
<
PlusOutlined
/>
}
onClick=
{
show
Sessions
}
onClick=
{
create
Sessions
}
/>
</
Tooltip
>
<
Tooltip
title=
"刷新连接器"
>
...
...
@@ -253,13 +267,30 @@ const StudioConnector = (props:any) => {
>
<
ProDescriptions
.
Item
span=
{
2
}
>
{
sessionData
?
(<
Table
dataSource=
{
sessionData
}
columns=
{
getSessionsColumns
}
size=
"small"
(<
Table
dataSource=
{
sessionData
}
columns=
{
getSessionsColumns
()
}
size=
"small"
/>):(<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>)
}
</
ProDescriptions
.
Item
>
</
ProDescriptions
>
)
}
</
ModalForm
>
<
SessionForm
onSubmit=
{
async
(
value
)
=>
{
const
success
=
await
handleAddOrUpdate
(
"api/studio/createSession"
,
value
);
if
(
success
)
{
handleCreateSessionModalVisible
(
false
);
/*if (actionRef.current) {
actionRef.current.reload();
}*/
}
}
}
onCancel=
{
()
=>
{
handleCreateSessionModalVisible
(
false
);
// setFormValues(
{});
}
}
updateModalVisible=
{
createSessionModalVisible
}
values=
{
{}
}
/>
</>
);
};
...
...
dlink-web/src/pages/FlinkSqlStudio/model.ts
View file @
4b6db6d8
import
{
Effect
,
Reducer
}
from
"umi"
;
import
{
executeSql
}
from
"./service"
;
import
{
addOrUpdateData
,
handleAddOrUpdate
,
handleRemove
,
handleRemoveById
,
postAll
,
queryData
getData
,
handleAddOrUpdate
}
from
"@/components/Common/crud"
;
import
{
Form
}
from
"antd"
;
import
{
executeDDL
}
from
"@/pages/FlinkSqlStudio/service"
;
export
type
ClusterType
=
{
id
:
number
,
...
...
@@ -76,21 +72,26 @@ export type RightClickMenu = {
export
type
ConnectorType
=
{
tablename
:
string
;
}
export
type
SessionClusterType
=
{
session
:
string
;
clusterId
:
number
;
clusterName
:
string
;
export
type
SessionType
=
{
session
?:
string
;
type
?:
string
;
useRemote
?:
string
;
clusterId
?:
number
;
clusterName
?:
string
;
address
?:
string
;
createUser
?:
string
;
createTime
?:
string
;
connectors
:
ConnectorType
[];
}
export
type
StateType
=
{
cluster
?:
ClusterType
[];
currentSessionCluster
:
Session
ClusterType
[]
;
currentSessionCluster
:
Session
Type
;
current
:
TabsItemType
;
sql
?:
string
;
monaco
?:
any
;
currentPath
?:
string
[];
tabs
:
TabsType
;
session
:
string
[];
session
:
SessionType
[];
result
:{};
rightClickMenu
?:
boolean
;
refs
:{
...
...
@@ -120,7 +121,7 @@ export type ModelType = {
const
getClusters
=
async
()
=>
{
try
{
const
{
datas
}
=
await
postAll
(
'api/cluster/listEnabledAll'
);
const
{
datas
}
=
await
getData
(
'api/cluster/listEnabledAll'
);
return
datas
;
}
catch
(
error
)
{
console
.
error
(
'获取Flink集群失败'
);
...
...
@@ -134,9 +135,6 @@ const Model: ModelType = {
state
:
{
cluster
:
getClusters
(),
currentSessionCluster
:
{
session
:
''
,
clusterId
:
0
,
clusterName
:
'本地环境'
,
connectors
:
[],
},
current
:
{
...
...
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