public class DefaultDistributedLock extends Synchronous<AsyncDistributedLock> implements DistributedLock
DistributedLock backed by a AsyncDistributedLock.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
DefaultDistributedLock(AsyncDistributedLock asyncLock,
long operationTimeoutMillis) |
| Modifier and Type | Method and Description |
|---|---|
Version |
lock()
Acquires the lock, blocking until it's available.
|
Optional<Version> |
tryLock()
Attempts to acquire the lock.
|
Optional<Version> |
tryLock(Duration timeout)
Attempts to acquire the lock for a specified amount of time.
|
void |
unlock()
Unlocks the lock.
|
destroy, name, primitiveTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprimitiveTypeaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenerspublic DefaultDistributedLock(AsyncDistributedLock asyncLock, long operationTimeoutMillis)
public Version lock()
DistributedLocklock in interface DistributedLockpublic Optional<Version> tryLock()
DistributedLocktryLock in interface DistributedLockpublic Optional<Version> tryLock(Duration timeout)
DistributedLocktryLock in interface DistributedLocktimeout - the timeout after which to give up attempting to acquire the lockpublic void unlock()
DistributedLockunlock in interface DistributedLock