|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.curator.framework.recipes.shared.SharedCount
public class SharedCount
Manages a shared integer. All clients watching the same path will have the up-to-date value of the shared integer (considering ZK's normal consistency guarantees).
| Constructor Summary | |
|---|---|
SharedCount(org.apache.curator.framework.CuratorFramework client,
String path,
int seedValue)
|
|
| Method Summary | |
|---|---|
void |
addListener(SharedCountListener listener)
|
void |
addListener(SharedCountListener listener,
Executor executor)
|
void |
close()
|
int |
getCount()
Return the current value of the count |
void |
removeListener(SharedCountListener listener)
|
void |
setCount(int newCount)
Change the shared count value irrespective of its previous state |
void |
start()
The shared count must be started before it can be used. |
boolean |
trySetCount(int newCount)
Changes the shared count only if its value has not changed since this client last read it. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SharedCount(org.apache.curator.framework.CuratorFramework client,
String path,
int seedValue)
client - the clientpath - the shared path - i.e. where the shared count is storedseedValue - the initial value for the count if/f the path has not yet been created| Method Detail |
|---|
public int getCount()
SharedCountReader
getCount in interface SharedCountReader
public void setCount(int newCount)
throws Exception
newCount - new value
Exception - ZK errors, interruptions, etc.
public boolean trySetCount(int newCount)
throws Exception
getCount().
newCount - the new value to attempt
getCount() will return the updated value
Exception - ZK errors, interruptions, etc.public void addListener(SharedCountListener listener)
addListener in interface org.apache.curator.framework.listen.Listenable<SharedCountListener>
public void addListener(SharedCountListener listener,
Executor executor)
addListener in interface org.apache.curator.framework.listen.Listenable<SharedCountListener>public void removeListener(SharedCountListener listener)
removeListener in interface org.apache.curator.framework.listen.Listenable<SharedCountListener>
public void start()
throws Exception
close() when you are
finished with the shared count
Exception - ZK errors, interruptions, etc.
public void close()
throws IOException
close in interface CloseableIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||