Created
February 2, 2011 10:53
-
-
Save mindreframer/807542 to your computer and use it in GitHub Desktop.
zookeeper testing script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######### 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