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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
stop
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)
ConcurrentMetadataStore
putIfAbsent
in interface ConcurrentMetadataStore
key
- The key.value
- The value.public boolean replace(String key, String oldValue, String newValue)
ConcurrentMetadataStore
replace
in interface ConcurrentMetadataStore
key
- The key.oldValue
- The old value.newValue
- The new value.public void addListener(MetadataStoreListener listener)
ListenableMetadataStore
addListener
in interface ListenableMetadataStore
listener
- the callback to be registeredpublic void removeListener(MetadataStoreListener callback)
ListenableMetadataStore
removeListener
in interface ListenableMetadataStore
callback
- the callback to be unregisteredpublic void put(String key, String value)
MetadataStore
put
in interface MetadataStore
key
- The key.value
- The value.public String get(String key)
MetadataStore
get
in interface MetadataStore
key
- The key.public String remove(String key)
MetadataStore
remove
in interface MetadataStore
key
- The key.public boolean isAutoStartup()
isAutoStartup
in interface SmartLifecycle
public int getPhase()
getPhase
in interface Phased
getPhase
in interface SmartLifecycle