Skip to content

Toady00/jruby-zk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JRuby Zk

Gem Version

Another ZooKeeper Wrapper

JRuby Zk requires all the jar files for using ZooKeeper from JRuby.

Note about version

The version of this gem will reflect the version of zookeeper bundled with it. So if you are using v3.4.5 of this gem, then you are using v3.4.5 of zookeeper.

Installation

Add this line to your application's Gemfile:

gem 'jruby-zk'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jruby-zk

Usage

require 'jruby-zk'
java_import org.apache.zookeeper.ZooKeeper

That's it. You now have access to ZooKeeper.

Simple Example

require 'jruby-zk'
java_import org.apache.zookeeper.ZooKeeper

class DummyWatcher
  include org.apache.zookeeper.Watcher
end

watcher = DummyWatcher.new

zk = ZooKeeper.new('192.168.123.20:2181', 10000, watcher)

zk.session_id      #=> 90002156548456448
zk.session_timeout #=> 10000
zk.state.to_s      #=> "CONNECTED"

acl = Java::OrgApacheZookeeper::ZooDefs::Ids::OPEN_ACL_UNSAFE
create_mode = Java::OrgApacheZookeeper::CreateMode::PERSISTENT

zk.create('/zoo_test', nil, acl, create_mode) #=> "/zoo_test"
zk.getChildren('/', false).to_a               #=> ["zoo_test", "zookeeper"]
zk.delete('/zoo_test', -1)                    #=> nil
zk.get_children('/', false).to_a              #=> ["zookeeper"]

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Simple wrapper around ZooKeeper Jars for JRuby

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages