Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A High-Level wrapper for Apache's Zookeeper
branch: dev/async-conv…

This branch is 1 commit ahead, 564 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.yardopts
Gemfile
LICENSE
README.markdown
Rakefile
zk.gemspec

README.markdown

ZK

ZK is a high-level interface to the Apache ZooKeeper server. It is based on the zookeeper gem which is a multi-Ruby low-level driver. Currently MRI 1.8.7 and JRuby are supported, and MRI 1.9.2 is very close to being ready. It is licensed under the MIT license.

This library is heavily used in a production deployment and is actively developed and maintained.

Development is sponsored by Snapfish and has been generously released to the Open Source community by HPDC, L.P.

What is ZooKeeper good for?

ZooKeeper is a multi-purpose tool that is designed to allow you to write code that coordinates many nodes in a cluster. It can be used as a directory service, a configuration database, and can provide cross-cluster locking, leader election, and group membership (to name a few). It presents to the user what looks like a distributed file system, with a few important differences: every node can have children and data, and there is a 1MB limit on data size for any given node. ZooKeeper provides atomic semantics and a simple API for manipulating data in the heirarchy.

One of the most useful aspects of ZooKeeper is the ability to set "watches" on nodes. This allows one to be notified when a node has been deleted, created, has had a child modified, or had its data modified. The asynchronous nature of these watches enables you to write code that can react to changes in your environment.

ZooKeeper is also (relatively) easy to deploy in a Highly Available configuration, and the clients natively understand the clustering and how to resume a session transparently when one of the cluster nodes goes away.

What does ZK do that the zookeeper gem doesn't?

The zookeeper gem provides a low-level, cross platform library for interfacing with ZooKeeper. While it is full featured, it only handles the basic operations that the driver provides. ZK implements the majority of the recipes in the ZooKeeper documentation, plus a number of other conveniences for a production environment.

ZK provides:

  • a robust lock implementation (both shared and exclusive locks)
  • an extension for the Mongoid ORM to provide advisory locks on mongodb records
  • a leader election implementation with both "leader" and "observer" roles
  • a higher-level interface to the ZooKeeper callback/watcher mechanism than the zookeeper gem provides
  • a simple threadpool implementation
  • a bounded, dynamically-growable (threadsafe) client pool implementation
  • a recursive Find class (like the Find module in ruby-core)
  • unix-like rm_rf and mkdir_p methods (useful for functional testing)

In addition to all of that, I would like to think that the public API the ZK::Client provides is more convenient to use for the common (synchronous) case.

Something went wrong with that request. Please try again.