|
@@ -9,7 +9,7 @@ import tech.powerjob.common.enums.InstanceStatus;
|
|
|
import tech.powerjob.common.model.InstanceDetail;
|
|
|
import tech.powerjob.common.request.ServerScheduleJobReq;
|
|
|
import tech.powerjob.common.request.TaskTrackerReportInstanceStatusReq;
|
|
|
-import tech.powerjob.worker.background.RunnableWrapper;
|
|
|
+import tech.powerjob.common.enhance.SafeRunnableWrapper;
|
|
|
import tech.powerjob.worker.common.WorkerRuntime;
|
|
|
import tech.powerjob.worker.common.constants.TaskConstant;
|
|
|
import tech.powerjob.worker.common.constants.TaskStatus;
|
|
@@ -94,14 +94,14 @@ public class LightTaskTracker extends TaskTracker {
|
|
|
// 初始延迟加入随机值,避免在高并发场景下所有请求集中在一个时间段
|
|
|
long initDelay = RandomUtils.nextInt(5000, 10000);
|
|
|
// 上报任务状态
|
|
|
- statusReportScheduledFuture = workerRuntime.getExecutorManager().getLightweightTaskStatusCheckExecutor().scheduleWithFixedDelay(new RunnableWrapper(this::checkAndReportStatus), initDelay, delay, TimeUnit.MILLISECONDS);
|
|
|
+ statusReportScheduledFuture = workerRuntime.getExecutorManager().getLightweightTaskStatusCheckExecutor().scheduleWithFixedDelay(new SafeRunnableWrapper(this::checkAndReportStatus), initDelay, delay, TimeUnit.MILLISECONDS);
|
|
|
// 超时控制
|
|
|
if (instanceInfo.getInstanceTimeoutMS() != Integer.MAX_VALUE) {
|
|
|
if (instanceInfo.getInstanceTimeoutMS() < 1000L) {
|
|
|
- timeoutCheckScheduledFuture = workerRuntime.getExecutorManager().getLightweightTaskStatusCheckExecutor().scheduleAtFixedRate(new RunnableWrapper(this::timeoutCheck), instanceInfo.getInstanceTimeoutMS(), instanceInfo.getInstanceTimeoutMS() / 10, TimeUnit.MILLISECONDS);
|
|
|
+ timeoutCheckScheduledFuture = workerRuntime.getExecutorManager().getLightweightTaskStatusCheckExecutor().scheduleAtFixedRate(new SafeRunnableWrapper(this::timeoutCheck), instanceInfo.getInstanceTimeoutMS(), instanceInfo.getInstanceTimeoutMS() / 10, TimeUnit.MILLISECONDS);
|
|
|
} else {
|
|
|
// 执行时间超过 1 s 的任务,超时检测最小颗粒度为 1 s
|
|
|
- timeoutCheckScheduledFuture = workerRuntime.getExecutorManager().getLightweightTaskStatusCheckExecutor().scheduleAtFixedRate(new RunnableWrapper(this::timeoutCheck), instanceInfo.getInstanceTimeoutMS(), 1000L, TimeUnit.MILLISECONDS);
|
|
|
+ timeoutCheckScheduledFuture = workerRuntime.getExecutorManager().getLightweightTaskStatusCheckExecutor().scheduleAtFixedRate(new SafeRunnableWrapper(this::timeoutCheck), instanceInfo.getInstanceTimeoutMS(), 1000L, TimeUnit.MILLISECONDS);
|
|
|
}
|
|
|
} else {
|
|
|
timeoutCheckScheduledFuture = null;
|