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
ConstructorDescriptionZookeeperMetadataStore
(org.apache.curator.framework.CuratorFramework client) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(MetadataStoreListener listener) Register a listener with the metadata store.Reads a value for the given key from this MetadataStore.int
getPhase()
getRoot()
boolean
boolean
void
Writes 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.void
removeListener
(MetadataStoreListener callback) Unregister a listener.boolean
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
Root node - store entries are children of this node.void
start()
void
stop()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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: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
Register a listener with the metadata store.- Specified by:
addListener
in interfaceListenableMetadataStore
- Parameters:
listener
- the callback to be registered
-
removeListener
Description copied from interface:ListenableMetadataStore
Unregister 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
-