public interface IDLock
Implementation:
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_LOCK_DURATION_MS |
| Modifier and Type | Method and Description |
|---|---|
String |
getName()
Get lock's name(space).
|
LockResult |
lock(String clientId)
Acquire the lock for
clientId with default duration. |
LockResult |
lock(String clientId,
long lockDurationMs)
Acquire the lock for
clientId for a duration of
lockDurationMs. |
LockResult |
unlock(String clientId)
Release the lock.
|
static final long DEFAULT_LOCK_DURATION_MS
String getName()
LockResult lock(String clientId) throws DLockException
clientId with default duration.
Reentrant: lock can be acquired multiple times by the same
clientId. Lock's expiry will be extended accordingly.
clientId - within a namespace, only one client is allowed to hold lock as
a given timeLockResult.SUCCESSFUL if successful,
LockResult.HOLD_BY_ANOTHER_CLIENT if lock is currently
hold by another clientDLockExceptionLockResult lock(String clientId, long lockDurationMs)
clientId for a duration of
lockDurationMs.
Reentrant: lock can be acquired multiple times by the same
clientId. Lock's expiry will be extended accordingly.
clientId - within a namespace, only one client is allowed to hold lock as
a given timelockDurationMs - LockResult.SUCCESSFUL if successful,
LockResult.HOLD_BY_ANOTHER_CLIENT if lock is currently
hold by another clientLockResult unlock(String clientId)
clientId - within a namespace, only one client is allowed to hold lock as
a given timeLockResult.SUCCESSFUL if successful,
LockResult.HOLD_BY_ANOTHER_CLIENT if lock is currently
hold by another client, LockResult.NOT_FOUND if the lock
is not currently hold by any client (not locked before, or
already expired)Copyright © 2018 DDTH. All rights reserved.