public interface LockStrategy
| Modifier and Type | Method and Description |
|---|---|
default LockedResource<String> |
tryAcquire(String resourceId)
Equivalent to
tryAcquire(String, Object) in cases where the resource being locked is
not applicable, or is the same as the String resourceId provided. |
<T> LockedResource<T> |
tryAcquire(String resourceId,
T resource)
Attempts to acquire a lock by the provided
resourceId for the logical resource
provided by resource. |
default <T extends Lockable> |
tryAcquire(T lockable)
Equivalent to
tryAcquire(String, Object) except the resource being locked has the
knowledge of its own resourceId to lock with. |
<T> LockedResource<T> tryAcquire(String resourceId, T resource) throws LockNotAvailableException
resourceId for the logical resource
provided by resource.
After a resource is locked, it is expected that nothing else can acquire it again until it is released (intentionally or not), no matter if it is the same thread, another thread, or across a network.
T - The type of the resource being acquired.resourceId - A string which identifies the resource and only that resource.resource - A logically locked resource as a result of the id being locked. Participants
must agree on a scheme of resourceIds to resources.LockNotAvailableException - If for whatever reason the lock could not be acquired.
Generally this is simply because another client has the lock, but it could also be due to
network failure, etc.default <T extends Lockable> LockedResource<T> tryAcquire(T lockable) throws LockNotAvailableException
tryAcquire(String, Object) except the resource being locked has the
knowledge of its own resourceId to lock with.LockNotAvailableExceptionLockabledefault LockedResource<String> tryAcquire(String resourceId) throws LockNotAvailableException
tryAcquire(String, Object) in cases where the resource being locked is
not applicable, or is the same as the String resourceId provided.LockNotAvailableExceptionCopyright © 2017. All rights reserved.