|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ClusterLockDao
Provides access to the Cluster Lock DB table.
Clustered applications need to implement this DAO in order to be able to use the DatabaseClusterLockService.
| Method Summary | |
|---|---|
void |
deleteLocksHeldByNode(String nodeId)
Deletes any locks held by the given 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. |
| Method Detail |
|---|
@Nullable
ClusterLockStatus getClusterLockStatusByName(@Nonnull
String lockName)
lockName - the globally unique id of the lock
boolean 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 written
void 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 written
void 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 locks
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||