本文介绍了Zookeeper如何同步集群中的时钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Zookeeper文档:

mtime 上次修改此znode的时间(以纪元为单位).

mtime The time in milliseconds from epoch when this znode was last modified.

我假设Zookeeper以某种方式同步ZK群集中所有节点的(内部)真实时钟,以使时间戳保持一致,而与客户端连接的节点无关.是这样吗?如果是,它如何工作?

I presume that Zookeeper somehow syncs the (internal) real clock of all the nodes in the ZK cluster in order the time stamps to be consistent regardless of the node where the client connects. Is that so? If yes, how does it work?

我发现的是:

ZooKeeper完全不使用实时时间或时钟时间,只是在创建znode和修改znode时将时间戳记放入stat结构中.

ZooKeeper doesn't use real time, or clock time, at all except to put timestamps into the stat structure on znode creation and znode modification.

也就是说,它会在可能的情况下使用逻辑时间,但是并没有说明实际时钟是否已同步.

That is, it uses logical time whenever it's possible, but it doesn't say if real clock is synced or not.

谢谢!

推荐答案

不,实际时钟仅在ctime和mtime中使用.当前的领导者使用实际时钟在请求中设置TxnHeader,然后将其用作zNode的ctime和mtime.

No, the real clock is only used in ctime and mtime. The current leader used the real clock to set a TxnHeader in the request, and then used as the ctime and mtime of zNode.

这篇关于Zookeeper如何同步集群中的时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 08:13