From c110f4acae82ca80abd93a0cc096a18a3cf0f6d1 Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Mon, 22 Aug 2022 22:36:49 +0800 Subject: [PATCH] Refresh server startup time when recovery from waiting (#11595) --- .../common/lifecycle/ServerLifeCycleManager.java | 7 +++++++ .../dolphinscheduler/server/registry/HeartBeatTask.java | 1 + 2 files changed, 8 insertions(+) diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/lifecycle/ServerLifeCycleManager.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/lifecycle/ServerLifeCycleManager.java index 1e2a93f638..3c625d70e7 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/lifecycle/ServerLifeCycleManager.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/lifecycle/ServerLifeCycleManager.java @@ -24,6 +24,12 @@ public class ServerLifeCycleManager { private static volatile ServerStatus serverStatus = ServerStatus.RUNNING; + private static long serverStartupTime = System.currentTimeMillis(); + + public static long getServerStartupTime() { + return serverStartupTime; + } + public static boolean isRunning() { return serverStatus == ServerStatus.RUNNING; } @@ -61,6 +67,7 @@ public class ServerLifeCycleManager { if (serverStatus != ServerStatus.WAITING) { throw new ServerLifeCycleException("The current server status is not waiting, cannot recover form waiting"); } + serverStartupTime = System.currentTimeMillis(); serverStatus = ServerStatus.RUNNING; } diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/HeartBeatTask.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/HeartBeatTask.java index b146a25482..495d48e342 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/HeartBeatTask.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/HeartBeatTask.java @@ -74,6 +74,7 @@ public class HeartBeatTask implements Runnable { if (!ServerLifeCycleManager.isRunning()) { return; } + heartBeat.setStartupTime(ServerLifeCycleManager.getServerStartupTime()); // update waiting task count heartBeat.setWorkerWaitingTaskCount(workerWaitingTaskCount);