Unverified Commit d87d2d80 authored by tswstarplanet's avatar tswstarplanet Committed by GitHub
Browse files

add maxWaitTime config when build zookeeper client (#3133)



* add maxWaitTime config when build zookeeper client

* throw exception when connect zk timeout

* use dedicated exception instead of a generic one

Co-authored-by: default avatardailidong <dailidong66@gmail.com>
Co-authored-by: default avatarqiaozhanwei <qiaozhanwei@outlook.com>
parent a23a3e2d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ public class ZookeeperConfig {
    @Value("${zookeeper.dolphinscheduler.root:/dolphinscheduler}")
    private String dsRoot;

    @Value("${zookeeper.max.wait.time:10000}")
    private int maxWaitTime;

    public String getServerList() {
        return serverList;
    }
@@ -115,4 +118,12 @@ public class ZookeeperConfig {
    public void setDsRoot(String dsRoot) {
        this.dsRoot = dsRoot;
    }

    public int getMaxWaitTime() {
        return maxWaitTime;
    }

    public void setMaxWaitTime(int maxWaitTime) {
        this.maxWaitTime = maxWaitTime;
    }
}
 No newline at end of file
+4 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static org.apache.dolphinscheduler.common.utils.Preconditions.checkNotNull;

@@ -109,7 +110,9 @@ public class ZookeeperOperator implements InitializingBean {
        zkClient = builder.build();
        zkClient.start();
        try {
            zkClient.blockUntilConnected();
            if (!zkClient.blockUntilConnected(zookeeperConfig.getMaxWaitTime(), TimeUnit.MILLISECONDS)) {
                throw new IllegalStateException("Connect zookeeper expire max wait time");
            }
        } catch (final Exception ex) {
            throw new RuntimeException(ex);
        }
+2 −1
Original line number Diff line number Diff line
@@ -27,3 +27,4 @@ zookeeper.quorum=localhost:2181
#zookeeper.retry.base.sleep=100
#zookeeper.retry.max.sleep=30000
#zookeeper.retry.maxtime=10
#zookeeper.max.wait.time=10000
 No newline at end of file