Class ZookeeperMetadataStore
java.lang.Object
org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore
- All Implemented Interfaces:
Lifecycle,Phased,SmartLifecycle,ConcurrentMetadataStore,ListenableMetadataStore,MetadataStore
public class ZookeeperMetadataStore extends Object implements ListenableMetadataStore, SmartLifecycle
Zookeeper-based
ListenableMetadataStore based on a Zookeeper node.
Values are stored in the children node, the names of which are stored as keys.- Since:
- 4.2
- Author:
- Marius Bogoevici, Gary Russell, Artem Bilan
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ZookeeperMetadataStore(org.apache.curator.framework.CuratorFramework client) -
Method Summary
Modifier and Type Method Description voidaddListener(MetadataStoreListener listener)Register a listener with the metadata store.Stringget(String key)Reads a value for the given key from this MetadataStore.StringgetPath(String key)intgetPhase()StringgetRoot()booleanisAutoStartup()booleanisRunning()voidput(String key, String value)Writes a key value pair to this MetadataStore.StringputIfAbsent(String key, String value)Atomically insert the key into the store.Stringremove(String key)Remove a value for the given key from this MetadataStore.voidremoveListener(MetadataStoreListener callback)Unregister a listener.booleanreplace(String key, String oldValue, String newValue)Atomically replace the value for the key in the store if the old value matches the oldValue argument.voidsetAutoStartup(boolean autoStartup)voidsetEncoding(String encoding)Encoding to use when storing data in ZooKeepervoidsetPhase(int phase)voidsetRoot(String root)Root node - store entries are children of this node.voidstart()voidstop()
-
Constructor Details
-
ZookeeperMetadataStore
public ZookeeperMetadataStore(org.apache.curator.framework.CuratorFramework client)
-
-
Method Details
-
setEncoding
Encoding to use when storing data in ZooKeeper- Parameters:
encoding- encoding as text
-
setRoot
Root node - store entries are children of this node.- Parameters:
root- encoding as text
-
getRoot
-
setAutoStartup
public void setAutoStartup(boolean autoStartup) -
setPhase
public void setPhase(int phase) -
putIfAbsent
Description copied from interface:ConcurrentMetadataStoreAtomically insert the key into the store.- Specified by:
putIfAbsentin interfaceConcurrentMetadataStore- Parameters:
key- The key.value- The value.- Returns:
- null if successful, the old value otherwise.
-
replace
Description copied from interface:ConcurrentMetadataStoreAtomically replace the value for the key in the store if the old value matches the oldValue argument.- Specified by:
replacein interfaceConcurrentMetadataStore- Parameters:
key- The key.oldValue- The old value.newValue- The new value.- Returns:
- true if successful.
-
addListener
Description copied from interface:ListenableMetadataStoreRegister a listener with the metadata store.- Specified by:
addListenerin interfaceListenableMetadataStore- Parameters:
listener- the callback to be registered
-
removeListener
Description copied from interface:ListenableMetadataStoreUnregister a listener.- Specified by:
removeListenerin interfaceListenableMetadataStore- Parameters:
callback- the callback to be unregistered
-
put
Description copied from interface:MetadataStoreWrites a key value pair to this MetadataStore.- Specified by:
putin interfaceMetadataStore- Parameters:
key- The key.value- The value.
-
get
Description copied from interface:MetadataStoreReads a value for the given key from this MetadataStore.- Specified by:
getin interfaceMetadataStore- Parameters:
key- The key.- Returns:
- The value.
-
remove
Description copied from interface:MetadataStoreRemove a value for the given key from this MetadataStore.- Specified by:
removein interfaceMetadataStore- Parameters:
key- The key.- Returns:
- The previous value associated with key, or null if there was no mapping for key.
-
getPath
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartupin interfaceSmartLifecycle
-
start
public void start() -
stop
public void stop() -
isRunning
public boolean isRunning() -
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-