Class ClusterLockDAOHibernate


public class ClusterLockDAOHibernate extends HibernateDao<ClusterLockEntity>
Hibernate DAO to store cluster locks
  • Field Details

  • Constructor Details

    • ClusterLockDAOHibernate

      public ClusterLockDAOHibernate()
  • Method Details

    • getPersistentClass

      public Class<ClusterLockEntity> getPersistentClass()
      Description copied from class: HibernateDao
      All subclasses of HibernateDao must implement this method for HibernateDao.load(Serializable) to work correctly.
      Specified by:
      getPersistentClass in class HibernateDao<ClusterLockEntity>
      Returns:
      the entity class for this DAO
    • getAllHeldClusterLocks

      public List<ClusterLockEntity> getAllHeldClusterLocks()
    • getLockByName

      public ClusterLockEntity getLockByName(String lockName)
    • 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 lock
      nodeId - This node's ID
      currentTime - the time in milliseconds that this update was written
      lockExpiryTimeout - 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

      public void renewLease(@Nonnull String lockName, @Nonnull String nodeId, long currentTime)
    • insertEmptyClusterLock

      public void insertEmptyClusterLock(@Nonnull String lockName, long currentTime)
      Attempt to insert an "unlocked" DB row for the named lock.
      Parameters:
      lockName - the lock identifier
      currentTime - the time in milliseconds that this insert was written
    • unlock

      public void unlock(String lockName, String nodeId, long currentTime)
      Unlock the named lock, if this node still holds the lock.
      Parameters:
      lockName - the lock identifier
      nodeId - This node's ID
      currentTime - the time in milliseconds that this update was written
    • list

      public List<ClusterLockEntity> list()
    • deleteLocksHeldByNode

      public void deleteLocksHeldByNode(String nodeId)