Class CuratorCounter


  • public class CuratorCounter
    extends Object
    A distributed atomic counter.
    Author:
    Ulf Lilleengen
    • Constructor Detail

      • CuratorCounter

        public CuratorCounter​(Curator curator,
                              com.yahoo.path.Path 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:
        IllegalStateException - if addition fails
      • set

        public void set​(long current)
      • get

        public long get()
      • initialize

        public void initialize​(long value)