Class DistributedDoubleBarrier
- java.lang.Object
-
- org.apache.curator.framework.recipes.barriers.DistributedDoubleBarrier
-
public class DistributedDoubleBarrier extends java.lang.ObjectA double barrier as described in the ZK recipes. Quoting the recipe:
Double barriers enable clients to synchronize the beginning and the end of a computation. When enough processes have joined the barrier, processes start their computation and leave the barrier once they have finished.
-
-
Constructor Summary
Constructors Constructor Description DistributedDoubleBarrier(org.apache.curator.framework.CuratorFramework client, java.lang.String barrierPath, int memberQty)Creates the barrier abstraction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenter()Enter the barrier and block until all members have enteredbooleanenter(long maxWait, java.util.concurrent.TimeUnit unit)Enter the barrier and block until all members have entered or the timeout has elapsedprotected java.util.List<java.lang.String>getChildrenForEntering()voidleave()Leave the barrier and block until all members have leftbooleanleave(long maxWait, java.util.concurrent.TimeUnit unit)Leave the barrier and block until all members have left or the timeout has elapsed
-
-
-
Constructor Detail
-
DistributedDoubleBarrier
public DistributedDoubleBarrier(org.apache.curator.framework.CuratorFramework client, java.lang.String barrierPath, int memberQty)Creates the barrier abstraction.memberQtyis the number of members in the barrier. Whenenter()is called, it blocks until all members have entered. Whenleave()is called, it blocks until all members have left.- Parameters:
client- the clientbarrierPath- path to usememberQty- the number of members in the barrier. NOTE: more thanmemberQtycan enter the barrier.memberQtyis a threshold, not a limit
-
-
Method Detail
-
enter
public void enter() throws java.lang.ExceptionEnter the barrier and block until all members have entered- Throws:
java.lang.Exception- interruptions, errors, etc.
-
enter
public boolean enter(long maxWait, java.util.concurrent.TimeUnit unit) throws java.lang.ExceptionEnter the barrier and block until all members have entered or the timeout has elapsed- Parameters:
maxWait- max time to blockunit- time unit- Returns:
- true if the entry was successful, false if the timeout elapsed first
- Throws:
java.lang.Exception- interruptions, errors, etc.
-
leave
public void leave() throws java.lang.ExceptionLeave the barrier and block until all members have left- Throws:
java.lang.Exception- interruptions, errors, etc.
-
leave
public boolean leave(long maxWait, java.util.concurrent.TimeUnit unit) throws java.lang.ExceptionLeave the barrier and block until all members have left or the timeout has elapsed- Parameters:
maxWait- max time to blockunit- time unit- Returns:
- true if leaving was successful, false if the timeout elapsed first
- Throws:
java.lang.Exception- interruptions, errors, etc.
-
getChildrenForEntering
protected java.util.List<java.lang.String> getChildrenForEntering() throws java.lang.Exception- Throws:
java.lang.Exception
-
-