public class SharedValue extends Object implements Closeable, SharedValueReader
| Constructor and Description |
|---|
SharedValue(org.apache.curator.framework.CuratorFramework client,
String path,
byte[] seedValue) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
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 createdpublic byte[] getValue()
SharedValueReadergetValue in interface SharedValueReaderpublic void setValue(byte[] newValue)
throws Exception
newValue - new valueException - ZK errors, interruptions, etc.public boolean trySetValue(byte[] newValue)
throws Exception
getValue().newValue - the new value to attemptgetValue() will return the updated valueException - ZK errors, interruptions, etc.public org.apache.curator.framework.listen.ListenerContainer<SharedValueListener> getListenable()
getListenable in interface SharedValueReaderpublic void start()
throws Exception
close() when you are
finished with the shared valueException - ZK errors, interruptions, etc.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2011-2014 The Apache Software Foundation. All Rights Reserved.