public class ZookeeperMetadataStore extends java.lang.Object implements ListenableMetadataStore, org.springframework.context.SmartLifecycle
ListenableMetadataStore based on a Zookeeper node.
Values are stored in the children node, the names of which are stored as keys.| Constructor and Description |
|---|
ZookeeperMetadataStore(org.apache.curator.framework.CuratorFramework client) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(MetadataStoreListener listener)
Registers a listener with the metadata store
|
java.lang.String |
get(java.lang.String key)
Reads a value for the given key from this MetadataStore.
|
java.lang.String |
getPath(java.lang.String key) |
int |
getPhase() |
java.lang.String |
getRoot() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
put(java.lang.String key,
java.lang.String value)
Writes a key value pair to this MetadataStore.
|
java.lang.String |
putIfAbsent(java.lang.String key,
java.lang.String value)
Atomically insert the key into the store.
|
java.lang.String |
remove(java.lang.String key)
Remove a value for the given key from this MetadataStore.
|
void |
removeListener(MetadataStoreListener callback)
Unregisters a listener
|
boolean |
replace(java.lang.String key,
java.lang.String oldValue,
java.lang.String newValue)
Atomically replace the value for the key in the store if the old
value matches the oldValue argument.
|
void |
setAutoStartup(boolean autoStartup) |
void |
setEncoding(java.lang.String encoding)
Encoding to use when storing data in ZooKeeper
|
void |
setPhase(int phase) |
void |
setRoot(java.lang.String root)
Root node - store entries are children of this node.
|
void |
start() |
void |
stop() |
void |
stop(java.lang.Runnable callback) |
public ZookeeperMetadataStore(org.apache.curator.framework.CuratorFramework client)
public void setEncoding(java.lang.String encoding)
encoding - encoding as textpublic void setRoot(java.lang.String root)
root - encoding as textpublic java.lang.String getRoot()
public void setAutoStartup(boolean autoStartup)
public void setPhase(int phase)
public java.lang.String putIfAbsent(java.lang.String key,
java.lang.String value)
ConcurrentMetadataStoreputIfAbsent in interface ConcurrentMetadataStorekey - The key.value - The value.public boolean replace(java.lang.String key,
java.lang.String oldValue,
java.lang.String newValue)
ConcurrentMetadataStorereplace in interface ConcurrentMetadataStorekey - The key.oldValue - The old value.newValue - The new value.public void addListener(MetadataStoreListener listener)
ListenableMetadataStoreaddListener in interface ListenableMetadataStorelistener - the callback to be registeredpublic void removeListener(MetadataStoreListener callback)
ListenableMetadataStoreremoveListener in interface ListenableMetadataStorecallback - the callback to be unregisteredpublic void put(java.lang.String key,
java.lang.String value)
MetadataStoreput in interface MetadataStorekey - The key.value - The value.public java.lang.String get(java.lang.String key)
MetadataStoreget in interface MetadataStorekey - The key.public java.lang.String remove(java.lang.String key)
MetadataStoreremove in interface MetadataStorekey - The key.public java.lang.String getPath(java.lang.String key)
public boolean isAutoStartup()
isAutoStartup in interface org.springframework.context.SmartLifecyclepublic void start()
start in interface org.springframework.context.Lifecyclepublic void stop()
stop in interface org.springframework.context.Lifecyclepublic void stop(java.lang.Runnable callback)
stop in interface org.springframework.context.SmartLifecyclepublic boolean isRunning()
isRunning in interface org.springframework.context.Lifecyclepublic int getPhase()
getPhase in interface org.springframework.context.PhasedgetPhase in interface org.springframework.context.SmartLifecycle