Interface LockManager<T>
- All Superinterfaces:
AutoCloseable
Controller for acquiring distributed lock on resources.
-
Method Summary
Modifier and TypeMethodDescriptionacquireLock(String path, T value) Acquire a lock on a shared resource.Close the LockManager and release all the locks.List all the locks that are children of a specific path.Read the content of an existing lock.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
readLock
Read the content of an existing lock. If the lock is already taken, this operation will fail immediately. Warning: because of the distributed nature of the lock, having acquired a lock will never provide a strong guarantee that no one else also think it owns the same resource. The caller will have to deal with these race conditions when using the resource itself (eg. using compareAndSet() or fencing mechanisms).- Parameters:
path- the path of the resource on which to acquire the lock- Returns:
- a future that will track the completion of the operation
- Throws:
MetadataStoreException.NotFoundException- if the lock is not takenMetadataStoreException- if there's a failure in reading the lock
-
acquireLock
Acquire a lock on a shared resource. If the lock is already taken, this operation will fail immediately. Warning: because of the distributed nature of the lock, having acquired a lock will never provide a strong guarantee that no one else also think it owns the same resource. The caller will have to deal with these race conditions when using the resource itself (eg. using compareAndSet() or fencing mechanisms).- Parameters:
path- the path of the resource on which to acquire the lockvalue- the value of the lock- Returns:
- a future that will track the completion of the operation
- Throws:
MetadataStoreException.LockBusyException- if the lock is already takenMetadataStoreException- if there's a failure in acquiring the lock
-
listLocks
List all the locks that are children of a specific path. For example, given locks:/a/b/lock-1and/a/b/lock-2, thelistLocks("/a/b")will return a list of["lock-1", "lock-2"].- Parameters:
path- the prefix path to get the list of locks- Returns:
- a future that will track the completion of the operation
- Throws:
MetadataStoreException- if there's a failure in getting the list of locks
-
asyncClose
CompletableFuture<Void> asyncClose()Close the LockManager and release all the locks.- Returns:
- a future that will track the completion of the operation
- Throws:
MetadataStoreException- if there's a failure in closing the LockManager
-