public abstract class AbstractDLock extends Object implements IDLock, AutoCloseable
IDLock.DEFAULT_LOCK_DURATION_MS| Constructor and Description |
|---|
AbstractDLock(String name) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
destroy() |
protected String |
getClientId()
Get client-id who is currently holding the lock.
|
protected Properties |
getLockProperties()
Get lock's custom properties.
|
protected String |
getLockProperty(String key)
Get lock's custom property.
|
String |
getName()
Get lock's name(space).
|
protected long |
getTimestampExpiry()
Get timestamp (in milliseconds) when the lock-acquisition expires.
|
AbstractDLock |
init() |
LockResult |
lock(String clientId)
Acquire the lock for
clientId with default duration. |
protected AbstractDLock |
setClientId(String clientId)
Get client-id who is currently holding the lock.
|
AbstractDLock |
setLockProperties(Properties lockProps)
Lock's custom properties.
|
AbstractDLock |
setName(String name) |
protected AbstractDLock |
setTimestampExpiry(long timestampExpiry)
Get timestamp (in milliseconds) when the lock-acquisition expires.
|
String |
toString() |
protected void |
updateLockHolder(String clientId,
long lockDurationMs)
Update current lock's holder info.
|
public AbstractDLock(String name)
public String getName()
public AbstractDLock setName(String name)
protected void updateLockHolder(String clientId, long lockDurationMs)
clientId - lockDurationMs - protected String getClientId()
Note: value returned from this method is "estimated".
protected AbstractDLock setClientId(String clientId)
clientId - protected long getTimestampExpiry()
Note: value returned from this method is "estimated".
protected AbstractDLock setTimestampExpiry(long timestampExpiry)
timestampExpiry - public AbstractDLock setLockProperties(Properties lockProps)
lockProps - protected Properties getLockProperties()
protected String getLockProperty(String key)
key - public AbstractDLock init()
public void destroy()
public void close()
close in interface AutoCloseablepublic LockResult lock(String clientId)
clientId with default duration.
Reentrant: lock can be acquired multiple times by the same
clientId. Lock's expiry will be extended accordingly.
lock in interface IDLockclientId - 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 clientCopyright © 2018 DDTH. All rights reserved.