On Sat, Aug 17, 2019 at 4:01 PM Jordan Zimmerman <jor...@jordanzimmerman.com> wrote:
> > > ... > > I don't understand that. Watches can be set in a multi. > > Not in the public API: > https://github.com/apache/zookeeper/blob/master/zookeeper-server/src/main/java/org/apache/zookeeper/Op.java > - is it supported in the back-end? > Who designed that mess?!? Seriously, looking back at the API, I vaguely remember punting the question of watches based on the complexity of setting them cleanly. Getting watches out of a multi would be a worthy improvement. > ...> > > I don't understand that, either. But this time I just don't understand > what you are suggesting and how it helps. > > The standard lock recipe creates an ephemeral-sequential node. Once your > node (with its sequence number) is returned you call getChildren() to see > if you have the lowest numbered node. The lowest numbered node is defined > to be the lock holder (or leader, etc.). This requires two round trips. Hmm... well looking at the directory in the same operation as the create sequential should be easy. > It would be nice to consolidate this into 1 API call. Further, if you're > not the lowest numbered node, you must set a watch on the node that > precedes you so you know when to check again. Setting the watch on the preceding node will require the second call no matter what because we won't know which know to watch until we get the list back again. > This is all very cumbersome to do in client code (thus Curator). Maybe > there's a way to specify this entire behavior in a multi call. > Not all of it. At least not that I understand. And I don't see a big win for the multi in the first operation other than saving a round-trip which is nice, but not a massive win.