Commit 4d7dc549 authored by yanzg's avatar yanzg

升级新版本

parent fad0f2cc
...@@ -4,6 +4,8 @@ import com.yanzuoguang.util.log.Log; ...@@ -4,6 +4,8 @@ import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.thread.ThreadHelper; import com.yanzuoguang.util.thread.ThreadHelper;
import com.yanzuoguang.util.vo.Ref; import com.yanzuoguang.util.vo.Ref;
import java.util.function.Consumer;
/** /**
* 超时监控 * 超时监控
* *
...@@ -23,8 +25,20 @@ public class YzgTimeout { ...@@ -23,8 +25,20 @@ public class YzgTimeout {
* @param runnable 运行函数 * @param runnable 运行函数
*/ */
public static void timeOut(Class<?> cls, String message, Runnable 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) -> { timeHeart(TIME_OUT_DEFAULT, TIME_OUT_UNIT, TIME_OUT_TIP, runnable, (time) -> {
Log.error(cls, "%s超时,已经执行%d豪秒,正在等待执行完成", message, time); Log.error(cls, "%s超时,已经执行%d豪秒,正在等待执行完成", message, time);
consumer.accept(time);
}); });
} }
......
...@@ -158,9 +158,10 @@ public class DbExecuteImpl implements DbExecute { ...@@ -158,9 +158,10 @@ public class DbExecuteImpl implements DbExecute {
boolean isError = false; boolean isError = false;
try { try {
YzgTimeout.timeOut(sqlInfo.getTargetClass(), sqlInfo.getSqlName(), () -> YzgTimeout.timeOut(sqlInfo.getTargetClass(), sqlInfo.getSqlName()
sqlFunction.accept(row, start) , () -> sqlFunction.accept(row, start)
); // 打印超时的SQL语句
, (time) -> printSql.print(sqlInfo, time, row.value));
} catch (Exception ex) { } catch (Exception ex) {
isError = true; isError = true;
throw ex; throw ex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment