`

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.

 

  • 大小: 46 KB
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics