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.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值