You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ke...@apache.org on 2022/11/02 13:51:16 UTC

[dolphinscheduler] branch 3.1.1-prepare updated: Fix the waiting strategy cannot recovery if the serverstate is already in running (#12651)

This is an automated email from the ASF dual-hosted git repository.

kerwin pushed a commit to branch 3.1.1-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/3.1.1-prepare by this push:
     new 9957df1c41 Fix the waiting strategy cannot recovery if the serverstate is already in running (#12651)
9957df1c41 is described below

commit 9957df1c41ff4f4bd9c96266a0c3b0e851dc3c48
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Wed Nov 2 14:06:01 2022 +0800

    Fix the waiting strategy cannot recovery if the serverstate is already in running (#12651)
---
 .../common/lifecycle/ServerLifeCycleManager.java       | 18 ++++++++++++------
 .../server/master/registry/MasterWaitingStrategy.java  |  1 -
 2 files changed, 12 insertions(+), 7 deletions(-)

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 3c625d70e7..3244205ad5 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
@@ -18,7 +18,9 @@
 package org.apache.dolphinscheduler.common.lifecycle;
 
 import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
 
+@Slf4j
 @UtilityClass
 public class ServerLifeCycleManager {
 
@@ -52,20 +54,24 @@ public class ServerLifeCycleManager {
             throw new ServerLifeCycleException("The current server is already stopped, cannot change to waiting");
         }
 
-        if (serverStatus != ServerStatus.RUNNING) {
-            throw new ServerLifeCycleException("The current server is not at running status, cannot change to waiting");
+        if (serverStatus == ServerStatus.WAITING) {
+            log.warn("The current server is already at waiting status, cannot change to waiting");
+            return;
         }
         serverStatus = ServerStatus.WAITING;
     }
 
     /**
      * Recover from {@link ServerStatus#WAITING} to {@link ServerStatus#RUNNING}.
-     *
-     * @throws ServerLifeCycleException if change failed
      */
     public static synchronized void recoverFromWaiting() throws ServerLifeCycleException {
-        if (serverStatus != ServerStatus.WAITING) {
-            throw new ServerLifeCycleException("The current server status is not waiting, cannot recover form waiting");
+        if (isStopped()) {
+            throw new ServerLifeCycleException("The current server is already stopped, cannot recovery");
+        }
+
+        if (serverStatus == ServerStatus.RUNNING) {
+            log.warn("The current server status is already running, cannot recover form waiting");
+            return;
         }
         serverStartupTime = System.currentTimeMillis();
         serverStatus = ServerStatus.RUNNING;
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterWaitingStrategy.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterWaitingStrategy.java
index 654d96f25b..1079b655f5 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterWaitingStrategy.java
+++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterWaitingStrategy.java
@@ -63,7 +63,6 @@ public class MasterWaitingStrategy implements MasterConnectStrategy {
     public void disconnect() {
         try {
             ServerLifeCycleManager.toWaiting();
-            // todo: clear the current resource
             clearMasterResource();
             Duration maxWaitingTime = masterConfig.getRegistryDisconnectStrategy().getMaxWaitingTime();
             try {