|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.curator.framework.recipes.shared.SharedValue
public class SharedValue
Manages a shared value. All clients watching the same path will have the up-to-date value (considering ZK's normal consistency guarantees).
| Constructor Summary | |
|---|---|
SharedValue(org.apache.curator.framework.CuratorFramework client,
String path,
byte[] seedValue)
|
|
| Method Summary | |
|---|---|
void |
close()
|
org.apache.curator.framework.listen.ListenerContainer<SharedValueListener> |
getListenable()
Returns the listenable |
byte[] |
getValue()
Return the current value of the count |
void |
setValue(byte[] newValue)
Change the shared value value irrespective of its previous state |
void |
start()
The shared value must be started before it can be used. |
boolean |
trySetValue(byte[] newValue)
Changes the shared value 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 SharedValue(org.apache.curator.framework.CuratorFramework client,
String path,
byte[] seedValue)
client - the clientpath - the shared path - i.e. where the shared value is storedseedValue - the initial value for the value if/f the path has not yet been created| Method Detail |
|---|
public byte[] getValue()
SharedValueReader
getValue in interface SharedValueReader
public void setValue(byte[] newValue)
throws Exception
newValue - new value
Exception - ZK errors, interruptions, etc.
public boolean trySetValue(byte[] newValue)
throws Exception
getValue().
newValue - the new value to attempt
getValue() will return the updated value
Exception - ZK errors, interruptions, etc.public org.apache.curator.framework.listen.ListenerContainer<SharedValueListener> getListenable()
getListenable in interface SharedValueReader
public void start()
throws Exception
close() when you are
finished with the shared value
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 | |||||||||