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
|
VersionedValue<byte[]> |
getVersionedValue()
Return the current version and value
|
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)
Deprecated.
use
trySetValue(VersionedValue, byte[]) for stronger atomicity
guarantees. Even if this object's internal state is up-to-date, the caller has no way to
ensure that they've read the most recently seen value. |
boolean |
trySetValue(VersionedValue<byte[]> previous,
byte[] newValue)
Changes the shared value only if its value has not changed since the version specified by
newValue.
|
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 VersionedValue<byte[]> getVersionedValue()
SharedValueReadergetVersionedValue in interface SharedValueReaderpublic void setValue(byte[] newValue)
throws Exception
newValue - new valueException - ZK errors, interruptions, etc.@Deprecated public boolean trySetValue(byte[] newValue) throws Exception
trySetValue(VersionedValue, byte[]) for stronger atomicity
guarantees. Even if this object's internal state is up-to-date, the caller has no way to
ensure that they've read the most recently seen value.getValue().newValue - the new value to attemptgetValue() will return the updated valueException - ZK errors, interruptions, etc.public boolean trySetValue(VersionedValue<byte[]> previous, 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–2018 The Apache Software Foundation. All rights reserved.