zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zili Chen <wander4...@gmail.com>
Subject create or setData in transaction?
Date Mon, 29 Jul 2019 03:12:12 GMT
Hi ZooKeepers,

Currently our transaction mechanism supports doing
create/setData/checkExist/delete in transaction. However, taking this
scenario into consideration, we want to put data in path "/path" but
don't know whether the znode exists or not. Let's say we program as
below

if (zk.exist(path)) {
  zk.setData(path, data);
} else {
  zk.create(path, data);
}

if we want to do the check and "put" in transaction, it would be like

zk.multi(Op.check(path), Op.setData(path, data));

but we cannot add a "else" branch. ZooKeeper's transaction would all
success or fail.

Is there any way to do an "if-else" transaction?

Best,
tison.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message