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
716eb700
Unverified
Commit
716eb700
authored
Nov 06, 2022
by
aiwenmo
Committed by
GitHub
Nov 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Optimization-1215][admin] Optimizate execute console (#1216)
Co-authored-by:
wenmo
<
32723967+wenmo@users.noreply.github.com
>
parent
b34a901d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
48 deletions
+51
-48
ProcessController.java
...src/main/java/com/dlink/controller/ProcessController.java
+2
-2
StudioServiceImpl.java
...c/main/java/com/dlink/service/impl/StudioServiceImpl.java
+32
-19
ProcessEntity.java
.../src/main/java/com/dlink/process/model/ProcessEntity.java
+8
-19
ProcessType.java
...ss/src/main/java/com/dlink/process/model/ProcessType.java
+2
-0
ConsolePool.java
...ess/src/main/java/com/dlink/process/pool/ConsolePool.java
+7
-3
data.d.ts
dlink-web/src/pages/SettingCenter/ProcessList/data.d.ts
+0
-1
index.tsx
dlink-web/src/pages/SettingCenter/ProcessList/index.tsx
+0
-4
No files found.
dlink-admin/src/main/java/com/dlink/controller/ProcessController.java
View file @
716eb700
...
@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -32,7 +32,7 @@ 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
cn.dev33.satoken.
SaManager
;
import
cn.dev33.satoken.
stp.StpUtil
;
/**
/**
* ProcessController
* ProcessController
...
@@ -55,6 +55,6 @@ public class ProcessController {
...
@@ -55,6 +55,6 @@ public class ProcessController {
@GetMapping
(
"/getConsoleByUserId"
)
@GetMapping
(
"/getConsoleByUserId"
)
public
Result
<
String
>
getConsoleByUserId
()
{
public
Result
<
String
>
getConsoleByUserId
()
{
return
Result
.
data
(
processService
.
getConsoleByUserId
(
S
aManager
.
getStpLogic
(
null
)
.
getLoginIdAsInt
()));
return
Result
.
data
(
processService
.
getConsoleByUserId
(
S
tpUtil
.
getLoginIdAsInt
()));
}
}
}
}
dlink-admin/src/main/java/com/dlink/service/impl/StudioServiceImpl.java
View file @
716eb700
...
@@ -82,7 +82,7 @@ import com.fasterxml.jackson.databind.JsonNode;
...
@@ -82,7 +82,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
cn.dev33.satoken.
SaManager
;
import
cn.dev33.satoken.
stp.StpUtil
;
/**
/**
* StudioServiceImpl
* StudioServiceImpl
...
@@ -176,15 +176,19 @@ public class StudioServiceImpl implements StudioService {
...
@@ -176,15 +176,19 @@ public class StudioServiceImpl implements StudioService {
}
}
private
JobResult
executeFlinkSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
private
JobResult
executeFlinkSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
ProcessEntity
process
=
ProcessContextHolder
.
registerProcess
(
ProcessEntity
.
init
(
ProcessType
.
FLINKEXECUTE
,
StpUtil
.
getLoginIdAsInt
()));
addFlinkSQLEnv
(
studioExecuteDTO
);
addFlinkSQLEnv
(
studioExecuteDTO
);
process
.
info
(
"Initializing Flink Job Config..."
);
JobConfig
config
=
studioExecuteDTO
.
getJobConfig
();
JobConfig
config
=
studioExecuteDTO
.
getJobConfig
();
buildSession
(
config
);
buildSession
(
config
);
// init UDF
// init UDF
udfService
.
init
(
studioExecuteDTO
.
getStatement
(),
config
);
udfService
.
init
(
studioExecuteDTO
.
getStatement
(),
config
);
JobManager
jobManager
=
JobManager
.
build
(
config
);
JobManager
jobManager
=
JobManager
.
build
(
config
);
process
.
infoSuccess
();
process
.
start
();
JobResult
jobResult
=
jobManager
.
executeSql
(
studioExecuteDTO
.
getStatement
());
JobResult
jobResult
=
jobManager
.
executeSql
(
studioExecuteDTO
.
getStatement
());
process
.
finish
();
RunTimeUtil
.
recovery
(
jobManager
);
RunTimeUtil
.
recovery
(
jobManager
);
return
jobResult
;
return
jobResult
;
}
}
...
@@ -200,29 +204,33 @@ public class StudioServiceImpl implements StudioService {
...
@@ -200,29 +204,33 @@ public class StudioServiceImpl implements StudioService {
@Override
@Override
public
JobResult
executeCommonSql
(
SqlDTO
sqlDTO
)
{
public
JobResult
executeCommonSql
(
SqlDTO
sqlDTO
)
{
ProcessEntity
process
=
ProcessContextHolder
.
registerProcess
(
ProcessEntity
.
init
(
ProcessType
.
SQLEXECUTE
,
StpUtil
.
getLoginIdAsInt
()));
JobResult
result
=
new
JobResult
();
JobResult
result
=
new
JobResult
();
result
.
setStatement
(
sqlDTO
.
getStatement
());
result
.
setStatement
(
sqlDTO
.
getStatement
());
result
.
setStartTimeNow
();
result
.
setStartTimeNow
();
process
.
info
(
"Initializing Database Connection..."
);
if
(
Asserts
.
isNull
(
sqlDTO
.
getDatabaseId
()))
{
if
(
Asserts
.
isNull
(
sqlDTO
.
getDatabaseId
()))
{
result
.
setSuccess
(
false
);
result
.
setSuccess
(
false
);
result
.
setError
(
"请指定数据源"
);
result
.
setError
(
"请指定数据源"
);
result
.
setEndTimeNow
();
result
.
setEndTimeNow
();
return
result
;
return
result
;
}
}
DataBase
dataBase
=
dataBaseService
.
getById
(
sqlDTO
.
getDatabaseId
());
DataBase
dataBase
=
dataBaseService
.
getById
(
sqlDTO
.
getDatabaseId
());
if
(
Asserts
.
isNull
(
dataBase
))
{
if
(
Asserts
.
isNull
(
dataBase
))
{
process
.
error
(
"The database does not exist."
);
result
.
setSuccess
(
false
);
result
.
setSuccess
(
false
);
result
.
setError
(
"
数据源不存在
"
);
result
.
setError
(
"
The database does not exist.
"
);
result
.
setEndTimeNow
();
result
.
setEndTimeNow
();
return
result
;
return
result
;
}
}
JdbcSelectResult
selectResult
;
JdbcSelectResult
selectResult
;
try
(
Driver
driver
=
Driver
.
build
(
dataBase
.
getDriverConfig
()))
{
try
(
Driver
driver
=
Driver
.
build
(
dataBase
.
getDriverConfig
()))
{
process
.
infoSuccess
();
process
.
start
();
selectResult
=
driver
.
executeSql
(
sqlDTO
.
getStatement
(),
sqlDTO
.
getMaxRowNum
());
selectResult
=
driver
.
executeSql
(
sqlDTO
.
getStatement
(),
sqlDTO
.
getMaxRowNum
());
}
}
process
.
finish
();
result
.
setResult
(
selectResult
);
result
.
setResult
(
selectResult
);
if
(
selectResult
.
isSuccess
())
{
if
(
selectResult
.
isSuccess
())
{
result
.
setSuccess
(
true
);
result
.
setSuccess
(
true
);
...
@@ -256,23 +264,18 @@ public class StudioServiceImpl implements StudioService {
...
@@ -256,23 +264,18 @@ public class StudioServiceImpl implements StudioService {
private
List
<
SqlExplainResult
>
explainFlinkSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
private
List
<
SqlExplainResult
>
explainFlinkSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
ProcessEntity
process
=
ProcessContextHolder
.
registerProcess
(
ProcessEntity
process
=
ProcessContextHolder
.
registerProcess
(
ProcessEntity
.
init
(
ProcessType
.
FLINKEXPLAIN
,
SaManager
.
getStpLogic
(
null
).
getLoginIdAsInt
(),
"admin"
));
ProcessEntity
.
init
(
ProcessType
.
FLINKEXPLAIN
,
StpUtil
.
getLoginIdAsInt
()));
addFlinkSQLEnv
(
studioExecuteDTO
);
addFlinkSQLEnv
(
studioExecuteDTO
);
process
.
info
(
"Initializing Flink Job Config..."
);
process
.
info
(
"Initializing Flink Job Config..."
);
JobConfig
config
=
studioExecuteDTO
.
getJobConfig
();
JobConfig
config
=
studioExecuteDTO
.
getJobConfig
();
// If you are using explainSql | getStreamGraph | getJobPlan, make the dialect change to local.
// If you are using explainSql | getStreamGraph | getJobPlan, make the dialect change to local.
config
.
buildLocal
();
config
.
buildLocal
();
buildSession
(
config
);
buildSession
(
config
);
process
.
infoSuccess
();
process
.
start
();
// init UDF
// init UDF
udfService
.
init
(
studioExecuteDTO
.
getStatement
(),
config
);
udfService
.
init
(
studioExecuteDTO
.
getStatement
(),
config
);
JobManager
jobManager
=
JobManager
.
build
(
config
);
JobManager
jobManager
=
JobManager
.
build
(
config
);
process
.
infoSuccess
();
process
.
start
();
List
<
SqlExplainResult
>
sqlExplainResults
=
List
<
SqlExplainResult
>
sqlExplainResults
=
jobManager
.
explainSql
(
studioExecuteDTO
.
getStatement
()).
getSqlExplainResults
();
jobManager
.
explainSql
(
studioExecuteDTO
.
getStatement
()).
getSqlExplainResults
();
process
.
finish
();
process
.
finish
();
...
@@ -280,17 +283,27 @@ public class StudioServiceImpl implements StudioService {
...
@@ -280,17 +283,27 @@ public class StudioServiceImpl implements StudioService {
}
}
private
List
<
SqlExplainResult
>
explainCommonSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
private
List
<
SqlExplainResult
>
explainCommonSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
ProcessEntity
process
=
ProcessContextHolder
.
registerProcess
(
ProcessEntity
.
init
(
ProcessType
.
SQLEXPLAIN
,
StpUtil
.
getLoginIdAsInt
()));
process
.
info
(
"Initializing Flink Job Config..."
);
if
(
Asserts
.
isNull
(
studioExecuteDTO
.
getDatabaseId
()))
{
if
(
Asserts
.
isNull
(
studioExecuteDTO
.
getDatabaseId
()))
{
return
Collections
.
singletonList
(
SqlExplainResult
.
fail
(
studioExecuteDTO
.
getStatement
(),
"请指定数据源"
));
process
.
error
(
"The database does not exist."
);
return
Collections
.
singletonList
(
SqlExplainResult
.
fail
(
studioExecuteDTO
.
getStatement
(),
"Please specify the database."
));
}
}
DataBase
dataBase
=
dataBaseService
.
getById
(
studioExecuteDTO
.
getDatabaseId
());
DataBase
dataBase
=
dataBaseService
.
getById
(
studioExecuteDTO
.
getDatabaseId
());
if
(
Asserts
.
isNull
(
dataBase
))
{
if
(
Asserts
.
isNull
(
dataBase
))
{
return
Collections
.
singletonList
(
SqlExplainResult
.
fail
(
studioExecuteDTO
.
getStatement
(),
"数据源不存在"
));
process
.
error
(
"The database does not exist."
);
return
Collections
.
singletonList
(
SqlExplainResult
.
fail
(
studioExecuteDTO
.
getStatement
(),
"The database does not exist."
));
}
}
try
(
Driver
driver
=
Driver
.
build
(
dataBase
.
getDriverConfig
()))
{
try
(
Driver
driver
=
Driver
.
build
(
dataBase
.
getDriverConfig
()))
{
return
driver
.
explain
(
studioExecuteDTO
.
getStatement
());
process
.
infoSuccess
();
process
.
start
();
List
<
SqlExplainResult
>
explain
=
driver
.
explain
(
studioExecuteDTO
.
getStatement
());
process
.
finish
();
return
explain
;
}
}
}
}
...
...
dlink-process/src/main/java/com/dlink/process/model/ProcessEntity.java
View file @
716eb700
...
@@ -48,25 +48,23 @@ public class ProcessEntity {
...
@@ -48,25 +48,23 @@ public class ProcessEntity {
private
int
stepIndex
=
0
;
private
int
stepIndex
=
0
;
private
List
<
ProcessStep
>
steps
;
private
List
<
ProcessStep
>
steps
;
private
Integer
userId
;
private
Integer
userId
;
private
String
userName
;
public
static
final
ProcessEntity
NULL_PROCESS
=
new
ProcessEntity
();
public
static
final
ProcessEntity
NULL_PROCESS
=
new
ProcessEntity
();
public
ProcessEntity
()
{
public
ProcessEntity
()
{
}
}
public
ProcessEntity
(
String
pid
,
String
name
,
Integer
taskId
,
ProcessType
type
,
Integer
userId
,
String
userName
)
{
public
ProcessEntity
(
String
pid
,
String
name
,
Integer
taskId
,
ProcessType
type
,
Integer
userId
)
{
this
.
pid
=
pid
;
this
.
pid
=
pid
;
this
.
name
=
name
;
this
.
name
=
name
;
this
.
taskId
=
taskId
;
this
.
taskId
=
taskId
;
this
.
type
=
type
;
this
.
type
=
type
;
this
.
userId
=
userId
;
this
.
userId
=
userId
;
this
.
userName
=
userName
;
}
}
public
ProcessEntity
(
String
name
,
Integer
taskId
,
ProcessType
type
,
ProcessStatus
status
,
LocalDateTime
startTime
,
public
ProcessEntity
(
String
name
,
Integer
taskId
,
ProcessType
type
,
ProcessStatus
status
,
LocalDateTime
startTime
,
LocalDateTime
endTime
,
long
time
,
LocalDateTime
endTime
,
long
time
,
List
<
ProcessStep
>
steps
,
Integer
userId
,
String
userName
)
{
List
<
ProcessStep
>
steps
,
Integer
userId
)
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
taskId
=
taskId
;
this
.
taskId
=
taskId
;
this
.
type
=
type
;
this
.
type
=
type
;
...
@@ -76,19 +74,18 @@ public class ProcessEntity {
...
@@ -76,19 +74,18 @@ public class ProcessEntity {
this
.
time
=
time
;
this
.
time
=
time
;
this
.
steps
=
steps
;
this
.
steps
=
steps
;
this
.
userId
=
userId
;
this
.
userId
=
userId
;
this
.
userName
=
userName
;
}
}
public
static
ProcessEntity
init
(
ProcessType
type
,
Integer
userId
,
String
userName
)
{
public
static
ProcessEntity
init
(
ProcessType
type
,
Integer
userId
)
{
return
init
(
type
.
getValue
()
+
"_TEMP"
,
null
,
type
,
userId
,
userName
);
return
init
(
type
.
getValue
()
+
"_TEMP"
,
null
,
type
,
userId
);
}
}
public
static
ProcessEntity
init
(
Integer
taskId
,
ProcessType
type
,
Integer
userId
,
String
userName
)
{
public
static
ProcessEntity
init
(
Integer
taskId
,
ProcessType
type
,
Integer
userId
)
{
return
init
(
type
.
getValue
()
+
taskId
,
taskId
,
type
,
userId
,
userName
);
return
init
(
type
.
getValue
()
+
taskId
,
taskId
,
type
,
userId
);
}
}
public
static
ProcessEntity
init
(
String
name
,
Integer
taskId
,
ProcessType
type
,
Integer
userId
,
String
userName
)
{
public
static
ProcessEntity
init
(
String
name
,
Integer
taskId
,
ProcessType
type
,
Integer
userId
)
{
ProcessEntity
process
=
new
ProcessEntity
(
UUID
.
randomUUID
().
toString
(),
name
,
taskId
,
type
,
userId
,
userName
);
ProcessEntity
process
=
new
ProcessEntity
(
UUID
.
randomUUID
().
toString
(),
name
,
taskId
,
type
,
userId
);
process
.
setStatus
(
ProcessStatus
.
INITIALIZING
);
process
.
setStatus
(
ProcessStatus
.
INITIALIZING
);
process
.
setStartTime
(
LocalDateTime
.
now
());
process
.
setStartTime
(
LocalDateTime
.
now
());
process
.
setSteps
(
new
ArrayList
<>());
process
.
setSteps
(
new
ArrayList
<>());
...
@@ -248,14 +245,6 @@ public class ProcessEntity {
...
@@ -248,14 +245,6 @@ public class ProcessEntity {
this
.
userId
=
userId
;
this
.
userId
=
userId
;
}
}
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
List
<
ProcessStep
>
getSteps
()
{
public
List
<
ProcessStep
>
getSteps
()
{
return
steps
;
return
steps
;
}
}
...
...
dlink-process/src/main/java/com/dlink/process/model/ProcessType.java
View file @
716eb700
...
@@ -30,8 +30,10 @@ import com.dlink.assertion.Asserts;
...
@@ -30,8 +30,10 @@ import com.dlink.assertion.Asserts;
public
enum
ProcessType
{
public
enum
ProcessType
{
FLINKEXPLAIN
(
"FlinkExplain"
),
FLINKEXPLAIN
(
"FlinkExplain"
),
FLINKEXECUTE
(
"FlinkExecute"
),
FLINKSUBMIT
(
"FlinkSubmit"
),
FLINKSUBMIT
(
"FlinkSubmit"
),
SQLEXPLAIN
(
"SQLExplain"
),
SQLEXPLAIN
(
"SQLExplain"
),
SQLEXECUTE
(
"SQLExecute"
),
SQKSUBMIT
(
"SQLSubmit"
),
SQKSUBMIT
(
"SQLSubmit"
),
UNKNOWN
(
"Unknown"
);
UNKNOWN
(
"Unknown"
);
...
...
dlink-process/src/main/java/com/dlink/process/pool/ConsolePool.java
View file @
716eb700
...
@@ -51,8 +51,12 @@ public class ConsolePool extends AbstractPool<StringBuilder> {
...
@@ -51,8 +51,12 @@ public class ConsolePool extends AbstractPool<StringBuilder> {
}
}
public
static
void
write
(
String
str
,
Integer
userId
)
{
public
static
void
write
(
String
str
,
Integer
userId
)
{
String
user
=
String
.
valueOf
(
userId
);
String
user
=
userId
.
toString
();
consoleEntityMap
.
getOrDefault
(
user
,
new
StringBuilder
(
"Dinky User Console:"
)).
append
(
str
);
if
(
consoleEntityMap
.
containsKey
(
user
))
{
consoleEntityMap
.
get
(
user
).
append
(
str
);
}
else
{
StringBuilder
sb
=
new
StringBuilder
(
"Dinky User Console:"
);
consoleEntityMap
.
put
(
user
,
sb
.
append
(
str
));
}
}
}
}
}
dlink-web/src/pages/SettingCenter/ProcessList/data.d.ts
View file @
716eb700
...
@@ -28,7 +28,6 @@ export type ProcessItem = {
...
@@ -28,7 +28,6 @@ export type ProcessItem = {
time
:
number
,
time
:
number
,
steps
:
ProcessStep
[],
steps
:
ProcessStep
[],
userId
:
number
,
userId
:
number
,
userName
:
string
,
};
};
export
type
ProcessStep
=
{
export
type
ProcessStep
=
{
...
...
dlink-web/src/pages/SettingCenter/ProcessList/index.tsx
View file @
716eb700
...
@@ -138,10 +138,6 @@ const ProcessList: React.FC<{}> = (props: any) => {
...
@@ -138,10 +138,6 @@ const ProcessList: React.FC<{}> = (props: any) => {
title
:
'操作人ID'
,
title
:
'操作人ID'
,
sorter
:
true
,
sorter
:
true
,
dataIndex
:
'userId'
,
dataIndex
:
'userId'
,
},
{
title
:
'操作人名'
,
sorter
:
true
,
dataIndex
:
'userName'
,
}
}
];
];
...
...
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