2013-05-15 36 views
0

我已经安装了红宝石2.0.0p195及以下的宝石红宝石 - 动物园管理员宝石版本错误的参数数目(3 4)(引发ArgumentError)

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' 

任何人都可以请帮我解决这个问题吗?

+0

你能分享一些代码吗? – draxxxeus

+0

需要 'RubyGems的' 需要 '饲养员' Z = Zookeeper.new( “本地主机:2181”)! 如果z.exists( “/应用”:手表=>真) z.create(“/应用程序“:”app root node“,:mode =>:ephemeral) end z.get_children(:path =>”/“) –

回答

0

要求 “RubyGems的”

要求 “ZK”

ZK = ZK.new

ZK.open( '本地主机:2181')做| ZK | 如果!zk.exists?( '/根')

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

使用ZK而不是饲养员宝石开始。它现在工作正常,但不确定上述参数错误的确切解决方案。

0

使用ZK,它更友好,记录更充分。 Zookeeper gem的目的是作为低级驱动程序层,ZK旨在用于应用程序编写。