Transactions ZooKeeper java客户端代码在使用zkClient.multi()时挂起
我想要的是: 我希望能够使用ZooKeeper的事务 我希望他们能真正完成 现在,我首先尝试使用Apache nee Netflix Curator库,但在以下示例中执行类似的事务时:Transactions ZooKeeper java客户端代码在使用zkClient.multi()时挂起,transactions,freeze,apache-zookeeper,apache-curator,Transactions,Freeze,Apache Zookeeper,Apache Curator,我想要的是: 我希望能够使用ZooKeeper的事务 我希望他们能真正完成 现在,我首先尝试使用Apache nee Netflix Curator库,但在以下示例中执行类似的事务时: curator.inTransaction().create().forPath(path, data) .and().commit(); 我意识到交易中只有一项,所以txn是不必要的,但我尽量让事情简单化。所以我想我应该使用原始ZooKeeper API编写一个更完整的测试场景 final Cou
curator.inTransaction().create().forPath(path, data)
.and().commit();
我意识到交易中只有一项,所以txn是不必要的,但我尽量让事情简单化。所以我想我应该使用原始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)));
至于zookeeper服务器,它是作为单个节点运行的,因此不应该与其他节点发生冲突/foo从未出现在树上-使用zooinspector查看它。如果我在没有事务的情况下使用ZK,那么一切都可以正常工作。我在网上搜寻,没有发现任何相关信息。我是不是遗漏了一些明显的东西?结果是你必须使用ZooKeeper>=3.4,否则你会有糟糕的一天。ZooKeeper 3.3在给定事务时只会挂断,什么也不做。结果表明,您必须使用ZooKeeper>=3.4,否则您将度过糟糕的一天。ZooKeeper 3.3在给定事务时只会挂断,什么也不做
EVENT! WatchedEvent state:SyncConnected type:None path:null
CREATING