Utilities

Test Server

In the curator-test sub-model the TestingServer class is provided. This class creates a local, in-process ZooKeeper server that can be used for testing.

Test Cluster

In the curator-test sub-model the TestingCluster class is provided. This class creates an internally running ensemble of ZooKeeper servers.

ZKPaths

Various static methods to help with using ZooKeeper ZNode paths:

  • getNodeFromPath: Given a full path, return the node name. i.e. "/one/two/three" will return "three"
  • mkdirs: Make sure all the nodes in the path are created.
  • getSortedChildren: Return the children of the given path sorted by sequence number
  • makePath: Given a parent path and a child node, create a combined full path

Locker

Curator's Locker uses Java 7's try-with-resources feature to making using Curator locks safer:

InterProcessMutex mutex = new InterProcessMutex(...) // or any InterProcessLock
try ( Locker locker = new Locker(mutex, maxTimeout, unit) )
{
   // do work
}

BlockingQueueConsumer

See: DistributedQueue and DistributedPriorityQueue

A queue consumer that provides behavior similar to a the JDK's BlockingQueue.

QueueSharder

Due to limitations in ZooKeeper's transport layer, a single queue will break if it has more than 10K-ish items in it. This class provides a facade over multiple distributed queues. It monitors the queues and if any one of them goes over a threshold, a new queue is added. Puts are distributed amongst the queues.

WatcherRemoveCuratorFramework

Curator has a utility that makes it easy to set watchers and remove them at a later date. It is used for all Curator recipes. From your CuratorFramework instance, call newWatcherRemoveCuratorFramework(). When using this proxy instance any watchers that are set are recorded. You can then call removeWatchers() to remove those watchers. See the Curator source code for usage details.