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, Christian Tzolov
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionZookeeperMetadataStore(org.apache.curator.framework.CuratorFramework client) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(MetadataStoreListener listener) Register a listener with the metadata store.Reads a value for the given key from this MetadataStore.intgetPhase()getRoot()booleanbooleanvoidWrites a key value pair to this MetadataStore.putIfAbsent(String key, String value) Atomically insert the key into the store.Remove a value for the given key from this MetadataStore.voidremoveListener(MetadataStoreListener callback) Unregister a listener.booleanAtomically 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) voidRoot node - store entries are children of this node.voidstart()voidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
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
-
stop
-
isRunning
-
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-