Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
4d7dc549
Commit
4d7dc549
authored
Sep 14, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级新版本
parent
fad0f2cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
YzgTimeout.java
...src/main/java/com/yanzuoguang/util/helper/YzgTimeout.java
+14
-0
DbExecuteImpl.java
.../src/main/java/com/yanzuoguang/db/impl/DbExecuteImpl.java
+4
-3
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/YzgTimeout.java
View file @
4d7dc549
...
...
@@ -4,6 +4,8 @@ import com.yanzuoguang.util.log.Log;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
com.yanzuoguang.util.vo.Ref
;
import
java.util.function.Consumer
;
/**
* 超时监控
*
...
...
@@ -23,8 +25,20 @@ public class YzgTimeout {
* @param runnable 运行函数
*/
public
static
void
timeOut
(
Class
<?>
cls
,
String
message
,
Runnable
runnable
)
{
timeOut
(
cls
,
message
,
runnable
,
null
);
}
/**
* 超时监控
*
* @param cls 日志类
* @param message 消息
* @param runnable 运行函数
*/
public
static
void
timeOut
(
Class
<?>
cls
,
String
message
,
Runnable
runnable
,
Consumer
<
Long
>
consumer
)
{
timeHeart
(
TIME_OUT_DEFAULT
,
TIME_OUT_UNIT
,
TIME_OUT_TIP
,
runnable
,
(
time
)
->
{
Log
.
error
(
cls
,
"%s超时,已经执行%d豪秒,正在等待执行完成"
,
message
,
time
);
consumer
.
accept
(
time
);
});
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/db/impl/DbExecuteImpl.java
View file @
4d7dc549
...
...
@@ -158,9 +158,10 @@ public class DbExecuteImpl implements DbExecute {
boolean
isError
=
false
;
try
{
YzgTimeout
.
timeOut
(
sqlInfo
.
getTargetClass
(),
sqlInfo
.
getSqlName
(),
()
->
sqlFunction
.
accept
(
row
,
start
)
);
YzgTimeout
.
timeOut
(
sqlInfo
.
getTargetClass
(),
sqlInfo
.
getSqlName
()
,
()
->
sqlFunction
.
accept
(
row
,
start
)
// 打印超时的SQL语句
,
(
time
)
->
printSql
.
print
(
sqlInfo
,
time
,
row
.
value
));
}
catch
(
Exception
ex
)
{
isError
=
true
;
throw
ex
;
...
...
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