The code bellow let you set the data of a zNode if its data version matches the specified version.
Calling the method "
CuratorFramework::setData
" will initialize the data of a zNode and return a "
Stat
" object.
You will get this error if the zNode doesn't exist in ZooKeeper:
org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /path
You will get this error if the version of the zNode (dataVersion) is incorrect:
org.apache.zookeeper.KeeperException$BadVersionException: KeeperErrorCode = BadVersion for /path
In order for the code bellow to work:
► Make sure to update the "
CONNECT_STRING
" variable with your information.