public class AlluxioEtcdClient extends Object
Modifier and Type | Class and Description |
---|---|
protected static interface |
AlluxioEtcdClient.EtcdUtilCallable<V> |
static class |
AlluxioEtcdClient.Lease
Lease structure to keep the info about a lease in etcd.
|
Modifier and Type | Field and Description |
---|---|
static String |
BASE_PATH |
static long |
DEFAULT_LEASE_TTL_IN_SEC |
static long |
DEFAULT_TIMEOUT_IN_SEC |
ServiceDiscoveryRecipe |
mServiceDiscovery |
static int |
RETRY_TIMES |
Constructor and Description |
---|
AlluxioEtcdClient(AlluxioConfiguration conf)
CTOR for AlluxioEtcdClient.
|
Modifier and Type | Method and Description |
---|---|
void |
addChildren(String parentPath,
String childPath,
byte[] value)
Create a childPath with value to a parentPath.
|
void |
addChildrenListener(String parentPath,
StateListener listener)
Add state listener to watch children for given path.
|
void |
addStateListener(String path,
StateListener listener)
Add state listener to given path.
|
boolean |
checkExistsForPath(String path)
Check existence of a single given path.
|
void |
createForPath(String path,
Optional<byte[]> value)
Create a path with given value in non-transactional way.
|
AlluxioEtcdClient.Lease |
createLease()
Create lease with default ttl and timeout.
|
AlluxioEtcdClient.Lease |
createLease(long ttlInSec,
long timeout,
TimeUnit timeUnit)
Create a lease with timeout and ttl.
|
void |
deleteForPath(String path,
boolean recursive)
Delete a path or recursively all paths with given path as prefix.
|
static void |
destroy()
Destroys the client and corresponding resources.
|
List<io.etcd.jetcd.KeyValue> |
getChildren(String parentPath)
Get list of children path kv pairs from a given parentPath
e.g.
|
io.etcd.jetcd.Client |
getEtcdClient()
Get the jetcd client instance.
|
byte[] |
getForPath(String path)
Get latest value attached to the path.
|
static AlluxioEtcdClient |
getInstance(AlluxioConfiguration conf)
Get the singleton instance of AlluxioEtcdClient.
|
boolean |
isLeaseExpired(AlluxioEtcdClient.Lease lease)
Check with etcd if a lease is already expired.
|
void |
removeChildrenListener(String parentPath)
Remove state listener for children on a given parentPath.
|
void |
removeListenerInternal(String path,
alluxio.membership.AlluxioEtcdClient.WatchType watchType)
Remove listener on given path.
|
void |
removeStateListener(String path)
Remove state listener for give path.
|
void |
revokeLease(AlluxioEtcdClient.Lease lease)
Revoke given lease.
|
public static final String BASE_PATH
public static final long DEFAULT_LEASE_TTL_IN_SEC
public static final long DEFAULT_TIMEOUT_IN_SEC
public static final int RETRY_TIMES
public final ServiceDiscoveryRecipe mServiceDiscovery
public AlluxioEtcdClient(AlluxioConfiguration conf)
conf
- public static AlluxioEtcdClient getInstance(AlluxioConfiguration conf)
conf
- public AlluxioEtcdClient.Lease createLease(long ttlInSec, long timeout, TimeUnit timeUnit)
ttlInSec
- timeout
- timeUnit
- public AlluxioEtcdClient.Lease createLease()
public void revokeLease(AlluxioEtcdClient.Lease lease)
lease
- public boolean isLeaseExpired(AlluxioEtcdClient.Lease lease)
lease
- public void addChildren(String parentPath, String childPath, byte[] value)
parentPath
- childPath
- value
- public List<io.etcd.jetcd.KeyValue> getChildren(String parentPath)
parentPath
- parentPath ends with /public void addStateListener(String path, StateListener listener)
path
- listener
- public void removeStateListener(String path)
path
- public void addChildrenListener(String parentPath, StateListener listener)
parentPath
- listener
- public void removeChildrenListener(String parentPath)
parentPath
- public byte[] getForPath(String path)
path
- public boolean checkExistsForPath(String path)
path
- public void createForPath(String path, Optional<byte[]> value)
path
- value
- public void deleteForPath(String path, boolean recursive)
path
- recursive
- public void removeListenerInternal(String path, alluxio.membership.AlluxioEtcdClient.WatchType watchType)
path
- watchType
- public io.etcd.jetcd.Client getEtcdClient()
public static void destroy()
AutoCloseable
because the client is used by client
FileSystemContext. FileSystemContext has reinit() logic which may close and recreate
all resources. We don't want the life cycle of one FileSystemContext to close the global
singleton ETCD client.Copyright © 2023. All Rights Reserved.