src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java
/**
     * because jetcd's connection change callback not supported yet, we must
     * loop to test if connect or disconnect event happend or not. It will be changed
     * in the future if we found better choice.
     */
because jetcd's connection change callback not supported yet, we must
loop to test if connect or disconnect event happend or not. It will be changed
in the future if we found better choice.
because jetcd ' s connection change callback not supported yet we must loop to test if connect or disconnect event happend or not . It will be changed in the future if we found better choice .
public void start() {
        if (!started) {
            try {
                Thread connectThread = new Thread(listenableFutureTask);
                connectThread.setName("DubboEtcdClientConnector");
                connectThread.setDaemon(true);
                connectThread.start();
                this.client = listenableFutureTask.get(expirePeriod, TimeUnit.SECONDS);
                this.connectState = isConnected();
                this.started = true;
            } catch (Throwable t) {
                logger.error("Etcd3 server can not be connected in " + expirePeriod + " second! etcd3 address: " + endPoints(url.getBackupAddress()), t);
            }
            try {
                int retry = 3;
                this.future = reconnectNotify.scheduleWithFixedDelay(new Runnable() {
                    @Override
                    public void run() {
                        boolean state = isConnected();
                        if (state != connectState) {
                            int notifyState = state ? StateListener.CONNECTED : StateListener.DISCONNECTED;
                            if (connectionStateListener != null) {
                                connectionStateListener.stateChanged(getClient(), notifyState);
                            }
                            connectState = state;
                        }
                    }
                }, retry, retry, TimeUnit.SECONDS);
            } catch (Throwable t) {
                logger.error("monitor reconnect status failed.", t);
            }
        }
    }
public void start ( ) { if ( ! started ) { try { Thread connectThread = new Thread ( listenableFutureTask ) ; connectThread . setName ( "DubboEtcdClientConnector" ) ; connectThread . setDaemon ( true ) ; connectThread . start ( ) ; this . client = listenableFutureTask . get ( expirePeriod , TimeUnit . SECONDS ) ; this . connectState = isConnected ( ) ; this . started = true ; } catch ( Throwable t ) { logger . error ( "Etcd3 server can not be connected in " + expirePeriod + " second! etcd3 address: " + endPoints ( url . getBackupAddress ( ) ) , t ) ; } try { int retry = 3 ; this . future = reconnectNotify . scheduleWithFixedDelay ( new Runnable ( ) { @ Override public void run ( ) { boolean state = isConnected ( ) ; if ( state != connectState ) { int notifyState = state ? StateListener . CONNECTED : StateListener . DISCONNECTED ; if ( connectionStateListener != null ) { connectionStateListener . stateChanged ( getClient ( ) , notifyState ) ; } connectState = state ; } } } , retry , retry , TimeUnit . SECONDS ) ; } catch ( Throwable t ) { logger . error ( "monitor reconnect status failed." , t ) ; } } }
because jetcd's connection change callback not supported yet, we must
 loop to test if connect or disconnect event happend or not.
because jetcd ' s connection change callback not supported yet we must loop to test if connect or disconnect event happend or not .