【问题标题】:Ruby - Zookeeper gem version wrong number of arguments (3 for 4) (ArgumentError)Ruby - Zookeeper gem 版本错误的参数数量(3 为 4)(ArgumentError)
【发布时间】:2013-11-12 04:55:56
【问题描述】:

我已经安装了 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'

谁能帮我解决这个问题?

【问题讨论】:

  • 你能分享一些代码吗?
  • require 'rubygems' require 'zookeeper' z = Zookeeper.new("localhost:2181") if !z.exists("/app", :watch => true) z.create(" /app","app 根节点",:mode => :ephemeral) end z.get_children(:path => "/")

标签: ruby apache-zookeeper


【解决方案1】:

需要“红宝石”

需要“zk”​​p>

zk = ZK.new

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

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

结束

结束

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多