Skip to content

Instantly share code, notes, and snippets.

@mindreframer
Created February 2, 2011 10:53
Show Gist options
  • Save mindreframer/807542 to your computer and use it in GitHub Desktop.
Save mindreframer/807542 to your computer and use it in GitHub Desktop.
zookeeper testing script
######### installing zookeeper from github
git clone https://github.com/twitter/zookeeper.git
gem uninstall zookeeper
gem install echoe
cd zookeeper
rake package
cd pkg
gem install zookeeper-0.4.2.gem
######### ruby code
require 'zookeeper'
ZK = Zookeeper.new('192.168.2.93:2181, 192.168.2.94:2181, 192.168.2.95:2181')
def set_callback(path)
wcb = Zookeeper::WatcherCallback.new do
puts "callback fired for #{path}"
new_value = ZK.get(:path => path)[:data]
puts "value changed to #{new_value}"
set_callback(path)
end
ZK.stat(:path => path, :watcher => wcb)
end
#ZK.set_debug_level(Zookeeper::ZOO_LOG_LEVEL_DEBUG)
set_callback('/test')
ZK.set(:path => '/test', :data => '60')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment