public interface ClusterLockDao
DatabaseClusterLockService.| Modifier and Type | Method and Description |
|---|---|
void |
deleteLocksHeldByNode(String nodeId)
Deletes any locks held by the given node.
|
List<ClusterLockStatus> |
getAllHeldClusterLocks()
Returns lock details for all cluster locks being held by any node.
|
ClusterLockStatus |
getClusterLockStatusByName(String lockName)
Returns the cluster lock details for the given name, or null if no such lock has ever been created.
|
void |
insertEmptyClusterLock(String lockName,
long updateTime)
Attempt to insert an "unlocked" DB row for the named lock.
|
boolean |
tryUpdateAcquireLock(String lockName,
String nodeId,
long updateTime)
Attempt to acquire an existing named lock for the given nodeId.
|
void |
unlock(String lockName,
String nodeId,
long updateTime)
Unlock the named lock, if this node still holds the lock.
|
@Nonnull List<ClusterLockStatus> getAllHeldClusterLocks()
@Nullable ClusterLockStatus getClusterLockStatusByName(@Nonnull String lockName)
lockName - the globally unique id of the lockboolean tryUpdateAcquireLock(@Nonnull String lockName, @Nonnull String nodeId, long updateTime)
This should be an UPDATE ... WHERE operation like
UPDATE CLUSTER_LOCK SET LOCKED_BY_NODE = ? WHERE LOCK_NAME = ? AND LOCKED_BY_NODE IS NULL
lockName - the globally unique id of the locknodeId - This node's IDupdateTime - the time in milliseconds that this update was writtenvoid insertEmptyClusterLock(@Nonnull String lockName, long updateTime)
You can assume that the lock name is not null. This insert should only insert a single row for the given lock name (which will never be null). This is expected to be achieved simply by putting a unique constraint on the LOCK_NAME column.
If the row already exists, then this method must catch the unique constraint violation and terminate normally. All other SQL errors should be thrown as a RuntimeException of some kind.
lockName - the lock identifierupdateTime - the time in milliseconds that this insert was writtenvoid unlock(@Nonnull String lockName, @Nonnull String nodeId, long updateTime)
If for some reason we no longer hold the lock then we should not unlock it. That is, the SQL should look something like
UPDATE CLUSTER_LOCK SET LOCKED_BY_NODE = NULL WHERE LOCK_NAME = ? AND LOCKED_BY_NODE = ?
lockName - the lock identifiernodeId - This node's IDupdateTime - the time in milliseconds that this update was writtenvoid deleteLocksHeldByNode(String nodeId)
nodeId - the node for which to delete the locksCopyright © 2018 Atlassian. All rights reserved.