|
|
@ -1,12 +1,12 @@
|
|
|
|
package cn.hippo4j.starter.remote;
|
|
|
|
package cn.hippo4j.starter.remote;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hippo4j.starter.core.ShutdownExecuteException;
|
|
|
|
import cn.hippo4j.starter.core.ShutdownExecuteException;
|
|
|
|
|
|
|
|
import cn.hippo4j.starter.event.ApplicationCompleteEvent;
|
|
|
|
import cn.hippo4j.starter.toolkit.thread.ThreadFactoryBuilder;
|
|
|
|
import cn.hippo4j.starter.toolkit.thread.ThreadFactoryBuilder;
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
|
import org.springframework.context.ApplicationListener;
|
|
|
|
import org.springframework.context.ApplicationListener;
|
|
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
@ -23,7 +23,7 @@ import static cn.hippo4j.common.constant.Constants.HEALTH_CHECK_INTERVAL;
|
|
|
|
* @date 2021/12/8 20:19
|
|
|
|
* @date 2021/12/8 20:19
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
public abstract class AbstractHealthCheck implements ServerHealthCheck, InitializingBean, ApplicationListener<ContextRefreshedEvent> {
|
|
|
|
public abstract class AbstractHealthCheck implements ServerHealthCheck, InitializingBean, ApplicationListener<ApplicationCompleteEvent> {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Health status
|
|
|
|
* Health status
|
|
|
@ -36,7 +36,7 @@ public abstract class AbstractHealthCheck implements ServerHealthCheck, Initiali
|
|
|
|
private volatile boolean clientShutdownHook = false;
|
|
|
|
private volatile boolean clientShutdownHook = false;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Spring context init complete
|
|
|
|
* Spring context init complete. TODO: Why this
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private boolean contextInitComplete = false;
|
|
|
|
private boolean contextInitComplete = false;
|
|
|
|
|
|
|
|
|
|
|
@ -136,12 +136,8 @@ public abstract class AbstractHealthCheck implements ServerHealthCheck, Initiali
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
|
|
public void onApplicationEvent(ApplicationCompleteEvent event) {
|
|
|
|
synchronized (ServerHealthCheck.class) {
|
|
|
|
|
|
|
|
if (event.getApplicationContext().getParent() == null) {
|
|
|
|
|
|
|
|
contextInitComplete = true;
|
|
|
|
contextInitComplete = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|