Interface BambooClusterLockDao

  • All Superinterfaces:
    com.atlassian.beehive.db.spi.ClusterLockDao
    All Known Implementing Classes:
    BambooClusterLockRawJdbcDao

    @Internal
    public interface BambooClusterLockDao
    extends com.atlassian.beehive.db.spi.ClusterLockDao
    Specialised implementation of ClusterLockDao.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void 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 ensureClusterLockTableExists()
      Creates lock table if required.
      com.atlassian.beehive.core.ClusterLockStatus getClusterLockStatusByName​(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.
      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 unlock​(@NotNull String lockName, @NotNull String nodeId)
      Force unlock a lock held by a specified node.
      • Methods inherited from interface com.atlassian.beehive.db.spi.ClusterLockDao

        getAllHeldClusterLocks, insertEmptyClusterLock, releaseLocksHeldByNode, renewLease, tryAcquireLock, unlock
    • Method Detail

      • ensureClusterLockTableExists

        void ensureClusterLockTableExists()
        Creates lock table if required.
      • tryUpdateAcquireNodeScopedLock

        boolean tryUpdateAcquireNodeScopedLock​(@NotNull
                                               @NotNull String lockName,
                                               long lockTimeoutSeconds)
        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)

        Parameters:
        lockName - name of the lock to acquire
        lockTimeoutSeconds - time (in seconds) after which the lock can be taken over
        Returns:
        true if the lock has been acquired/updated successfully, false otherwise
        Since:
        9.5
      • tryUpdateAcquireNodeScopedLock

        boolean tryUpdateAcquireNodeScopedLock​(@NotNull
                                               @NotNull String lockName,
                                               @NotNull
                                               @NotNull String nodeId,
                                               long lockTimeoutSeconds)
        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)

        Parameters:
        lockName - name of the lock to acquire
        nodeId - this node id
        lockTimeoutSeconds - time (in seconds) after which the lock can be taken over
        Returns:
        true if the lock has been acquired/updated successfully, false otherwise
      • getClusterLockStatusByName

        @Nullable
        com.atlassian.beehive.core.ClusterLockStatus getClusterLockStatusByName​(@Nonnull
                                                                                String lockName)
        Returns the cluster lock details for the given name and or null if no such lock has ever been created.
        Specified by:
        getClusterLockStatusByName in interface com.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.
      • unlock

        void unlock​(@NotNull
                    @NotNull String lockName,
                    @NotNull
                    @NotNull String nodeId)
        Force unlock a lock held by a specified node.
        Parameters:
        lockName -
        nodeId -
      • getClusterMultiLockStatusByNamePrefix

        @NotNull
        @NotNull Set<com.atlassian.beehive.core.ClusterLockStatus> getClusterMultiLockStatusByNamePrefix​(@NotNull
                                                                                                         @NotNull String lockNamePrefix)
        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).
        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.
        Since:
        9.5
      • deleteExpiredLocksByPrefix

        void deleteExpiredLocksByPrefix​(@NotNull
                                        @NotNull String lockNamePrefix,
                                        long lockTimeoutSeconds)
        Deletes the locks identified by a given prefix that are expired based on a given timeout in seconds.
        Parameters:
        lockNamePrefix - the prefix that will be used to find the locks
        lockTimeoutSeconds - time (in seconds) after which the lock can be taken over
        Since:
        9.5