Package com.atlassian.bamboo.beehive
Class BambooClusterLockRawJdbcDao
java.lang.Object
com.atlassian.bamboo.beehive.AbstractBambooRawJdbcDao
com.atlassian.bamboo.beehive.BambooClusterLockRawJdbcDao
- All Implemented Interfaces:
BambooClusterLockDao
,com.atlassian.beehive.db.spi.ClusterLockDao
public class BambooClusterLockRawJdbcDao
extends AbstractBambooRawJdbcDao
implements BambooClusterLockDao
-
Field Summary
Fields inherited from class com.atlassian.bamboo.beehive.AbstractBambooRawJdbcDao
dbmsBean, hibernateConfig
-
Constructor Summary
ConstructorDescriptionBambooClusterLockRawJdbcDao
(@NotNull ClusterNodeHeartbeatDao clusterNodeHeartbeatDao) -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteExpiredLocksByPrefix
(@NotNull String lockNamePrefix, long lockTimeoutSeconds) Deletes the locks identified by a given prefix that are expired based on a given timeout in seconds.void
deleteLocksHeldByNode
(String nodeId) void
Creates lock table if required.@NotNull List<com.atlassian.beehive.core.ClusterLockStatus>
@Nullable com.atlassian.beehive.core.ClusterLockStatus
getClusterLockStatusByName
(@NotNull String lockName) Returns the cluster lock details for the given name and or null if no such lock has ever been created.@NotNull Set<com.atlassian.beehive.core.ClusterLockStatus>
getClusterMultiLockStatusByNamePrefix
(@NotNull String lockNamePrefix) Returns the cluster lock details based on a name prefix, or empty if no such lock exists.void
insertEmptyClusterLock
(@NotNull String lockName) void
void
renewLease
(@NotNull String lockName) void
renewLease
(@NotNull String lockName, @NotNull String nodeId) boolean
tryAcquireLock
(@NotNull String lockName) Deprecated.boolean
tryUpdateAcquireNodeScopedLock
(@NotNull String lockName, long lockTimeoutSeconds) Try to acquire an existing lock for the current node.boolean
tryUpdateAcquireNodeScopedLock
(@NotNull String lockName, @NotNull String nodeId, long lockTimeoutSeconds) Try to acquire an existing lock for the given node.void
void
Force unlock a lock held by a specified node.Methods inherited from class com.atlassian.bamboo.beehive.AbstractBambooRawJdbcDao
ensureClusterTableExists, supplierWithConnection, withDatabaseConnection
-
Constructor Details
-
BambooClusterLockRawJdbcDao
public BambooClusterLockRawJdbcDao(@NotNull @NotNull ClusterNodeHeartbeatDao clusterNodeHeartbeatDao)
-
-
Method Details
-
getAllHeldClusterLocks
@NotNull public @NotNull List<com.atlassian.beehive.core.ClusterLockStatus> getAllHeldClusterLocks()- Specified by:
getAllHeldClusterLocks
in interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
getClusterLockStatusByName
@Nullable public @Nullable com.atlassian.beehive.core.ClusterLockStatus getClusterLockStatusByName(@NotNull @NotNull String lockName) Description copied from interface:BambooClusterLockDao
Returns the cluster lock details for the given name and or null if no such lock has ever been created.- Specified by:
getClusterLockStatusByName
in interfaceBambooClusterLockDao
- Specified by:
getClusterLockStatusByName
in interfacecom.atlassian.beehive.db.spi.ClusterLockDao
- Parameters:
lockName
- the globally unique id of the lock- Returns:
- the cluster lock details for the given name, or null if no such lock has ever been created.
-
getClusterMultiLockStatusByNamePrefix
@NotNull public @NotNull Set<com.atlassian.beehive.core.ClusterLockStatus> getClusterMultiLockStatusByNamePrefix(@NotNull @NotNull String lockNamePrefix) Description copied from interface:BambooClusterLockDao
Returns the cluster lock details based on a name prefix, or empty if no such lock exists. It allows multiple nodes to have the same lock, differing only by a suffix (for instance, in case of READ lock).- Specified by:
getClusterMultiLockStatusByNamePrefix
in interfaceBambooClusterLockDao
- Parameters:
lockNamePrefix
- the prefix that will be used to find the locks- Returns:
- the cluster READ lock details for the given prefix, or empty if none.
-
deleteExpiredLocksByPrefix
public void deleteExpiredLocksByPrefix(@NotNull @NotNull String lockNamePrefix, long lockTimeoutSeconds) Description copied from interface:BambooClusterLockDao
Deletes the locks identified by a given prefix that are expired based on a given timeout in seconds.- Specified by:
deleteExpiredLocksByPrefix
in interfaceBambooClusterLockDao
- Parameters:
lockNamePrefix
- the prefix that will be used to find the lockslockTimeoutSeconds
- time (in seconds) after which the lock can be taken over
-
tryAcquireLock
@Deprecated(since="Since 9.4 use tryUpdateAcquireNodeScopedLock instead") public boolean tryAcquireLock(@NotNull @NotNull String lockName) Deprecated.- Specified by:
tryAcquireLock
in interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
tryUpdateAcquireNodeScopedLock
public boolean tryUpdateAcquireNodeScopedLock(@NotNull @NotNull String lockName, long lockTimeoutSeconds) Description copied from interface:BambooClusterLockDao
Try to acquire an existing lock for the current node. This method will succeed and will update the lock timestamp both when the lock has been just acquired by the node and when the lock is already owned by the current node.See also
ClusterLockDao.tryAcquireLock(String)
- Specified by:
tryUpdateAcquireNodeScopedLock
in interfaceBambooClusterLockDao
- Parameters:
lockName
- name of the lock to acquirelockTimeoutSeconds
- time (in seconds) after which the lock can be taken over- Returns:
- true if the lock has been acquired/updated successfully, false otherwise
-
tryUpdateAcquireNodeScopedLock
public boolean tryUpdateAcquireNodeScopedLock(@NotNull @NotNull String lockName, @NotNull @NotNull String nodeId, long lockTimeoutSeconds) Description copied from interface:BambooClusterLockDao
Try to acquire an existing lock for the given node. This method will succeed and will update the lock timestamp both when the lock has been just acquired by the node and when the lock is already owned by the given node.See also
ClusterLockDao.tryAcquireLock(String)
- Specified by:
tryUpdateAcquireNodeScopedLock
in interfaceBambooClusterLockDao
- Parameters:
lockName
- name of the lock to acquirenodeId
- this node idlockTimeoutSeconds
- time (in seconds) after which the lock can be taken over- Returns:
- true if the lock has been acquired/updated successfully, false otherwise
-
insertEmptyClusterLock
- Specified by:
insertEmptyClusterLock
in interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
unlock
- Specified by:
unlock
in interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
renewLease
- Specified by:
renewLease
in interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
renewLease
-
unlock
Description copied from interface:BambooClusterLockDao
Force unlock a lock held by a specified node.- Specified by:
unlock
in interfaceBambooClusterLockDao
-
releaseLocksHeldByNode
public void releaseLocksHeldByNode()- Specified by:
releaseLocksHeldByNode
in interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
deleteLocksHeldByNode
-
ensureClusterLockTableExists
public void ensureClusterLockTableExists()Description copied from interface:BambooClusterLockDao
Creates lock table if required.- Specified by:
ensureClusterLockTableExists
in interfaceBambooClusterLockDao
-