• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

使用watch要注意如下的问题

互联网 diligentman 1周前 (02-18) 9次浏览
  • watch是一次性的,当watch被触发然后发送给client后,后面同类的事件是不会再次发送到client了,你要持续的监听只能重新添加watch
  • 因为标准的手表是一次性触发器,并且在获取事件和发送一个新的请求来获取手表之间有延迟,你不能可靠地看到发生在ZooKeeper节点上的每一个变化。准备好处理znode在获取事件和再次设置手表之间多次更改的情况。(你可能并不在乎,但至少意识到这种情况可能会发生。)
  • A watch object, or function/context pair, will only be triggered once for a given notification. For example, if the same watch object is registered for an exists and a getData call for the same file and that file is then deleted, the watch object would only be invoked once with the deletion notification for the file.
  • When you disconnect from a server (for example, when the server fails), you will not get any watches until the connection is reestablished. For this reason session events are sent to all outstanding watch handlers. Use session events to go into a safe mode: you will not be receiving events while disconnected, so your process should act conservatively in that mode.

程序员灯塔
转载请注明原文链接:使用watch要注意如下的问题
喜欢 (0)