接口 EtcdClient
-
- 所有已知实现类:
AbstractEtcdClient,JEtcdClient
public interface EtcdClient
-
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 List<String>addChildListener(String path, ChildListener listener)register children listener for specified path.voidaddStateListener(StateListener listener)support connection notify if connection state was changed.voidclose()close current client and release all resourses.voidcreate(String path)save the specified path to the etcd registry.longcreateEphemeral(String path)save the specified path to the etcd registry.longcreateLease(long second)create new lease from specified second ,it should be waiting if failed.longcreateLease(long ttl, long timeout, TimeUnit unit)create new lease from specified ttl second before waiting specified timeout.voiddelete(String path)remove the specified from etcd registry.<T> TgetChildListener(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.StringgetKVValue(String key)Get the value of the specified key.URLgetUrl()booleanisConnected()test if current client is active.booleanput(String key, String value)Put the key value pair to etcdbooleanputEphemeral(String key, String value)Put the key value pair to etcd (Ephemeral)voidremoveChildListener(String path, ChildListener listener)unregister children lister for specified path.voidremoveStateListener(StateListener listener)remove connection notify if connection state was changed.voidrevokeLease(long lease)revoke specified lease, any associated path will removed automatically.
-
-
-
方法详细资料
-
create
void create(String path)
save the specified path to the etcd registry.- 参数:
path- the path to be saved
-
createEphemeral
long createEphemeral(String path)
save the specified path to the etcd registry. if node disconnect from etcd, it will be deleted automatically by etcd when session timeout.- 参数:
path- the path to be saved- 返回:
- the lease of current path.
-
delete
void delete(String path)
remove the specified from etcd registry.- 参数:
path- the path to be removed
-
getChildren
List<String> getChildren(String path)
find direct children directory, excluding path self, Never return null.- 参数:
path- the path to be found direct children.- 返回:
- direct children directory, contains zero element list if children directory not exists.
-
addChildListener
List<String> addChildListener(String path, ChildListener listener)
register children listener for specified path.- 参数:
path- the path to be watched when children is added, delete or update.listener- when children is changed , listener will be triggered.- 返回:
- direct children directory, contains zero element list if children directory not exists.
-
getChildListener
<T> T getChildListener(String path, ChildListener listener)
find watcher of the children listener for specified path.- 参数:
path- the path to be watched when children is added, delete or update.listener- when children is changed , listener will be triggered.- 返回:
- watcher if find else null
-
removeChildListener
void removeChildListener(String path, ChildListener listener)
unregister children lister for specified path.- 参数:
path- the path to be unwatched .listener- when children is changed , lister will be triggered.
-
addStateListener
void addStateListener(StateListener listener)
support connection notify if connection state was changed.- 参数:
listener- if state changed, listener will be triggered.
-
removeStateListener
void removeStateListener(StateListener listener)
remove connection notify if connection state was changed.- 参数:
listener- remove already registered listener, if listener not exists nothing happened.
-
isConnected
boolean isConnected()
test if current client is active.- 返回:
- true if connection is active else false.
-
close
void close()
close current client and release all resourses.
-
getUrl
URL getUrl()
-
createLease
long createLease(long second)
create new lease from specified second ,it should be waiting if failed.- 参数:
second- lease time (support second only).- 返回:
- lease id from etcd
-
createLease
long createLease(long ttl, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutExceptioncreate new lease from specified ttl second before waiting specified timeout.- 参数:
ttl- lease time (support second only).timeout- the maximum time to waitunit- the time unit of the timeout argument- 返回:
- lease id from etcd
- 抛出:
CancellationException- if this future was cancelledExecutionException- if this future completed exceptionallyInterruptedException- if the current thread was interrupted while waitingTimeoutException- if the wait timed out
-
revokeLease
void revokeLease(long lease)
revoke specified lease, any associated path will removed automatically.- 参数:
lease- to be removed lease
-
getKVValue
String getKVValue(String key)
Get the value of the specified key.- 参数:
key- the specified key- 返回:
- null if the value is not found
-
put
boolean put(String key, String value)
Put the key value pair to etcd- 参数:
key- the specified keyvalue- the paired value- 返回:
- true if put success
-
-