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
Constructors Constructor Description BambooClusterLockRawJdbcDao(@NotNull ClusterNodeHeartbeatDao clusterNodeHeartbeatDao)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddeleteExpiredLocksByPrefix(@NotNull String lockNamePrefix, long lockTimeoutSeconds)Deletes the locks identified by a given prefix that are expired based on a given timeout in seconds.voiddeleteLocksHeldByNode(String nodeId)voidensureClusterLockTableExists()Creates lock table if required.@NotNull List<com.atlassian.beehive.core.ClusterLockStatus>getAllHeldClusterLocks()@Nullable com.atlassian.beehive.core.ClusterLockStatusgetClusterLockStatusByName(@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.voidinsertEmptyClusterLock(@NotNull String lockName)voidreleaseLocksHeldByNode()voidrenewLease(@NotNull String lockName)voidrenewLease(@NotNull String lockName, @NotNull String nodeId)booleantryAcquireLock(@NotNull String lockName)Deprecated.booleantryUpdateAcquireNodeScopedLock(@NotNull String lockName, long lockTimeoutSeconds)Try to acquire an existing lock for the current node.booleantryUpdateAcquireNodeScopedLock(@NotNull String lockName, @NotNull String nodeId, long lockTimeoutSeconds)Try to acquire an existing lock for the given node.voidunlock(@NotNull String lockName)voidunlock(@NotNull String lockName, @NotNull String nodeId)Force unlock a lock held by a specified node.-
Methods inherited from class com.atlassian.bamboo.beehive.AbstractBambooRawJdbcDao
ensureClusterTableExists, supplierWithConnection, withDatabaseConnection
-
-
-
-
Constructor Detail
-
BambooClusterLockRawJdbcDao
public BambooClusterLockRawJdbcDao(@NotNull @NotNull ClusterNodeHeartbeatDao clusterNodeHeartbeatDao)
-
-
Method Detail
-
getAllHeldClusterLocks
@NotNull public @NotNull List<com.atlassian.beehive.core.ClusterLockStatus> getAllHeldClusterLocks()
- Specified by:
getAllHeldClusterLocksin interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
getClusterLockStatusByName
@Nullable public @Nullable com.atlassian.beehive.core.ClusterLockStatus getClusterLockStatusByName(@NotNull @NotNull String lockName)Description copied from interface:BambooClusterLockDaoReturns the cluster lock details for the given name and or null if no such lock has ever been created.- Specified by:
getClusterLockStatusByNamein interfaceBambooClusterLockDao- Specified by:
getClusterLockStatusByNamein 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:BambooClusterLockDaoReturns 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:
getClusterMultiLockStatusByNamePrefixin 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:BambooClusterLockDaoDeletes the locks identified by a given prefix that are expired based on a given timeout in seconds.- Specified by:
deleteExpiredLocksByPrefixin 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:
tryAcquireLockin interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
tryUpdateAcquireNodeScopedLock
public boolean tryUpdateAcquireNodeScopedLock(@NotNull @NotNull String lockName, long lockTimeoutSeconds)Description copied from interface:BambooClusterLockDaoTry 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:
tryUpdateAcquireNodeScopedLockin 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:BambooClusterLockDaoTry 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:
tryUpdateAcquireNodeScopedLockin 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
public void insertEmptyClusterLock(@NotNull @NotNull String lockName)- Specified by:
insertEmptyClusterLockin interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
unlock
public void unlock(@NotNull @NotNull String lockName)- Specified by:
unlockin interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
renewLease
public void renewLease(@NotNull @NotNull String lockName)- Specified by:
renewLeasein interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
renewLease
public void renewLease(@NotNull @NotNull String lockName, @NotNull @NotNull String nodeId)
-
unlock
public void unlock(@NotNull @NotNull String lockName, @NotNull @NotNull String nodeId)Description copied from interface:BambooClusterLockDaoForce unlock a lock held by a specified node.- Specified by:
unlockin interfaceBambooClusterLockDao
-
releaseLocksHeldByNode
public void releaseLocksHeldByNode()
- Specified by:
releaseLocksHeldByNodein interfacecom.atlassian.beehive.db.spi.ClusterLockDao
-
deleteLocksHeldByNode
public void deleteLocksHeldByNode(String nodeId)
-
ensureClusterLockTableExists
public void ensureClusterLockTableExists()
Description copied from interface:BambooClusterLockDaoCreates lock table if required.- Specified by:
ensureClusterLockTableExistsin interfaceBambooClusterLockDao
-
-