线程“main”中的异常org.apache.zookeeper.KeeperException $ ConnectionLossException:KeeperErrorCode = ConnectionLoss for

时间:2013-07-21 19:32:53

标签: apache-zookeeper

我正在为Leader选举尝试一个简单的zookeeper示例,我总是收到错误,服务器无法启动。这是我的代码:

public LeaderElection() throws IOException, InterruptedException, KeeperException {
    setZk(new ZooKeeper("localhost", TIMEOUT, this));

    /* This call gives the problem */
    Stat s = getZk().exists(MASTER, this);

    if (s == null) {
        getZk().create(MASTER, "This node is used for election.".getBytes(),
                ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    }
    //wait till SyncConnected Signal is received in process method.
    latch.await();

    setNodePath(getZk().create(MASTER + NODE, null /*no data yet*/,
            ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL));
}

exists()来电时我收到错误:

  

线程“main”中的异常org.apache.zookeeper.KeeperException $ ConnectionLossException:KeeperErrorCode = ConnectionLoss for

请让我知道我错过了什么。我使用的是zk版本3.4.5,以及15K的时间。

0 个答案:

没有答案