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
ConstructorDescriptionDistributedDoubleBarrier
(CuratorFramework client, String barrierPath, int memberQty) Creates the barrier abstraction. -
Method Summary
Modifier and TypeMethodDescriptionvoid
enter()
Enter the barrier and block until all members have enteredboolean
Enter the barrier and block until all members have entered or the timeout has elapsedvoid
leave()
Leave the barrier and block until all members have leftboolean
Leave the barrier and block until all members have left or the timeout has elapsed
-
Constructor Details
-
DistributedDoubleBarrier
Creates the barrier abstraction.memberQty
is 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 thanmemberQty
can enter the barrier.memberQty
is 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
-