Class CuratorCounter


  • public class CuratorCounter
    extends java.lang.Object
    A distributed atomic counter.
    Since:
    5.1
    Author:
    Ulf Lilleengen
    • Constructor Summary

      Constructors 
      Constructor Description
      CuratorCounter​(Curator curator, java.lang.String counterPath)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long add​(long delta)
      Atomically add and return resulting value.
      long get()  
      void initialize​(long value)  
      long next()
      Convenience method for add(long) with 1
      long previous()
      Convenience method for add(long) with -1
      void set​(long current)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • CuratorCounter

        public CuratorCounter​(Curator curator,
                              java.lang.String counterPath)
    • Method Detail

      • next

        public long next()
        Convenience method for add(long) with 1
      • previous

        public long previous()
        Convenience method for add(long) with -1
      • add

        public long add​(long delta)
        Atomically add and return resulting value.
        Parameters:
        delta - value to add, may be negative
        Returns:
        the resulting value
        Throws:
        java.lang.IllegalStateException - if addition fails
      • set

        public void set​(long current)
      • get

        public long get()
      • initialize

        public void initialize​(long value)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object