java.io.Closeable, java.lang.AutoCloseable, SharedValueReaderpublic class SharedValue extends java.lang.Object implements java.io.Closeable, SharedValueReader
| Modifier | Constructor | Description |
|---|---|---|
|
SharedValue(org.apache.curator.framework.CuratorFramework client,
java.lang.String path,
byte[] seedValue) |
|
protected |
SharedValue(org.apache.curator.framework.WatcherRemoveCuratorFramework client,
java.lang.String path,
byte[] seedValue,
org.apache.curator.framework.api.CuratorWatcher watcher) |
| Modifier and Type | Method | 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,
java.lang.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 createdprotected SharedValue(org.apache.curator.framework.WatcherRemoveCuratorFramework client,
java.lang.String path,
byte[] seedValue,
org.apache.curator.framework.api.CuratorWatcher watcher)
public byte[] getValue()
SharedValueReadergetValue in interface SharedValueReaderpublic VersionedValue<byte[]> getVersionedValue()
SharedValueReadergetVersionedValue in interface SharedValueReaderpublic void setValue(byte[] newValue)
throws java.lang.Exception
newValue - new valuejava.lang.Exception - ZK errors, interruptions, etc.@Deprecated
public boolean trySetValue(byte[] newValue)
throws java.lang.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 valuejava.lang.Exception - ZK errors, interruptions, etc.public boolean trySetValue(VersionedValue<byte[]> previous, byte[] newValue) throws java.lang.Exception
getValue().newValue - the new value to attemptgetValue() will return the updated valuejava.lang.Exception - ZK errors, interruptions, etc.public org.apache.curator.framework.listen.ListenerContainer<SharedValueListener> getListenable()
getListenable in interface SharedValueReaderpublic void start()
throws java.lang.Exception
close() when you are
finished with the shared valuejava.lang.Exception - ZK errors, interruptions, etc.public void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.