Class DistributedDoubleBarrier
java.lang.Object
org.apache.curator.framework.recipes.barriers.DistributedDoubleBarrier
A 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
ConstructorsConstructorDescriptionDistributedDoubleBarrier(CuratorFramework client, String barrierPath, int memberQty) Creates the barrier abstraction. -
Method Summary
Modifier and TypeMethodDescriptionvoidenter()Enter the barrier and block until all members have enteredbooleanEnter the barrier and block until all members have entered or the timeout has elapsedvoidleave()Leave the barrier and block until all members have leftbooleanLeave the barrier and block until all members have left or the timeout has elapsed
-
Constructor Details
-
DistributedDoubleBarrier
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 Details
-
enter
Enter the barrier and block until all members have entered- Throws:
Exception- interruptions, errors, etc.
-
enter
Enter 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:
Exception- interruptions, errors, etc.
-
leave
Leave the barrier and block until all members have left- Throws:
Exception- interruptions, errors, etc.
-
leave
Leave 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:
Exception- interruptions, errors, etc.
-
getChildrenForEntering
- Throws:
Exception
-