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 void
addListener(MetadataStoreListener listener)
Registers a listener with the metadata storeString
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 listenerboolean
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 ZooKeepervoid
setPhase(int phase)
void
setRoot(String root)
Root node - store entries are children of this node.void
start()
void
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:ConcurrentMetadataStore
Atomically insert the key into the store.- Specified by:
putIfAbsent
in interfaceConcurrentMetadataStore
- Parameters:
key
- The key.value
- The value.- Returns:
- null if successful, the old value otherwise.
-
replace
Description copied from interface:ConcurrentMetadataStore
Atomically replace the value for the key in the store if the old value matches the oldValue argument.- Specified by:
replace
in interfaceConcurrentMetadataStore
- Parameters:
key
- The key.oldValue
- The old value.newValue
- The new value.- Returns:
- true if successful.
-
addListener
Description copied from interface:ListenableMetadataStore
Registers a listener with the metadata store- Specified by:
addListener
in interfaceListenableMetadataStore
- Parameters:
listener
- the callback to be registered
-
removeListener
Description copied from interface:ListenableMetadataStore
Unregisters a listener- Specified by:
removeListener
in interfaceListenableMetadataStore
- Parameters:
callback
- the callback to be unregistered
-
put
Description copied from interface:MetadataStore
Writes a key value pair to this MetadataStore.- Specified by:
put
in interfaceMetadataStore
- Parameters:
key
- The key.value
- The value.
-
get
Description copied from interface:MetadataStore
Reads a value for the given key from this MetadataStore.- Specified by:
get
in interfaceMetadataStore
- Parameters:
key
- The key.- Returns:
- The value.
-
remove
Description copied from interface:MetadataStore
Remove a value for the given key from this MetadataStore.- Specified by:
remove
in 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:
isAutoStartup
in interfaceSmartLifecycle
-
start
public void start() -
stop
public void stop() -
isRunning
public boolean isRunning() -
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-