Class CuratorCounter

java.lang.Object
com.yahoo.vespa.curator.recipes.CuratorCounter

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

    • CuratorCounter

      public CuratorCounter(Curator curator, com.yahoo.path.Path counterPath)
  • Method Details

    • 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)
    • toString

      public String toString()
      Overrides:
      toString in class Object