Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
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
wangpeng
dinky
Commits
e32555e0
Unverified
Commit
e32555e0
authored
Nov 28, 2023
by
gaoyan
Committed by
GitHub
Nov 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimized clusterinstance (#2578)
* Optimize the process * Optimized the logic of the cluster list * Optimized the logic of the cluster list
parent
abbd3f80
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
63 deletions
+50
-63
ClusterInstanceController.java
.../java/org/dinky/controller/ClusterInstanceController.java
+4
-2
ClearJobHistoryHandler.java
...in/java/org/dinky/job/handler/ClearJobHistoryHandler.java
+5
-0
ClusterInstanceService.java
...c/main/java/org/dinky/service/ClusterInstanceService.java
+1
-1
ClusterInstanceServiceImpl.java
...va/org/dinky/service/impl/ClusterInstanceServiceImpl.java
+7
-6
index.tsx
...Center/Cluster/Instance/components/InstanceList/index.tsx
+33
-54
No files found.
dinky-admin/src/main/java/org/dinky/controller/ClusterInstanceController.java
View file @
e32555e0
...
@@ -154,8 +154,10 @@ public class ClusterInstanceController {
...
@@ -154,8 +154,10 @@ public class ClusterInstanceController {
paramType
=
"query"
,
paramType
=
"query"
,
required
=
true
,
required
=
true
,
dataTypeClass
=
JsonNode
.
class
)
dataTypeClass
=
JsonNode
.
class
)
public
Result
<
List
<
ClusterInstance
>>
listClusterInstance
(
@RequestParam
(
"keyword"
)
String
searchKeyWord
)
{
public
Result
<
List
<
ClusterInstance
>>
listClusterInstance
(
return
Result
.
succeed
(
clusterInstanceService
.
selectListByKeyWord
(
searchKeyWord
));
@RequestParam
(
defaultValue
=
""
)
String
searchKeyWord
,
@RequestParam
(
defaultValue
=
"false"
)
boolean
isAutoCreate
)
{
return
Result
.
succeed
(
clusterInstanceService
.
selectListByKeyWord
(
searchKeyWord
,
isAutoCreate
));
}
}
/**
/**
...
...
dinky-admin/src/main/java/org/dinky/job/handler/ClearJobHistoryHandler.java
View file @
e32555e0
...
@@ -21,6 +21,7 @@ package org.dinky.job.handler;
...
@@ -21,6 +21,7 @@ package org.dinky.job.handler;
import
org.dinky.data.model.job.History
;
import
org.dinky.data.model.job.History
;
import
org.dinky.data.model.job.JobInstance
;
import
org.dinky.data.model.job.JobInstance
;
import
org.dinky.service.ClusterInstanceService
;
import
org.dinky.service.HistoryService
;
import
org.dinky.service.HistoryService
;
import
org.dinky.service.JobHistoryService
;
import
org.dinky.service.JobHistoryService
;
import
org.dinky.service.JobInstanceService
;
import
org.dinky.service.JobInstanceService
;
...
@@ -38,6 +39,7 @@ public class ClearJobHistoryHandler {
...
@@ -38,6 +39,7 @@ public class ClearJobHistoryHandler {
private
JobInstanceService
jobInstanceService
;
private
JobInstanceService
jobInstanceService
;
private
JobHistoryService
jobHistoryService
;
private
JobHistoryService
jobHistoryService
;
private
HistoryService
historyService
;
private
HistoryService
historyService
;
private
ClusterInstanceService
clusterService
;
/**
/**
* Clears job history records based on the specified criteria.
* Clears job history records based on the specified criteria.
...
@@ -66,6 +68,9 @@ public class ClearJobHistoryHandler {
...
@@ -66,6 +68,9 @@ public class ClearJobHistoryHandler {
List
<
JobInstance
>
deleteList
=
jobInstanceService
.
list
(
deleteWrapper
);
List
<
JobInstance
>
deleteList
=
jobInstanceService
.
list
(
deleteWrapper
);
List
<
Integer
>
historyDeleteIds
=
List
<
Integer
>
historyDeleteIds
=
deleteList
.
stream
().
map
(
JobInstance:
:
getHistoryId
).
collect
(
Collectors
.
toList
());
deleteList
.
stream
().
map
(
JobInstance:
:
getHistoryId
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
clusterDeleteIds
=
deleteList
.
stream
().
map
(
JobInstance:
:
getClusterId
).
collect
(
Collectors
.
toList
());
clusterService
.
removeBatchByIds
(
clusterDeleteIds
);
jobHistoryService
.
removeBatchByIds
(
historyDeleteIds
);
jobHistoryService
.
removeBatchByIds
(
historyDeleteIds
);
jobInstanceService
.
remove
(
deleteWrapper
);
jobInstanceService
.
remove
(
deleteWrapper
);
}
}
...
...
dinky-admin/src/main/java/org/dinky/service/ClusterInstanceService.java
View file @
e32555e0
...
@@ -145,5 +145,5 @@ public interface ClusterInstanceService extends ISuperService<ClusterInstance> {
...
@@ -145,5 +145,5 @@ public interface ClusterInstanceService extends ISuperService<ClusterInstance> {
*/
*/
ClusterInstance
deploySessionCluster
(
Integer
id
);
ClusterInstance
deploySessionCluster
(
Integer
id
);
List
<
ClusterInstance
>
selectListByKeyWord
(
String
searchKeyWord
);
List
<
ClusterInstance
>
selectListByKeyWord
(
String
searchKeyWord
,
boolean
isAutoCreate
);
}
}
dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java
View file @
e32555e0
...
@@ -213,14 +213,15 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance
...
@@ -213,14 +213,15 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance
* @return
* @return
*/
*/
@Override
@Override
public
List
<
ClusterInstance
>
selectListByKeyWord
(
String
searchKeyWord
)
{
public
List
<
ClusterInstance
>
selectListByKeyWord
(
String
searchKeyWord
,
boolean
isAutoCreate
)
{
return
getBaseMapper
()
return
getBaseMapper
()
.
selectList
(
new
LambdaQueryWrapper
<
ClusterInstance
>()
.
selectList
(
new
LambdaQueryWrapper
<
ClusterInstance
>()
.
like
(
ClusterInstance:
:
getName
,
searchKeyWord
)
.
and
(
true
,
i
->
i
.
eq
(
ClusterInstance:
:
getAutoRegisters
,
isAutoCreate
))
.
or
()
.
and
(
true
,
i
->
i
.
like
(
ClusterInstance:
:
getName
,
searchKeyWord
)
.
like
(
ClusterInstance:
:
getAlias
,
searchKeyWord
)
.
or
()
.
or
()
.
like
(
ClusterInstance:
:
getAlias
,
searchKeyWord
)
.
like
(
ClusterInstance:
:
getNote
,
searchKeyWord
));
.
or
()
.
like
(
ClusterInstance:
:
getNote
,
searchKeyWord
)));
}
}
private
boolean
checkHealth
(
ClusterInstance
clusterInstance
)
{
private
boolean
checkHealth
(
ClusterInstance
clusterInstance
)
{
...
...
dinky-web/src/pages/RegCenter/Cluster/Instance/components/InstanceList/index.tsx
View file @
e32555e0
...
@@ -22,14 +22,15 @@ import { EditBtn } from '@/components/CallBackButton/EditBtn';
...
@@ -22,14 +22,15 @@ import { EditBtn } from '@/components/CallBackButton/EditBtn';
import
{
EnableSwitchBtn
}
from
'@/components/CallBackButton/EnableSwitchBtn'
;
import
{
EnableSwitchBtn
}
from
'@/components/CallBackButton/EnableSwitchBtn'
;
import
{
PopconfirmDeleteBtn
}
from
'@/components/CallBackButton/PopconfirmDeleteBtn'
;
import
{
PopconfirmDeleteBtn
}
from
'@/components/CallBackButton/PopconfirmDeleteBtn'
;
import
{
Authorized
,
HasAuthority
}
from
'@/hooks/useAccess'
;
import
{
Authorized
,
HasAuthority
}
from
'@/hooks/useAccess'
;
import
useHookRequest
from
'@/hooks/useHookRequest'
;
import
{
CLUSTER_INSTANCE_TYPE
}
from
'@/pages/RegCenter/Cluster/Instance/components/contants'
;
import
{
CLUSTER_INSTANCE_TYPE
}
from
'@/pages/RegCenter/Cluster/Instance/components/contants'
;
import
{
renderWebUiRedirect
}
from
'@/pages/RegCenter/Cluster/Instance/components/function'
;
import
{
renderWebUiRedirect
}
from
'@/pages/RegCenter/Cluster/Instance/components/function'
;
import
InstanceModal
from
'@/pages/RegCenter/Cluster/Instance/components/InstanceModal'
;
import
InstanceModal
from
'@/pages/RegCenter/Cluster/Instance/components/InstanceModal'
;
import
{
getData
}
from
'@/services/api'
;
import
{
import
{
handleAddOrUpdate
,
handleAddOrUpdate
,
handleOption
,
handleOption
,
handleRemoveById
,
handleRemoveById
,
queryDataByParams
,
updateDataByParam
updateDataByParam
}
from
'@/services/BusinessCrud'
;
}
from
'@/services/BusinessCrud'
;
import
{
PROTABLE_OPTIONS_PUBLIC
,
PRO_LIST_CARD_OPTIONS
}
from
'@/services/constants'
;
import
{
PROTABLE_OPTIONS_PUBLIC
,
PRO_LIST_CARD_OPTIONS
}
from
'@/services/constants'
;
...
@@ -38,12 +39,7 @@ import { Cluster } from '@/types/RegCenter/data.d';
...
@@ -38,12 +39,7 @@ import { Cluster } from '@/types/RegCenter/data.d';
import
{
InitClusterInstanceState
}
from
'@/types/RegCenter/init.d'
;
import
{
InitClusterInstanceState
}
from
'@/types/RegCenter/init.d'
;
import
{
ClusterInstanceState
}
from
'@/types/RegCenter/state.d'
;
import
{
ClusterInstanceState
}
from
'@/types/RegCenter/state.d'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
import
{
CheckCircleOutlined
,
ExclamationCircleOutlined
,
HeartTwoTone
}
from
'@ant-design/icons'
;
CheckCircleOutlined
,
ClearOutlined
,
ExclamationCircleOutlined
,
HeartTwoTone
}
from
'@ant-design/icons'
;
import
{
ActionType
,
ProList
}
from
'@ant-design/pro-components'
;
import
{
ActionType
,
ProList
}
from
'@ant-design/pro-components'
;
import
{
import
{
Badge
,
Badge
,
...
@@ -54,14 +50,15 @@ import {
...
@@ -54,14 +50,15 @@ import {
Divider
,
Divider
,
Input
,
Input
,
List
,
List
,
Popconfirm
,
Row
,
Row
,
Space
,
Space
,
Switch
,
Tag
,
Tag
,
Tooltip
,
Tooltip
,
Typography
Typography
}
from
'antd'
;
}
from
'antd'
;
import
{
useEffect
,
useRef
,
useState
}
from
'react'
;
import
{
useRef
,
useState
}
from
'react'
;
const
{
Text
,
Paragraph
,
Link
}
=
Typography
;
const
{
Text
,
Paragraph
,
Link
}
=
Typography
;
export
default
()
=>
{
export
default
()
=>
{
...
@@ -70,16 +67,18 @@ export default () => {
...
@@ -70,16 +67,18 @@ export default () => {
*/
*/
const
[
clusterInstanceStatus
,
setClusterInstanceStatus
]
=
const
[
clusterInstanceStatus
,
setClusterInstanceStatus
]
=
useState
<
ClusterInstanceState
>
(
InitClusterInstanceState
);
useState
<
ClusterInstanceState
>
(
InitClusterInstanceState
);
const
[
isAutoCreate
,
setIsAutoCreate
]
=
useState
<
boolean
>
(
false
);
const
[
searchKeyWord
,
setSearchKeyword
]
=
useState
<
string
>
(
''
);
const
actionRef
=
useRef
<
ActionType
>
();
const
actionRef
=
useRef
<
ActionType
>
();
const
queryClusterInstanceList
=
async
(
keyword
=
''
)
=>
{
const
{
data
,
loading
}
=
useHookRequest
(
getData
,
{
queryDataByParams
(
API_CONSTANTS
.
CLUSTER_INSTANCE_LIST
,
{
keyword
}).
then
((
res
)
=>
{
refreshDeps
:
[
searchKeyWord
,
isAutoCreate
],
setClusterInstanceStatus
((
prevState
)
=>
({
defaultParams
:
[
...
prevState
,
API_CONSTANTS
.
CLUSTER_INSTANCE_LIST
,
instanceList
:
res
as
Cluster
.
Instance
[]
{
searchKeyWord
:
searchKeyWord
,
isAutoCreate
:
isAutoCreate
}
}));
]
});
});
};
/**
/**
* execute and callback function
* execute and callback function
* @param {() => void} callback
* @param {() => void} callback
...
@@ -88,15 +87,10 @@ export default () => {
...
@@ -88,15 +87,10 @@ export default () => {
const
executeAndCallback
=
async
(
callback
:
()
=>
void
)
=>
{
const
executeAndCallback
=
async
(
callback
:
()
=>
void
)
=>
{
setClusterInstanceStatus
((
prevState
)
=>
({
...
prevState
,
loading
:
true
}));
setClusterInstanceStatus
((
prevState
)
=>
({
...
prevState
,
loading
:
true
}));
await
callback
();
await
callback
();
queryClusterInstanceList
();
setClusterInstanceStatus
((
prevState
)
=>
({
...
prevState
,
loading
:
false
}));
setClusterInstanceStatus
((
prevState
)
=>
({
...
prevState
,
loading
:
false
}));
actionRef
.
current
?.
reload
?.();
actionRef
.
current
?.
reload
?.();
};
};
useEffect
(()
=>
{
queryClusterInstanceList
();
},
[]);
/**
/**
* cancel
* cancel
*/
*/
...
@@ -161,15 +155,6 @@ export default () => {
...
@@ -161,15 +155,6 @@ export default () => {
);
);
};
};
/**
* recycle instance
*/
const
handleRecycle
=
async
()
=>
{
await
executeAndCallback
(
async
()
=>
handleRemoveById
(
API_CONSTANTS
.
CLUSTER_INSTANCE_RECYCLE
,
0
)
);
};
/**
/**
* tool bar render
* tool bar render
*/
*/
...
@@ -262,12 +247,10 @@ export default () => {
...
@@ -262,12 +247,10 @@ export default () => {
* tool bar render
* tool bar render
*/
*/
const
toolBarRender
=
()
=>
[
const
toolBarRender
=
()
=>
[
<
Input
.
Search
<
Switch
loading=
{
clusterInstanceStatus
.
loading
}
checkedChildren=
{
l
(
'rc.ci.ar'
)
}
key=
{
`_search`
}
unCheckedChildren=
{
l
(
'rc.ci.mr'
)
}
allowClear
onChange=
{
(
v
)
=>
setIsAutoCreate
(
v
)
}
placeholder=
{
l
(
'rc.ci.search'
)
}
onSearch=
{
(
value
)
=>
queryClusterInstanceList
(
value
)
}
/>,
/>,
<
Authorized
key=
{
`_add_auth`
}
path=
'/registration/cluster/instance/add'
>
<
Authorized
key=
{
`_add_auth`
}
path=
'/registration/cluster/instance/add'
>
<
CreateBtn
<
CreateBtn
...
@@ -285,18 +268,6 @@ export default () => {
...
@@ -285,18 +268,6 @@ export default () => {
{
l
(
'button.heartbeat'
)
}
{
l
(
'button.heartbeat'
)
}
</
Button
>
</
Button
>
</
Authorized
>,
</
Authorized
>,
<
Authorized
key=
{
`_add_recycle`
}
path=
'/registration/cluster/instance/recovery'
>
<
Popconfirm
key=
{
`_add_recycle_pop`
}
title=
{
l
(
'rc.ci.recycle'
)
}
description=
{
l
(
'rc.ci.recycleConfirm'
)
}
onConfirm=
{
handleRecycle
}
>
<
Button
key=
{
'recycle_btn'
}
type=
{
'primary'
}
icon=
{
<
ClearOutlined
/>
}
>
{
l
(
'button.recycle'
)
}
</
Button
>
</
Popconfirm
>
</
Authorized
>
];
];
const
renderListItem
=
(
item
:
Cluster
.
Instance
)
=>
{
const
renderListItem
=
(
item
:
Cluster
.
Instance
)
=>
{
...
@@ -304,12 +275,12 @@ export default () => {
...
@@ -304,12 +275,12 @@ export default () => {
<
List
.
Item
className=
{
'card-list-item-wrapper'
}
key=
{
item
.
id
}
>
<
List
.
Item
className=
{
'card-list-item-wrapper'
}
key=
{
item
.
id
}
>
<
Badge
.
Ribbon
<
Badge
.
Ribbon
className=
{
'card-list-item-wrapper'
}
className=
{
'card-list-item-wrapper'
}
color=
{
item
.
autoRegisters
?
'
green'
:
'yellow
'
}
color=
{
item
.
autoRegisters
?
'
#95de64'
:
'#ffec3d
'
}
text=
{
text=
{
item
.
autoRegisters
?
(
item
.
autoRegisters
?
(
l
(
'rc.ci.ar'
)
l
(
'rc.ci.ar'
)
)
:
(
)
:
(
<
span
style=
{
{
color
:
'
crimson
'
}
}
>
{
l
(
'rc.ci.mr'
)
}
</
span
>
<
span
style=
{
{
color
:
'
#69b1ff
'
}
}
>
{
l
(
'rc.ci.mr'
)
}
</
span
>
)
)
}
}
>
>
...
@@ -334,15 +305,23 @@ export default () => {
...
@@ -334,15 +305,23 @@ export default () => {
return
(
return
(
<>
<>
<
ProList
<
Cluster
.
Instance
>
<
ProList
<
Cluster
.
Instance
>
headerTitle=
{
l
(
'rc.ci.management'
)
}
headerTitle=
{
<
Input
.
Search
loading=
{
clusterInstanceStatus
.
loading
}
key=
{
`_search`
}
allowClear
placeholder=
{
l
(
'rc.ci.search'
)
}
onSearch=
{
(
v
)
=>
setSearchKeyword
(
v
)
}
/>
}
toolBarRender=
{
toolBarRender
}
toolBarRender=
{
toolBarRender
}
{
...
PROTABLE_OPTIONS_PUBLIC
}
{
...
PROTABLE_OPTIONS_PUBLIC
}
{
...(
PRO_LIST_CARD_OPTIONS
as
any
)
}
{
...(
PRO_LIST_CARD_OPTIONS
as
any
)
}
grid=
{
{
gutter
:
24
,
column
:
4
}
}
grid=
{
{
gutter
:
24
,
column
:
4
}
}
pagination=
{
{
size
:
'small'
,
defaultPageSize
:
12
,
hideOnSinglePage
:
true
}
}
pagination=
{
{
size
:
'small'
,
defaultPageSize
:
12
,
hideOnSinglePage
:
true
}
}
actionRef=
{
actionRef
}
actionRef=
{
actionRef
}
dataSource=
{
clusterInstanceStatus
.
instanceList
}
dataSource=
{
data
}
loading=
{
clusterInstanceStatus
.
loading
}
loading=
{
loading
}
itemLayout=
{
'vertical'
}
itemLayout=
{
'vertical'
}
renderItem=
{
renderListItem
}
renderItem=
{
renderListItem
}
/
>
/
>
...
...
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