in dubbo-remoting-extensions/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java [506:546]
public void start() {
if (!started) {
try {
this.client = completableFuture.get(expirePeriod, TimeUnit.SECONDS);
this.connectState = isConnected();
this.started = true;
} catch (Throwable t) {
logger.error("Timeout! etcd3 server can not be connected in : " + expirePeriod + " seconds! url: " + url, t);
completableFuture.whenComplete((c, e) -> {
this.client = c;
if (e != null) {
logger.error("Got an exception when trying to create etcd3 instance, can not connect to etcd3 server, url: " + url, e);
}
});
}
try {
this.future = reconnectNotify.scheduleWithFixedDelay(() -> {
boolean connected = isConnected();
if (connectState != connected) {
int notifyState = connected ? StateListener.CONNECTED : StateListener.DISCONNECTED;
if (connectionStateListener != null) {
try {
if (connected) {
clearKeepAlive();
}
connectionStateListener.stateChanged(getClient(), notifyState);
} finally {
cancelKeepAlive = false;
}
}
connectState = connected;
}
}, DEFAULT_RECONNECT_PERIOD, DEFAULT_RECONNECT_PERIOD, TimeUnit.MILLISECONDS);
} catch (Throwable t) {
logger.error("monitor reconnect status failed.", t);
}
}
}