Package com.atlassian.crowd.dao.cluster
Class ClusterLockDAOHibernate
java.lang.Object
com.atlassian.crowd.util.persistence.hibernate.StatelessDao
com.atlassian.crowd.util.persistence.hibernate.HibernateDao<ClusterLockEntity>
com.atlassian.crowd.dao.cluster.ClusterLockDAOHibernate
Hibernate DAO to store cluster locks
-
Field Summary
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger, statelessSessionBatchProcessor, timeSource
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
sessionFactory
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteLocksHeldByNode
(String nodeId) getLockByName
(String lockName) All subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)
to work correctly.void
insertEmptyClusterLock
(String lockName, long currentTime) Attempt to insert an "unlocked" DB row for the named lock.list()
void
renewLease
(String lockName, String nodeId, long currentTime) boolean
tryUpdateAcquireLock
(String lockName, String nodeId, long currentTime, long lockExpiryTimeout) Attempt to acquire an existing named lock for the given nodeId.void
Unlock the named lock, if this node still holds the lock.Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
createDeleteQuery, createDeleteQuery, createQuery, createQuery, executeHQLQuery, findAllInternal, findByProperties, findByPropertiesOptional, findByProperty, findByProperty, findByPropertyOptional, findByPropertyOrThrow, getCountByProperties, load, load, loadOptional, loadReference, loadReference, remove, removeByIdIfPresent, save, saveOrUpdate, session, setBatchFinder, setBatchProcessor, setClock, setStatelessSessionBatchProcessor, toPredicates, update
Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
setSessionFactory, withStatelessSession
-
Field Details
-
SUPPRESS_LOGGING_MDC_KEY
- See Also:
-
-
Constructor Details
-
ClusterLockDAOHibernate
public ClusterLockDAOHibernate()
-
-
Method Details
-
getPersistentClass
Description copied from class:HibernateDao
All subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)
to work correctly.- Specified by:
getPersistentClass
in classHibernateDao<ClusterLockEntity>
- Returns:
- the entity class for this DAO
-
getAllHeldClusterLocks
-
getLockByName
-
tryUpdateAcquireLock
public boolean tryUpdateAcquireLock(@Nonnull String lockName, @Nonnull String nodeId, long currentTime, long lockExpiryTimeout) Attempt to acquire an existing named lock for the given nodeId.- Parameters:
lockName
- the globally unique id of the locknodeId
- This node's IDcurrentTime
- the time in milliseconds that this update was writtenlockExpiryTimeout
- the timeout for the lock expiry, should be sourced from com.atlassian.beehive.db.LockExpiryConfiguration#getExpiryPeriodDurationSeconds()- Returns:
- true if we acquired the lock, false if the row exists but is already locked.
-
renewLease
-
insertEmptyClusterLock
Attempt to insert an "unlocked" DB row for the named lock.- Parameters:
lockName
- the lock identifiercurrentTime
- the time in milliseconds that this insert was written
-
unlock
Unlock the named lock, if this node still holds the lock.- Parameters:
lockName
- the lock identifiernodeId
- This node's IDcurrentTime
- the time in milliseconds that this update was written
-
list
-
deleteLocksHeldByNode
-