public class DistributedBarrier
extends java.lang.Object
A barrier as described in the ZK recipes. Quoting the recipe:
Distributed systems use barriers to block processing of a set of nodes until a condition is met at which time all the nodes are allowed to proceed
Constructor and Description |
---|
DistributedBarrier(CuratorFramework client,
java.lang.String barrierPath) |
Modifier and Type | Method and Description |
---|---|
void |
removeBarrier()
Utility to remove the barrier node
|
void |
setBarrier()
Utility to set the barrier node
|
void |
waitOnBarrier()
Blocks until the barrier node comes into existence
|
boolean |
waitOnBarrier(long maxWait,
java.util.concurrent.TimeUnit unit)
Blocks until the barrier no longer exists or the timeout elapses
|
public DistributedBarrier(CuratorFramework client, java.lang.String barrierPath)
client
- clientbarrierPath
- path to use as the barrierpublic void setBarrier() throws java.lang.Exception
java.lang.Exception
- errorspublic void removeBarrier() throws java.lang.Exception
java.lang.Exception
- errorspublic void waitOnBarrier() throws java.lang.Exception
java.lang.Exception
- errorspublic boolean waitOnBarrier(long maxWait, java.util.concurrent.TimeUnit unit) throws java.lang.Exception
maxWait
- max time to blockunit
- time unitjava.lang.Exception
- errors