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
d9edebed
Unverified
Commit
d9edebed
authored
Oct 27, 2023
by
aiwenmo
Committed by
GitHub
Oct 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature-2447][studio] Add FlinkSQL and common SQL debug preview (#2449)
Co-authored-by:
wenmo
<
32723967+wenmo@users.noreply.github.com
>
parent
1cd2930d
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
67 additions
and
23 deletions
+67
-23
HistoryController.java
...src/main/java/org/dinky/controller/HistoryController.java
+13
-0
HistoryService.java
...admin/src/main/java/org/dinky/service/HistoryService.java
+8
-0
HistoryServiceImpl.java
.../main/java/org/dinky/service/impl/HistoryServiceImpl.java
+10
-0
StudioServiceImpl.java
...c/main/java/org/dinky/service/impl/StudioServiceImpl.java
+1
-1
TaskServiceImpl.java
...src/main/java/org/dinky/service/impl/TaskServiceImpl.java
+3
-0
CommonSqlTask.java
...n/src/main/java/org/dinky/service/task/CommonSqlTask.java
+4
-6
ResultPool.java
...-core/src/main/java/org/dinky/data/result/ResultPool.java
+3
-5
package.json
dinky-web/package.json
+1
-1
app.tsx
dinky-web/src/app.tsx
+0
-1
index.tsx
...web/src/pages/DataStudio/BottomContainer/Result/index.tsx
+10
-9
BusinessCrud.ts
dinky-web/src/services/BusinessCrud.ts
+13
-0
endpoints.tsx
dinky-web/src/services/endpoints.tsx
+1
-0
No files found.
dinky-admin/src/main/java/org/dinky/controller/HistoryController.java
View file @
d9edebed
...
@@ -21,11 +21,14 @@ package org.dinky.controller;
...
@@ -21,11 +21,14 @@ package org.dinky.controller;
import
org.dinky.data.model.History
;
import
org.dinky.data.model.History
;
import
org.dinky.data.result.ProTableResult
;
import
org.dinky.data.result.ProTableResult
;
import
org.dinky.data.result.Result
;
import
org.dinky.service.HistoryService
;
import
org.dinky.service.HistoryService
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
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.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
...
@@ -62,4 +65,14 @@ public class HistoryController {
...
@@ -62,4 +65,14 @@ public class HistoryController {
public
ProTableResult
<
History
>
listHistory
(
@RequestBody
JsonNode
para
)
{
public
ProTableResult
<
History
>
listHistory
(
@RequestBody
JsonNode
para
)
{
return
historyService
.
selectForProTable
(
para
);
return
historyService
.
selectForProTable
(
para
);
}
}
/**
* 获取Job实例的所有信息
*/
@GetMapping
(
"/getLatestHistoryById"
)
@ApiOperation
(
"Get latest history info by id"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"task id"
,
dataType
=
"Integer"
,
paramType
=
"query"
,
required
=
true
)
public
Result
<
History
>
getLatestHistoryById
(
@RequestParam
Integer
id
)
{
return
Result
.
succeed
(
historyService
.
getLatestHistoryById
(
id
));
}
}
}
dinky-admin/src/main/java/org/dinky/service/HistoryService.java
View file @
d9edebed
...
@@ -37,4 +37,12 @@ public interface HistoryService extends ISuperService<History> {
...
@@ -37,4 +37,12 @@ public interface HistoryService extends ISuperService<History> {
*/
*/
@Deprecated
@Deprecated
boolean
removeHistoryById
(
Integer
id
);
boolean
removeHistoryById
(
Integer
id
);
/**
* Get latest history info by task id.
*
* @param id The ID of the task.
* @return History info.
*/
History
getLatestHistoryById
(
Integer
id
);
}
}
dinky-admin/src/main/java/org/dinky/service/impl/HistoryServiceImpl.java
View file @
d9edebed
...
@@ -27,6 +27,8 @@ import org.dinky.service.HistoryService;
...
@@ -27,6 +27,8 @@ import org.dinky.service.HistoryService;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
/**
/**
* HistoryServiceImpl
* HistoryServiceImpl
*
*
...
@@ -43,4 +45,12 @@ public class HistoryServiceImpl extends SuperServiceImpl<HistoryMapper, History>
...
@@ -43,4 +45,12 @@ public class HistoryServiceImpl extends SuperServiceImpl<HistoryMapper, History>
}
}
return
removeById
(
id
);
return
removeById
(
id
);
}
}
@Override
public
History
getLatestHistoryById
(
Integer
id
)
{
return
baseMapper
.
selectOne
(
new
QueryWrapper
<
History
>()
.
eq
(
"task_id"
,
id
)
.
orderByDesc
(
"start_time"
)
.
last
(
"limit 1"
));
}
}
}
dinky-admin/src/main/java/org/dinky/service/impl/StudioServiceImpl.java
View file @
d9edebed
...
@@ -88,7 +88,7 @@ public class StudioServiceImpl implements StudioService {
...
@@ -88,7 +88,7 @@ public class StudioServiceImpl implements StudioService {
@Override
@Override
public
JdbcSelectResult
getCommonSqlData
(
Integer
taskId
)
{
public
JdbcSelectResult
getCommonSqlData
(
Integer
taskId
)
{
return
ResultPool
.
getCommonSqlCache
(
taskId
);
return
(
JdbcSelectResult
)
ResultPool
.
getCommonSqlCache
(
taskId
);
}
}
@Override
@Override
...
...
dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java
View file @
d9edebed
...
@@ -325,6 +325,9 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
...
@@ -325,6 +325,9 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override
@Override
public
boolean
cancelTaskJob
(
TaskDTO
task
)
{
public
boolean
cancelTaskJob
(
TaskDTO
task
)
{
if
(
Dialect
.
isCommonSql
(
task
.
getDialect
()))
{
return
true
;
}
JobInstance
jobInstance
=
jobInstanceService
.
getById
(
task
.
getJobInstanceId
());
JobInstance
jobInstance
=
jobInstanceService
.
getById
(
task
.
getJobInstanceId
());
Assert
.
notNull
(
jobInstance
,
Status
.
JOB_INSTANCE_NOT_EXIST
.
getMessage
());
Assert
.
notNull
(
jobInstance
,
Status
.
JOB_INSTANCE_NOT_EXIST
.
getMessage
());
ClusterInstance
clusterInstance
=
clusterInstanceService
.
getById
(
jobInstance
.
getClusterId
());
ClusterInstance
clusterInstance
=
clusterInstanceService
.
getById
(
jobInstance
.
getClusterId
());
...
...
dinky-admin/src/main/java/org/dinky/service/task/CommonSqlTask.java
View file @
d9edebed
...
@@ -23,15 +23,13 @@ import org.dinky.config.Dialect;
...
@@ -23,15 +23,13 @@ import org.dinky.config.Dialect;
import
org.dinky.data.annotation.SupportDialect
;
import
org.dinky.data.annotation.SupportDialect
;
import
org.dinky.data.dto.SqlDTO
;
import
org.dinky.data.dto.SqlDTO
;
import
org.dinky.data.dto.TaskDTO
;
import
org.dinky.data.dto.TaskDTO
;
import
org.dinky.data.result.ResultPool
;
import
org.dinky.data.result.SqlExplainResult
;
import
org.dinky.data.result.SqlExplainResult
;
import
org.dinky.job.JobResult
;
import
org.dinky.job.JobResult
;
import
org.dinky.service.DataBaseService
;
import
org.dinky.service.DataBaseService
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
cn.hutool.cache.Cache
;
import
cn.hutool.cache.impl.TimedCache
;
import
cn.hutool.extra.spring.SpringUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -50,8 +48,6 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -50,8 +48,6 @@ import lombok.extern.slf4j.Slf4j;
Dialect
.
PRESTO
Dialect
.
PRESTO
})
})
public
class
CommonSqlTask
extends
BaseTask
{
public
class
CommonSqlTask
extends
BaseTask
{
private
static
final
Cache
<
Integer
,
JobResult
>
COMMON_SQL_SEARCH_CACHE
=
new
TimedCache
<>(
TimeUnit
.
MINUTES
.
toMillis
(
10
));
public
CommonSqlTask
(
TaskDTO
task
)
{
public
CommonSqlTask
(
TaskDTO
task
)
{
super
(
task
);
super
(
task
);
...
@@ -68,7 +64,9 @@ public class CommonSqlTask extends BaseTask {
...
@@ -68,7 +64,9 @@ public class CommonSqlTask extends BaseTask {
log
.
info
(
"Preparing to execute common sql..."
);
log
.
info
(
"Preparing to execute common sql..."
);
SqlDTO
sqlDTO
=
SqlDTO
.
build
(
task
.
getStatement
(),
task
.
getDatabaseId
(),
null
);
SqlDTO
sqlDTO
=
SqlDTO
.
build
(
task
.
getStatement
(),
task
.
getDatabaseId
(),
null
);
DataBaseService
dataBaseService
=
SpringUtil
.
getBean
(
DataBaseService
.
class
);
DataBaseService
dataBaseService
=
SpringUtil
.
getBean
(
DataBaseService
.
class
);
return
COMMON_SQL_SEARCH_CACHE
.
get
(
task
.
getId
(),
()
->
dataBaseService
.
executeCommonSql
(
sqlDTO
));
JobResult
jobResult
=
dataBaseService
.
executeCommonSql
(
sqlDTO
);
ResultPool
.
putCommonSqlCache
(
task
.
getId
(),
jobResult
.
getResult
());
return
jobResult
;
}
}
@Override
@Override
...
...
dinky-core/src/main/java/org/dinky/data/result/ResultPool.java
View file @
d9edebed
...
@@ -19,8 +19,6 @@
...
@@ -19,8 +19,6 @@
package
org
.
dinky
.
data
.
result
;
package
org
.
dinky
.
data
.
result
;
import
org.dinky.metadata.result.JdbcSelectResult
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
cn.hutool.cache.Cache
;
import
cn.hutool.cache.Cache
;
...
@@ -35,7 +33,7 @@ public final class ResultPool {
...
@@ -35,7 +33,7 @@ public final class ResultPool {
private
ResultPool
()
{}
private
ResultPool
()
{}
private
static
final
Cache
<
Integer
,
JdbcSelect
Result
>
COMMON_SQL_SEARCH_CACHE
=
private
static
final
Cache
<
Integer
,
I
Result
>
COMMON_SQL_SEARCH_CACHE
=
new
TimedCache
<>(
TimeUnit
.
MINUTES
.
toMillis
(
10
));
new
TimedCache
<>(
TimeUnit
.
MINUTES
.
toMillis
(
10
));
private
static
final
Cache
<
String
,
SelectResult
>
results
=
new
TimedCache
<>(
TimeUnit
.
MINUTES
.
toMillis
(
10
));
private
static
final
Cache
<
String
,
SelectResult
>
results
=
new
TimedCache
<>(
TimeUnit
.
MINUTES
.
toMillis
(
10
));
...
@@ -47,11 +45,11 @@ public final class ResultPool {
...
@@ -47,11 +45,11 @@ public final class ResultPool {
results
.
put
(
result
.
getJobId
(),
result
);
results
.
put
(
result
.
getJobId
(),
result
);
}
}
public
static
void
putCommonSqlCache
(
Integer
taskId
,
JdbcSelect
Result
result
)
{
public
static
void
putCommonSqlCache
(
Integer
taskId
,
I
Result
result
)
{
COMMON_SQL_SEARCH_CACHE
.
put
(
taskId
,
result
);
COMMON_SQL_SEARCH_CACHE
.
put
(
taskId
,
result
);
}
}
public
static
JdbcSelect
Result
getCommonSqlCache
(
Integer
taskId
)
{
public
static
I
Result
getCommonSqlCache
(
Integer
taskId
)
{
return
COMMON_SQL_SEARCH_CACHE
.
get
(
taskId
);
return
COMMON_SQL_SEARCH_CACHE
.
get
(
taskId
);
}
}
...
...
dinky-web/package.json
View file @
d9edebed
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
"redux-persist"
:
"^6.0.0"
,
"redux-persist"
:
"^6.0.0"
,
"remark-gfm"
:
"^4.0.0"
,
"remark-gfm"
:
"^4.0.0"
,
"screenfull"
:
"^6.0.2"
,
"screenfull"
:
"^6.0.2"
,
"sql-formatter"
:
"^13.0.
1
"
,
"sql-formatter"
:
"^13.0.
2
"
,
"styled-components"
:
"^6.0.8"
,
"styled-components"
:
"^6.0.8"
,
"use-sse"
:
"^2.0.1"
"use-sse"
:
"^2.0.1"
},
},
...
...
dinky-web/src/app.tsx
View file @
d9edebed
...
@@ -115,7 +115,6 @@ export async function getInitialState(): Promise<{
...
@@ -115,7 +115,6 @@ export async function getInitialState(): Promise<{
// ProLayout 支持的api https://procomponents.ant.design/components/layout
// ProLayout 支持的api https://procomponents.ant.design/components/layout
export
const
layout
:
RunTimeLayoutConfig
=
({
initialState
})
=>
{
export
const
layout
:
RunTimeLayoutConfig
=
({
initialState
})
=>
{
console
.
log
(
initialState
);
const
fullscreen
=
initialState
?.
fullscreen
;
const
fullscreen
=
initialState
?.
fullscreen
;
const
defaultSettings
=
{
const
defaultSettings
=
{
...
...
dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx
View file @
d9edebed
...
@@ -25,7 +25,7 @@ import {
...
@@ -25,7 +25,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
{
postAll
}
from
'@/services/api'
;
import
{
postAll
}
from
'@/services/api'
;
import
{
handleGetOption
}
from
'@/services/BusinessCrud'
;
import
{
handleGetOption
,
handleGetOptionWithoutMsg
}
from
'@/services/BusinessCrud'
;
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'
;
...
@@ -142,18 +142,18 @@ const Result = (props: any) => {
...
@@ -142,18 +142,18 @@ const Result = (props: any) => {
}
else
{
}
else
{
// flink sql
// flink sql
// to do: get job data by history id list, not flink jid
// to do: get job data by history id list, not flink jid
if
(
current
.
jobInstanceId
)
{
console
.
log
(
current
);
const
res
=
await
postAll
(
API_CONSTANTS
.
GET_JOB_BY_ID
,
{
if
(
current
.
id
)
{
id
:
current
.
jobInstanceId
const
res
=
await
handleGetOptionWithoutMsg
(
API_CONSTANTS
.
GET_LATEST_HISTORY_BY_ID
,
{
id
:
current
.
id
});
});
const
job
Data
=
res
.
datas
;
const
history
Data
=
res
.
datas
;
if
(
'
unknown'
!==
jobData
.
status
.
toLowerCase
()
)
{
if
(
'
2'
==
historyData
.
status
)
{
const
jid
=
jobData
.
j
id
;
const
historyId
=
historyData
.
id
;
const
tableData
=
await
handleGetOption
(
'api/studio/getJobData'
,
'Get Data'
,
{
const
tableData
=
await
handleGetOption
(
'api/studio/getJobData'
,
'Get Data'
,
{
jobId
:
ji
d
jobId
:
historyI
d
});
});
const
datas
=
tableData
.
datas
;
const
datas
=
tableData
.
datas
;
datas
.
jid
=
jid
;
if
(
datas
.
success
)
{
if
(
datas
.
success
)
{
params
.
resultData
=
datas
;
params
.
resultData
=
datas
;
setData
(
datas
);
setData
(
datas
);
...
@@ -238,6 +238,7 @@ const Result = (props: any) => {
...
@@ -238,6 +238,7 @@ const Result = (props: any) => {
{
data
.
columns
?
(
{
data
.
columns
?
(
<
Table
<
Table
columns=
{
getColumns
(
data
.
columns
)
}
columns=
{
getColumns
(
data
.
columns
)
}
size=
"small"
dataSource=
{
data
.
rowData
?.
map
((
item
:
any
,
index
:
number
)
=>
{
dataSource=
{
data
.
rowData
?.
map
((
item
:
any
,
index
:
number
)
=>
{
return
{
...
item
,
key
:
index
};
return
{
...
item
,
key
:
index
};
})
}
})
}
...
...
dinky-web/src/services/BusinessCrud.ts
View file @
d9edebed
...
@@ -204,6 +204,19 @@ export const handleGetOption = async (url: string, title: string, param: any) =>
...
@@ -204,6 +204,19 @@ export const handleGetOption = async (url: string, title: string, param: any) =>
}
}
};
};
export
const
handleGetOptionWithoutMsg
=
async
(
url
:
string
,
param
:
any
)
=>
{
try
{
const
result
=
await
getData
(
url
,
param
);
if
(
result
.
code
===
RESPONSE_CODE
.
SUCCESS
)
{
return
result
;
}
WarningMessage
(
result
.
msg
);
return
undefined
;
}
catch
(
error
)
{
return
undefined
;
}
};
export
const
handleData
=
async
(
url
:
string
,
id
:
any
)
=>
{
export
const
handleData
=
async
(
url
:
string
,
id
:
any
)
=>
{
try
{
try
{
const
{
code
,
datas
}
=
await
getInfoById
(
url
,
id
);
const
{
code
,
datas
}
=
await
getInfoById
(
url
,
id
);
...
...
dinky-web/src/services/endpoints.tsx
View file @
d9edebed
...
@@ -217,6 +217,7 @@ export enum API_CONSTANTS {
...
@@ -217,6 +217,7 @@ export enum API_CONSTANTS {
// ---- devops
// ---- devops
GET_JOB_LIST
=
'/api/jobInstance'
,
GET_JOB_LIST
=
'/api/jobInstance'
,
GET_JOB_BY_ID
=
'/api/jobInstance/getOneById'
,
GET_JOB_BY_ID
=
'/api/jobInstance/getOneById'
,
GET_LATEST_HISTORY_BY_ID
=
'/api/history/getLatestHistoryById'
,
GET_JOB_DETAIL
=
'/api/jobInstance/getJobInfoDetail'
,
GET_JOB_DETAIL
=
'/api/jobInstance/getJobInfoDetail'
,
REFRESH_JOB_DETAIL
=
'/api/jobInstance/refreshJobInfoDetail'
,
REFRESH_JOB_DETAIL
=
'/api/jobInstance/refreshJobInfoDetail'
,
READ_CHECKPOINT
=
'/api/flinkConf/readCheckPoint'
,
READ_CHECKPOINT
=
'/api/flinkConf/readCheckPoint'
,
...
...
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