Browse Source

Fix the waiting strategy cannot recovery if the serverstate is already in running (#12651)

3.2.0-release
Wenjun Ruan 2 years ago committed by GitHub
parent
commit
9e0c9af1a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/lifecycle/ServerLifeCycleManager.java
  2. 1
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterWaitingStrategy.java

18
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;

1
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 {

Loading…
Cancel
Save