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
106d1b53
Unverified
Commit
106d1b53
authored
Dec 16, 2023
by
gaoyan
Committed by
GitHub
Dec 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
footer use sse get jvm (#2661)
* footer use sse get jvm * footer use sse get jvm
parent
f3f4d225
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
30 additions
and
27 deletions
+30
-27
MonitorController.java
...src/main/java/org/dinky/controller/MonitorController.java
+3
-3
SseController.java
...min/src/main/java/org/dinky/controller/SseController.java
+1
-1
MonitorService.java
...admin/src/main/java/org/dinky/service/MonitorService.java
+1
-2
MonitorServiceImpl.java
.../main/java/org/dinky/service/impl/MonitorServiceImpl.java
+8
-5
FlinkConfigOptionsUtils.java
...rc/main/java/org/dinky/utils/FlinkConfigOptionsUtils.java
+3
-0
index.tsx
...web/src/pages/DataStudio/BottomContainer/Result/index.tsx
+1
-1
index.tsx
dinky-web/src/pages/DataStudio/FooterContainer/index.tsx
+8
-11
index.tsx
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
+3
-2
index.tsx
...-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
+1
-1
model.ts
dinky-web/src/pages/DataStudio/model.ts
+1
-1
No files found.
dinky-admin/src/main/java/org/dinky/controller/MonitorController.java
View file @
106d1b53
...
@@ -24,7 +24,6 @@ import org.dinky.data.annotations.Log;
...
@@ -24,7 +24,6 @@ import org.dinky.data.annotations.Log;
import
org.dinky.data.dto.MetricsLayoutDTO
;
import
org.dinky.data.dto.MetricsLayoutDTO
;
import
org.dinky.data.enums.BusinessType
;
import
org.dinky.data.enums.BusinessType
;
import
org.dinky.data.enums.MetricsType
;
import
org.dinky.data.enums.MetricsType
;
import
org.dinky.data.metrics.Jvm
;
import
org.dinky.data.model.Metrics
;
import
org.dinky.data.model.Metrics
;
import
org.dinky.data.result.Result
;
import
org.dinky.data.result.Result
;
import
org.dinky.data.vo.MetricsVO
;
import
org.dinky.data.vo.MetricsVO
;
...
@@ -41,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -41,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.servlet.mvc.method.annotation.SseEmitter
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
...
@@ -124,7 +124,7 @@ public class MonitorController {
...
@@ -124,7 +124,7 @@ public class MonitorController {
@GetMapping
(
"/getJvmInfo"
)
@GetMapping
(
"/getJvmInfo"
)
@ApiOperation
(
"Get Jvm Data Display"
)
@ApiOperation
(
"Get Jvm Data Display"
)
public
Result
<
Jvm
>
getJvmInfo
()
{
public
SseEmitter
getJvmInfo
()
{
return
Result
.
succeed
(
Jvm
.
of
()
);
return
monitorService
.
sendJvmInfo
(
);
}
}
}
}
dinky-admin/src/main/java/org/dinky/controller/SseController.java
View file @
106d1b53
...
@@ -56,7 +56,7 @@ public class SseController {
...
@@ -56,7 +56,7 @@ public class SseController {
@GetMapping
(
value
=
"/connect"
,
produces
=
MediaType
.
TEXT_EVENT_STREAM_VALUE
)
@GetMapping
(
value
=
"/connect"
,
produces
=
MediaType
.
TEXT_EVENT_STREAM_VALUE
)
@ApiOperation
(
"Connect Sse"
)
@ApiOperation
(
"Connect Sse"
)
@ApiImplicitParam
(
name
=
"sessionKey"
,
value
=
"Session unique key"
,
required
=
true
,
dataType
=
"String"
)
@ApiImplicitParam
(
name
=
"sessionKey"
,
value
=
"Session unique key"
,
required
=
true
,
dataType
=
"String"
)
public
SseEmitter
getJvmInfo
(
String
sessionKey
)
{
public
SseEmitter
connect
(
String
sessionKey
)
{
return
SseSessionContextHolder
.
connectSession
(
sessionKey
);
return
SseSessionContextHolder
.
connectSession
(
sessionKey
);
}
}
}
}
dinky-admin/src/main/java/org/dinky/service/MonitorService.java
View file @
106d1b53
...
@@ -46,10 +46,9 @@ public interface MonitorService extends IService<Metrics> {
...
@@ -46,10 +46,9 @@ public interface MonitorService extends IService<Metrics> {
/**
/**
* Send the JVM information to the specified SSE emitter.
* Send the JVM information to the specified SSE emitter.
*
*
* @param sseEmitter The SSE emitter to send the JVM information to.
* @return {@link SseEmitter}
* @return {@link SseEmitter}
*/
*/
SseEmitter
sendJvmInfo
(
SseEmitter
sseEmitter
);
SseEmitter
sendJvmInfo
();
/**
/**
* Save the Flink metric layout.
* Save the Flink metric layout.
...
...
dinky-admin/src/main/java/org/dinky/service/impl/MonitorServiceImpl.java
View file @
106d1b53
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
org
.
dinky
.
service
.
impl
;
package
org
.
dinky
.
service
.
impl
;
import
org.dinky.context.SseSessionContextHolder
;
import
org.dinky.data.MetricsLayoutVo
;
import
org.dinky.data.MetricsLayoutVo
;
import
org.dinky.data.constant.PaimonTableConstant
;
import
org.dinky.data.constant.PaimonTableConstant
;
import
org.dinky.data.dto.MetricsLayoutDTO
;
import
org.dinky.data.dto.MetricsLayoutDTO
;
...
@@ -42,6 +43,7 @@ import java.util.ArrayList;
...
@@ -42,6 +43,7 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.Executor
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -58,7 +60,6 @@ import cn.hutool.core.collection.CollUtil;
...
@@ -58,7 +60,6 @@ import cn.hutool.core.collection.CollUtil;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.thread.ThreadUtil
;
import
cn.hutool.core.thread.ThreadUtil
;
import
cn.hutool.json.JSONUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
@Service
@Service
...
@@ -98,16 +99,18 @@ public class MonitorServiceImpl extends ServiceImpl<MetricsMapper, Metrics> impl
...
@@ -98,16 +99,18 @@ public class MonitorServiceImpl extends ServiceImpl<MetricsMapper, Metrics> impl
}
}
@Override
@Override
public
SseEmitter
sendJvmInfo
(
SseEmitter
sseEmitter
)
{
public
SseEmitter
sendJvmInfo
()
{
String
sessionKey
=
UUID
.
randomUUID
().
toString
();
SseEmitter
sseEmitter
=
SseSessionContextHolder
.
connectSession
(
sessionKey
);
SseSessionContextHolder
.
subscribeTopic
(
sessionKey
,
CollUtil
.
newArrayList
(
sessionKey
));
scheduleRefreshMonitorDataExecutor
.
execute
(()
->
{
scheduleRefreshMonitorDataExecutor
.
execute
(()
->
{
try
{
try
{
while
(
true
)
{
while
(
true
)
{
sseEmitter
.
send
(
JSONUtil
.
toJsonStr
(
Jvm
.
of
()
));
SseSessionContextHolder
.
sendTopic
(
sessionKey
,
Jvm
.
of
(
));
ThreadUtil
.
sleep
(
10000
);
ThreadUtil
.
sleep
(
10000
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"send jvm info failed, complete sse emiter :"
+
e
.
getMessage
());
sseEmitter
.
complete
();
}
}
});
});
return
sseEmitter
;
return
sseEmitter
;
...
...
dinky-admin/src/main/java/org/dinky/utils/FlinkConfigOptionsUtils.java
View file @
106d1b53
...
@@ -65,6 +65,9 @@ public class FlinkConfigOptionsUtils {
...
@@ -65,6 +65,9 @@ public class FlinkConfigOptionsUtils {
FlinkConfigOption
config
=
new
FlinkConfigOption
();
FlinkConfigOption
config
=
new
FlinkConfigOption
();
Object
fieldValue
=
ReflectUtil
.
getStaticFieldValue
(
field
);
Object
fieldValue
=
ReflectUtil
.
getStaticFieldValue
(
field
);
String
key
=
ReflectUtil
.
invoke
(
fieldValue
,
"key"
);
String
key
=
ReflectUtil
.
invoke
(
fieldValue
,
"key"
);
if
(!
key
.
contains
(
"."
))
{
continue
;
}
Object
defaultValue
=
ReflectUtil
.
invoke
(
fieldValue
,
"defaultValue"
);
Object
defaultValue
=
ReflectUtil
.
invoke
(
fieldValue
,
"defaultValue"
);
config
.
setKey
(
key
);
config
.
setKey
(
key
);
if
(
ObjectUtil
.
isBasicType
(
defaultValue
))
{
if
(
ObjectUtil
.
isBasicType
(
defaultValue
))
{
...
...
dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx
View file @
106d1b53
...
@@ -26,6 +26,7 @@ import {
...
@@ -26,6 +26,7 @@ import {
import
{
isSql
}
from
'@/pages/DataStudio/HeaderContainer/service'
;
import
{
isSql
}
from
'@/pages/DataStudio/HeaderContainer/service'
;
import
{
StateType
}
from
'@/pages/DataStudio/model'
;
import
{
StateType
}
from
'@/pages/DataStudio/model'
;
import
{
handleGetOption
,
handleGetOptionWithoutMsg
}
from
'@/services/BusinessCrud'
;
import
{
handleGetOption
,
handleGetOptionWithoutMsg
}
from
'@/services/BusinessCrud'
;
import
{
DIALECT
}
from
'@/services/constants'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
transformTableDataToCsv
}
from
'@/utils/function'
;
import
{
transformTableDataToCsv
}
from
'@/utils/function'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
...
@@ -37,7 +38,6 @@ import { FilterConfirmProps } from 'antd/es/table/interface';
...
@@ -37,7 +38,6 @@ import { FilterConfirmProps } from 'antd/es/table/interface';
import
{
DataIndex
}
from
'rc-table/es/interface'
;
import
{
DataIndex
}
from
'rc-table/es/interface'
;
import
{
useEffect
,
useRef
,
useState
}
from
'react'
;
import
{
useEffect
,
useRef
,
useState
}
from
'react'
;
import
{
connect
}
from
'umi'
;
import
{
connect
}
from
'umi'
;
import
{
DIALECT
}
from
"@/services/constants"
;
type
Data
=
{
type
Data
=
{
[
c
:
string
]:
any
;
[
c
:
string
]:
any
;
...
...
dinky-web/src/pages/DataStudio/FooterContainer/index.tsx
View file @
106d1b53
...
@@ -21,8 +21,7 @@ import useThemeValue from '@/hooks/useThemeValue';
...
@@ -21,8 +21,7 @@ import useThemeValue from '@/hooks/useThemeValue';
import
JobRunningModal
from
'@/pages/DataStudio/FooterContainer/JobRunningModal'
;
import
JobRunningModal
from
'@/pages/DataStudio/FooterContainer/JobRunningModal'
;
import
{
getCurrentTab
}
from
'@/pages/DataStudio/function'
;
import
{
getCurrentTab
}
from
'@/pages/DataStudio/function'
;
import
{
StateType
,
TabsPageType
,
VIEW
}
from
'@/pages/DataStudio/model'
;
import
{
StateType
,
TabsPageType
,
VIEW
}
from
'@/pages/DataStudio/model'
;
import
{
getData
}
from
'@/services/api'
;
import
{
getSseData
}
from
'@/services/api'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
connect
}
from
'@@/exports'
;
import
{
connect
}
from
'@@/exports'
;
import
{
Button
,
GlobalToken
,
Space
}
from
'antd'
;
import
{
Button
,
GlobalToken
,
Space
}
from
'antd'
;
...
@@ -60,20 +59,18 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => {
...
@@ -60,20 +59,18 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => {
const
currentTab
=
getCurrentTab
(
tabs
.
panes
??
[],
tabs
.
activeKey
);
const
currentTab
=
getCurrentTab
(
tabs
.
panes
??
[],
tabs
.
activeKey
);
useEffect
(()
=>
{
useEffect
(()
=>
{
const
t
=
setInterval
(()
=>
{
const
eventSource
=
getSseData
(
'/api/monitor/getJvmInfo'
);
getData
(
API_CONSTANTS
.
MONITOR_GET_JVM_INFO
)
eventSource
.
onmessage
=
(
event
)
=>
{
.
then
((
res
)
=>
{
const
data
=
JSON
.
parse
(
event
.
data
).
data
;
setMemDetailInfo
(
setMemDetailInfo
(
Number
(
res
.
data
[
'heapUsed'
]
/
1024
/
1024
).
toFixed
(
0
)
+
Number
(
data
[
'heapUsed'
]
/
1024
/
1024
).
toFixed
(
0
)
+
'/'
+
'/'
+
Number
(
res
.
data
[
'max'
]
/
1024
/
1024
).
toFixed
(
0
)
+
Number
(
data
[
'max'
]
/
1024
/
1024
).
toFixed
(
0
)
+
'M'
'M'
);
);
})
};
.
catch
((
e
)
=>
{});
},
3000
);
return
()
=>
{
return
()
=>
{
clearTimeout
(
t
);
eventSource
.
close
(
);
};
};
},
[]);
},
[]);
...
...
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
View file @
106d1b53
...
@@ -33,7 +33,8 @@ import {
...
@@ -33,7 +33,8 @@ import {
changeTaskLife
,
changeTaskLife
,
debugTask
,
debugTask
,
executeSql
,
executeSql
,
getJobPlan
,
isSql
getJobPlan
,
isSql
}
from
'@/pages/DataStudio/HeaderContainer/service'
;
}
from
'@/pages/DataStudio/HeaderContainer/service'
;
import
{
DataStudioTabsItemType
,
StateType
,
TabsPageType
,
VIEW
}
from
'@/pages/DataStudio/model'
;
import
{
DataStudioTabsItemType
,
StateType
,
TabsPageType
,
VIEW
}
from
'@/pages/DataStudio/model'
;
import
{
JOB_LIFE_CYCLE
,
JOB_STATUS
}
from
'@/pages/DevOps/constants'
;
import
{
JOB_LIFE_CYCLE
,
JOB_STATUS
}
from
'@/pages/DevOps/constants'
;
...
@@ -178,7 +179,7 @@ const HeaderContainer = (props: any) => {
...
@@ -178,7 +179,7 @@ const HeaderContainer = (props: any) => {
await
SuccessMessageAsync
(
l
(
'pages.datastudio.editor.exec.success'
));
await
SuccessMessageAsync
(
l
(
'pages.datastudio.editor.exec.success'
));
currentData
.
status
=
JOB_STATUS
.
RUNNING
;
currentData
.
status
=
JOB_STATUS
.
RUNNING
;
// Common sql task is synchronized, so it needs to automatically update the status to finished.
// Common sql task is synchronized, so it needs to automatically update the status to finished.
if
(
isSql
(
currentData
.
dialect
))
{
if
(
isSql
(
currentData
.
dialect
))
{
currentData
.
status
=
JOB_STATUS
.
FINISHED
;
currentData
.
status
=
JOB_STATUS
.
FINISHED
;
}
}
if
(
currentTab
)
currentTab
.
console
.
result
=
res
.
data
.
result
;
if
(
currentTab
)
currentTab
.
console
.
result
=
res
.
data
.
result
;
...
...
dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
View file @
106d1b53
...
@@ -156,7 +156,7 @@ const Project: React.FC = (props: connect) => {
...
@@ -156,7 +156,7 @@ const Project: React.FC = (props: connect) => {
icon
:
type
,
icon
:
type
,
id
:
parentId
+
name
,
id
:
parentId
+
name
,
treeKey
:
key
,
treeKey
:
key
,
breadcrumbLabel
:
path
.
slice
(
0
,
path
.
length
-
1
).
join
(
'/'
),
breadcrumbLabel
:
path
.
slice
(
0
,
path
.
length
-
1
).
join
(
'/'
),
label
:
name
,
label
:
name
,
params
:
{
params
:
{
taskId
:
taskId
taskId
:
taskId
...
...
dinky-web/src/pages/DataStudio/model.ts
View file @
106d1b53
...
@@ -724,7 +724,7 @@ const Model: ModelType = {
...
@@ -724,7 +724,7 @@ const Model: ModelType = {
tabs
:
{
tabs
:
{
...
state
.
tabs
,
...
state
.
tabs
,
activeKey
:
item
.
key
,
activeKey
:
item
.
key
,
activeBreadcrumbTitle
:
[
item
.
type
,
item
.
breadcrumbLabel
,
item
.
label
].
join
(
'/'
)
,
activeBreadcrumbTitle
:
[
item
.
type
,
item
.
breadcrumbLabel
,
item
.
label
].
join
(
'/'
)
},
},
footContainer
:
{
footContainer
:
{
...
state
.
footContainer
,
...
state
.
footContainer
,
...
...
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