public interface EtcdClient
| 限定符和类型 | 方法和说明 |
|---|---|
List<String> |
addChildListener(String path,
ChildListener listener)
register children listener for specified path.
|
void |
addStateListener(StateListener listener)
support connection notify if connection state was changed.
|
void |
close()
close current client and release all resourses.
|
void |
create(String path)
save the specified path to the etcd registry.
|
long |
createEphemeral(String path)
save the specified path to the etcd registry.
|
long |
createLease(long second)
create new lease from specified second ,it should be waiting if failed.
|
long |
createLease(long ttl,
long timeout,
TimeUnit unit)
create new lease from specified ttl second before waiting specified timeout.
|
void |
delete(String path)
remove the specified from etcd registry.
|
<T> T |
getChildListener(String path,
ChildListener listener)
find watcher of the children listener for specified path.
|
List<String> |
getChildren(String path)
find direct children directory, excluding path self,
Never return null.
|
String |
getKVValue(String key)
Get the value of the specified key.
|
URL |
getUrl() |
boolean |
isConnected()
test if current client is active.
|
boolean |
put(String key,
String value)
Put the key value pair to etcd
|
boolean |
putEphemeral(String key,
String value)
Put the key value pair to etcd (Ephemeral)
|
void |
removeChildListener(String path,
ChildListener listener)
unregister children lister for specified path.
|
void |
removeStateListener(StateListener listener)
remove connection notify if connection state was changed.
|
void |
revokeLease(long lease)
revoke specified lease, any associated path will removed automatically.
|
void create(String path)
path - the path to be savedlong createEphemeral(String path)
path - the path to be savedvoid delete(String path)
path - the path to be removedList<String> getChildren(String path)
path - the path to be found direct children.List<String> addChildListener(String path, ChildListener listener)
path - the path to be watched when children is added, delete or update.listener - when children is changed , listener will be triggered.<T> T getChildListener(String path, ChildListener listener)
path - the path to be watched when children is added, delete or update.listener - when children is changed , listener will be triggered.void removeChildListener(String path, ChildListener listener)
path - the path to be unwatched .listener - when children is changed , lister will be triggered.void addStateListener(StateListener listener)
listener - if state changed, listener will be triggered.void removeStateListener(StateListener listener)
listener - remove already registered listener, if listener
not exists nothing happened.boolean isConnected()
void close()
URL getUrl()
long createLease(long second)
second - lease time (support second only).long createLease(long ttl,
long timeout,
TimeUnit unit)
throws InterruptedException,
ExecutionException,
TimeoutException
ttl - lease time (support second only).timeout - the maximum time to waitunit - the time unit of the timeout argumentCancellationException - if this future was cancelledExecutionException - if this future completed exceptionallyInterruptedException - if the current thread was interrupted
while waitingTimeoutException - if the wait timed outvoid revokeLease(long lease)
lease - to be removed leaseString getKVValue(String key)
key - the specified keyboolean put(String key, String value)
key - the specified keyvalue - the paired valueCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.