0

我已经安装了 ruby​​ 2.0.0p195 和以下 gem

gem install net-ssh

gem install rdoc

gem install zookeeper

Ruby Zookeeper client installed successfully (ver - 1.4.4)

但是当我执行示例 ruby​​ 脚本来检查节点是否存在并在 zookeeper 上创建节点时:

require 'rubygems'
require 'zookeeper'

z = Zookeeper.new("localhost:2181")
if !z.exists("/app", :watch => true)
        z.create("/app","app root node",:mode => :ephemeral)
end
z.get_children(:path => "/")

...它引发以下错误。

zookeeper-1.4.4/lib/zookeeper/continuation.rb:172:in `zkrb_exists': wrong number of arguments (3 for 4) (ArgumentError)
    from .rvm/gems/ruby-2.0.0-p195/gems/zookeeper-1.4.4/lib/zookeeper/continuation.rb:172:in `submit'
    from .rvm/gems/ruby-2.0.0-p195/gems/zookeeper-1.4.4/ext/c_zookeeper.rb:303:in `submit_pending_calls'
    from .rvm/gems/ruby-2.0.0-p195/gems/zookeeper-1.4.4/ext/c_zookeeper.rb:261:in `event_thread_body'

谁能帮我解决这个问题?

4

2 回答 2

0

需要“红宝石”

需要“zk”

zk = ZK.new

ZK.open('localhost:2181') 做 |zk| 如果 !zk.exists?('/root')

   zk.create("/root", :data => "foo")

结尾

结尾

开始使用 zk 而不是 zookeeper gem。它现在工作正常,但不确定上述参数错误的确切解决方案。

于 2013-05-16T19:33:23.360 回答
0

使用 ZK,它更加友好和有据可查。Zookeeper gem 旨在用作低级驱动程序层,ZK 旨在用于应用程序编写。

于 2013-05-17T17:24:12.050 回答