Question

Now I'm developing a ZooKeeper client to watch the change of znode. The znode will be updated from time to time and produces NodeDeleted and NodeCreated event. My client only wants to know the value of znode after NodeCreated. But the problem is that, I will also receive the NodeDeleted event and the watch is only for one time. So I have to call exist(), setData() or getData() to set the watch back on this znode.

Actually I don't care about the data or whether the znode is exist. Is there any way to just set the watch on specified znode? Or should this be the feature of ZooKeeper?

Was it helpful?

Solution

You can set a watch but after each event you need to set a new watch. That means you could miss events between the time your initial watch expired and your next watch is set. To simplify usage, you should check out Apache Curator. The Path Cache recipe would be helpful for your use case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top