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

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

问题描述

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

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)

推荐答案

在此调用中: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.

希望这可以解决您的问题

Hope this will solve your problem

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

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