What I want:
- I'd like to be able to use transactions with ZooKeeper
- I'd like for them to actually complete
Now I first tried using the Apache (nee Netflix) Curator library, but when following the examples to do a transaction like so:
curator.inTransaction().create().forPath(path, data)
.and().commit();
and it would just get stuck there (I realize there's only one item in the transaction so a txn is unnecessary, but I'm trying to keep things simple). So I figured I'd write a more complete test scenario using the raw ZooKeeper API
final CountDownLatch connect = new CountDownLatch(1);
ZooKeeper z = new ZooKeeper("localhost:2181", 60000, new Watcher() {
@Override
public void process(WatchedEvent arg0) {
System.err.println("EVENT! " + arg0);
connect.countDown();
}
});
List<ACL> acl = ImmutableList.of(new ACL(0777, new Id("world", "anyone")));
connect.await();
System.err.println("CREATING");
z.multi(ImmutableList.of(
Op.create("/foo", "DATA".getBytes(), acl, CreateMode.PERSISTENT)));
It also hangs like a dead man after printing
EVENT! WatchedEvent state:SyncConnected type:None path:null
CREATING
As for the zookeeper server, it's running as a single node, so there are no other nodes it should be quarreling with. /foo never shows up in the tree - using zooinspector to look at it. If I use ZK without transactions, everything works fine. I hunted around the webz and found nothing relevant. Am I missing something obvious?