ClientBase.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:https-github.com-apache-zookeeper 作者:
/**
 * Return true if any of the states is achieved
 */
public static boolean waitForServerState(QuorumPeer qp, int timeout,
        String... serverStates) {
    long start = Time.currentElapsedTime();
    while (true) {
        try {
            Thread.sleep(250);
        } catch (InterruptedException e) {
            // ignore
        }
        for (String state : serverStates) {
            if (qp.getServerState().equals(state)) {
                return true;
            }
        }
        if (Time.currentElapsedTime() > start + timeout) {
            return false;
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号