public class ZookeeperMetadataStore extends Object implements ListenableMetadataStore, SmartLifecycle
ListenableMetadataStore based on a Zookeeper node.
Values are stored in the children node, the names of which are stored as keys.DEFAULT_PHASE| 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
|
String |
get(String key)
Reads a value for the given key from this MetadataStore.
|
String |
getPath(String key) |
int |
getPhase() |
String |
getRoot() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
put(String key,
String value)
Writes a key value pair to this MetadataStore.
|
String |
putIfAbsent(String key,
String value)
Atomically insert the key into the store.
|
String |
remove(String key)
Remove a value for the given key from this MetadataStore.
|
void |
removeListener(MetadataStoreListener callback)
Unregisters a listener
|
boolean |
replace(String key,
String oldValue,
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(String encoding)
Encoding to use when storing data in ZooKeeper
|
void |
setPhase(int phase) |
void |
setRoot(String root)
Root node - store entries are children of this node.
|
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
public ZookeeperMetadataStore(org.apache.curator.framework.CuratorFramework client)
public void setEncoding(String encoding)
encoding - encoding as textpublic void setRoot(String root)
root - encoding as textpublic String getRoot()
public void setAutoStartup(boolean autoStartup)
public void setPhase(int phase)
public String putIfAbsent(String key, String value)
ConcurrentMetadataStoreputIfAbsent in interface ConcurrentMetadataStorekey - The key.value - The value.public boolean replace(String key, String oldValue, 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(String key, String value)
MetadataStoreput in interface MetadataStorekey - The key.value - The value.public String get(String key)
MetadataStoreget in interface MetadataStorekey - The key.public String remove(String key)
MetadataStoreremove in interface MetadataStorekey - The key.public boolean isAutoStartup()
isAutoStartup in interface SmartLifecyclepublic void stop(Runnable callback)
stop in interface SmartLifecyclepublic int getPhase()
getPhase in interface PhasedgetPhase in interface SmartLifecycle