Class DistributedBarrier


  • 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 Summary

      Constructors 
      Constructor Description
      DistributedBarrier​(org.apache.curator.framework.CuratorFramework client, java.lang.String barrierPath)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DistributedBarrier

        public DistributedBarrier​(org.apache.curator.framework.CuratorFramework client,
                                  java.lang.String barrierPath)
        Parameters:
        client - client
        barrierPath - path to use as the barrier
    • Method Detail

      • setBarrier

        public void setBarrier()
                        throws java.lang.Exception
        Utility to set the barrier node
        Throws:
        java.lang.Exception - errors
      • removeBarrier

        public void removeBarrier()
                           throws java.lang.Exception
        Utility to remove the barrier node
        Throws:
        java.lang.Exception - errors
      • waitOnBarrier

        public void waitOnBarrier()
                           throws java.lang.Exception
        Blocks until the barrier node comes into existence
        Throws:
        java.lang.Exception - errors
      • waitOnBarrier

        public boolean waitOnBarrier​(long maxWait,
                                     java.util.concurrent.TimeUnit unit)
                              throws java.lang.Exception
        Blocks until the barrier no longer exists or the timeout elapses
        Parameters:
        maxWait - max time to block
        unit - time unit
        Returns:
        true if the wait was successful, false if the timeout elapsed first
        Throws:
        java.lang.Exception - errors