我是靠谱客的博主 有魅力白开水,最近开发中收集的这篇文章主要介绍zookeeper-negotiated session timeout,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

  in zookeeper ,during certain io pressure,the client will try to reconnect to quorum.after that,the quorum peer will return a new session timeout (akka negotiatedSessionTimeout) to former,then client will recompulate the real connTimeout and readTimeout from the response .the negotiatedSessionTimeout is  a safe threshold which is bound to a window between ([minSessionTimeout,maxSessionTimeout]).

  that means if u first use a self-defined sesion timeout to connect to a zookeeper quorum,only the first time thi s timeout is effect to yourself.



   quorum side:

negotiatedSessionTimeout=[minSessionTimeout,maxSessionTimeout]

   client side:

readTimeout = negotiatedSessionTimeout * 2 / 3; //-here is same as in constructor
connectTimeout = negotiatedSessionTimeout / hostProvider.size();

 

  but the diferences in this case between 3.4.3 and 3.5  are huge,

3.4.3 QuorumPeer

    
    /** minimum session timeout in milliseconds */
    public int getMinSessionTimeout() {
        return minSessionTimeout == -1 ? tickTime * 2 : minSessionTimeout;
    }

    /** minimum session timeout in milliseconds */
    public void setMinSessionTimeout(int min) {
        LOG.info("minSessionTimeout set to " + min);
        this.minSessionTimeout = min;
    }

    /** maximum session timeout in milliseconds */
    public int getMaxSessionTimeout() {
        return maxSessionTimeout == -1 ? tickTime * 20 : maxSessionTimeout;
    }

 

 

3.5 QuorumPeerConf#parseProperties()

        minSessionTimeout = minSessionTimeout == -1 ? tickTime * 2 : minSessionTimeout;
        maxSessionTimeout = maxSessionTimeout == -1 ? tickTime * 20 : maxSessionTimeout;

 

  they are the same effective though with changes

 

conclusion

1.client session timeout will be reset after retry to connect quorum

2.the sessionTimeout finally will be divided to connectTimeout and readTimeout,so the retry mechanism will really implement the 'restrict timeout' meaning.

3.the return negotiatedSessionTimeout will be minSessionTimeout if your self-defined sessionTimeout less than it;else will be max one if your sessionTimeout bigger than max;else the same as yours.

  so by default ,if u set 2000 ms for one tick,then the returned timeout will be 20 ticks(40000 ms) if u give one larger than max(20 ticks) .this case is usually happened in general.

 

最后

以上就是有魅力白开水为你收集整理的zookeeper-negotiated session timeout的全部内容,希望文章能够帮你解决zookeeper-negotiated session timeout所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(31)

评论列表共有 0 条评论

立即
投稿
返回
顶部