Ruby
ruby zookeeper
'김용환'
2017. 2. 7. 10:58
ruby 공부차, ruby에서 zookeeper 클라이언트(https://github.com/zk-ruby/zookeeper)를 사용한 예시이다.
require 'json'
require 'zookeeper'
@zookeeper = Zookeeper.new("zk1.plus.google.com:2181")
@root_key = "redis"
@zookeeper.get_children(:path => @root_key).tap do |node|
queue = node[:children]
while ! queue.empty? do
children_path = queue.shift
child_node = @zookeeper.get_children(:path => @root_key + "/" + children_path)
children_queue = child_node[:children]
........
end
end