This is an automated email from the ASF dual-hosted git repository.
wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 9e0c9af1a5 Fix the waiting strategy cannot recovery if the serverstate
is already in running (#12651)
9e0c9af1a5 is described below
commit 9e0c9af1a5070b6a55750737aff2026233b26952
Author: Wenjun Ruan <[email protected]>
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 4f88ce4787..1c962f2920 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
@@ -64,7 +64,6 @@ public class MasterWaitingStrategy implements
MasterConnectStrategy {
public void disconnect() {
try {
ServerLifeCycleManager.toWaiting();
- // todo: clear the current resource
clearMasterResource();
Duration maxWaitingTime =
masterConfig.getRegistryDisconnectStrategy().getMaxWaitingTime();
try {