-
Notifications
You must be signed in to change notification settings - Fork 435
Utilities
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.
In the curator-test sub-model the TestingCluster
class is provided. This class creates an internally running ensemble of ZooKeeper servers.
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
Utility to ensure that a particular path is created.
The first time it is used, a synchronized call to ZKPaths.mkdirs(ZooKeeper, String)
is made to ensure that the entire path has been created (with an empty byte array if needed). Subsequent calls with the instance are un-synchronized NOPs.
Usage:
EnsurePath ensurePath = new EnsurePath(aFullPathToEnsure);
...
String nodePath = aFullPathToEnsure + "/foo";
ensurePath.ensure(zk); // first time syncs and creates if needed
zk.create(nodePath, ...);
...
ensurePath.ensure(zk); // subsequent times are NOPs
zk.create(nodePath, ...);
NOTE: There's a method in the CuratorFramework class that returns an EnsurePath instance that is namespace aware.
See: DistributedQueue and DistributedPriorityQueue
A queue consumer that provides behavior similar to a the JDK's BlockingQueue.
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.
Reaper
A Utility to delete parent paths of locks, etc. Periodically checks paths added to the reaper. If at check time, there are no children, the path is deleted. Clients should create one Reaper instance per application. Add lock paths to the reaper as needed and the reaper will periodically delete them. Curator's lock recipes will correctly handle parents getting deleted.
ChildReaper
Utility to reap the empty child nodes in a parent node. Periodically calls getChildren() on the node and adds empty nodes to an internally managed Reaper.
NOTE: You should consider using LeaderRunner to run the Reapers as they don't need to run in every client.
A utility for running a task one only one instance in a group. Uses a LeaderSelector internally. When leadership is obtained, the task is signaled to run.
- Curator
- Javadoc
- Coverage Report
- Getting Started
- Examples
- FAQ
- Client
- Framework
-
Recipes
- Leader Latch
- Leader Election
- Shared Reentrant Lock
- Shared Lock
- Shared Reentrant Read Write Lock
- Shared Semaphore
- Multi Shared Lock
- Distributed Queue
- Distributed Id Queue
- Distributed Priority Queue
- Distributed Delay Queue
- Simple Distributed Queue
- Barrier
- Double Barrier
- Shared counter
- Distributed Atomic Long
- Path Cache
- Node Cache
- Utilities – Test Server, Test Cluster, ZKPaths, EnsurePath, QueueSharder, Reaper, ChildReaper
- Tech Notes
- Errors
- Exhibitor Integration
- Extensions
- Logging and Tracing