如何在zookeeper中获取路径的创建模式 [英] How to get the create mode of a path in zookeeper

查看:33
本文介绍了如何在zookeeper中获取路径的创建模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在动物园管理员中,我可以使用zookeeper.exists(path,false)来检查路径是否存在.但是如果路径存在,我可以使用女巫方法来获取路径的创建模式吗?(持久或临时)

In zookeeper, I can usezookeeper.exists(path,false)to check if the path exists. But if the path exists, witch method can I use to get the create mode of the path?(Persistent or Ephemeral)

推荐答案

On this call :zookeeper.exists(path,false) ..Zookeeper 服务器将返回一个 Stat 结构.从 Stat 结构中检查属性 "ephemeralOwner" .如果 znode 是临时节点,则这对应于此 znode 所有者的会话 ID.如果不是临时节点,则为零.

On this call :zookeeper.exists(path,false) .. Zookeeper server will return you a Stat structure . From the Stat structure you check the property "ephemeralOwner" . this corresponds to session id of the owner of this znode if the znode is an ephemeral node. If it is not an ephemeral node, it will be zero.

希望这能解决您的问题

这篇关于如何在zookeeper中获取路径的创建模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆