On Tue, Dec 21, 2010 at 1:30 PM, Henry Robinson <[email protected]> wrote:
> This is a more complicated requirement, and not something that can be done
> right now with Zookeeper even in a single operation on a single znode. The
> only conditional operations are updates.
Actually, creates and deletes are conditional also. Creates are conditional
on the file
not existing previously and deletes can accept a version number.
> Designing an API to support three
> different kinds of operation would also be more complicated, and the
> implementation would be trickier.
>
This is definitely true. Conceptually it is the same thing, but practically
building a usable API is
a bit tricky. Using a builder style would work, though. For example:
Zookeeper zk = ...;
zk.transaction()
.create("/foobar")
.update("/pig", data, version)
.delete("/dog"", otherVersion)
.commit()
Another option would be to pass a list of operations which can be one of
Create, Update or delete.