mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-02 12:17:43 +08:00
Fix the waiting strategy cannot recovery if the serverstate is already in running (#12651)
This commit is contained in:
parent
135d70da09
commit
9957df1c41
@ -18,7 +18,9 @@
|
|||||||
package org.apache.dolphinscheduler.common.lifecycle;
|
package org.apache.dolphinscheduler.common.lifecycle;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class ServerLifeCycleManager {
|
public class ServerLifeCycleManager {
|
||||||
|
|
||||||
@ -52,20 +54,24 @@ public class ServerLifeCycleManager {
|
|||||||
throw new ServerLifeCycleException("The current server is already stopped, cannot change to waiting");
|
throw new ServerLifeCycleException("The current server is already stopped, cannot change to waiting");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverStatus != ServerStatus.RUNNING) {
|
if (serverStatus == ServerStatus.WAITING) {
|
||||||
throw new ServerLifeCycleException("The current server is not at running status, cannot change to waiting");
|
log.warn("The current server is already at waiting status, cannot change to waiting");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
serverStatus = ServerStatus.WAITING;
|
serverStatus = ServerStatus.WAITING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recover from {@link ServerStatus#WAITING} to {@link ServerStatus#RUNNING}.
|
* Recover from {@link ServerStatus#WAITING} to {@link ServerStatus#RUNNING}.
|
||||||
*
|
|
||||||
* @throws ServerLifeCycleException if change failed
|
|
||||||
*/
|
*/
|
||||||
public static synchronized void recoverFromWaiting() throws ServerLifeCycleException {
|
public static synchronized void recoverFromWaiting() throws ServerLifeCycleException {
|
||||||
if (serverStatus != ServerStatus.WAITING) {
|
if (isStopped()) {
|
||||||
throw new ServerLifeCycleException("The current server status is not waiting, cannot recover form waiting");
|
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();
|
serverStartupTime = System.currentTimeMillis();
|
||||||
serverStatus = ServerStatus.RUNNING;
|
serverStatus = ServerStatus.RUNNING;
|
||||||
|
@ -63,7 +63,6 @@ public class MasterWaitingStrategy implements MasterConnectStrategy {
|
|||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
try {
|
try {
|
||||||
ServerLifeCycleManager.toWaiting();
|
ServerLifeCycleManager.toWaiting();
|
||||||
// todo: clear the current resource
|
|
||||||
clearMasterResource();
|
clearMasterResource();
|
||||||
Duration maxWaitingTime = masterConfig.getRegistryDisconnectStrategy().getMaxWaitingTime();
|
Duration maxWaitingTime = masterConfig.getRegistryDisconnectStrategy().getMaxWaitingTime();
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user