Package com.yahoo.vespa.curator.recipes
Class CuratorCounter
- java.lang.Object
-
- com.yahoo.vespa.curator.recipes.CuratorCounter
-
public class CuratorCounter extends Object
A distributed atomic counter.- Author:
- Ulf Lilleengen
-
-
Constructor Summary
Constructors Constructor Description CuratorCounter(Curator curator, com.yahoo.path.Path 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 foradd(long)
with 1long
previous()
Convenience method foradd(long)
with -1void
set(long current)
String
toString()
-
-
-
Constructor Detail
-
CuratorCounter
public CuratorCounter(Curator curator, com.yahoo.path.Path counterPath)
-
-
Method Detail
-
next
public long next()
Convenience method foradd(long)
with 1
-
previous
public long previous()
Convenience method foradd(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)
-
-