com.netflix.curator.framework.recipes.barriers
Class DistributedDoubleBarrier

java.lang.Object
  extended by com.netflix.curator.framework.recipes.barriers.DistributedDoubleBarrier

public class DistributedDoubleBarrier
extends Object

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
DistributedDoubleBarrier(CuratorFramework client, String barrierPath, int memberQty)
          Creates the barrier abstraction.
 
Method Summary
 void enter()
          Enter the barrier and block until all members have entered
 boolean enter(long maxWait, TimeUnit unit)
          Enter the barrier and block until all members have entered or the timeout has elapsed
 void leave()
          Leave the barrier and block until all members have left
 boolean leave(long maxWait, TimeUnit unit)
          Leave the barrier and block until all members have left or the timeout has elapsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributedDoubleBarrier

public DistributedDoubleBarrier(CuratorFramework client,
                                String barrierPath,
                                int memberQty)
Creates the barrier abstraction. memberQty is the number of members in the barrier. When enter() is called, it blocks until all members have entered. When leave() is called, it blocks until all members have left.

Parameters:
client - the client
barrierPath - path to use
memberQty - the number of members in the barrier
Method Detail

enter

public void enter()
           throws Exception
Enter the barrier and block until all members have entered

Throws:
Exception - interruptions, errors, etc.

enter

public boolean enter(long maxWait,
                     TimeUnit unit)
              throws Exception
Enter the barrier and block until all members have entered or the timeout has elapsed

Parameters:
maxWait - max time to block
unit - time unit
Returns:
true if the entry was successful, false if the timeout elapsed first
Throws:
Exception - interruptions, errors, etc.

leave

public void leave()
           throws Exception
Leave the barrier and block until all members have left

Throws:
Exception - interruptions, errors, etc.

leave

public boolean leave(long maxWait,
                     TimeUnit unit)
              throws Exception
Leave the barrier and block until all members have left or the timeout has elapsed

Parameters:
maxWait - max time to block
unit - time unit
Returns:
true if leaving was successful, false if the timeout elapsed first
Throws:
Exception - interruptions, errors, etc.


Copyright © 2012. All Rights Reserved.