Interface LockManager

All Known Implementing Classes:
LockManagerImpl

public interface LockManager
Author:
Filip Hrisafov
  • Method Details

    • waitForLock

      void waitForLock(Duration waitTime)
      Wait for the given waitTime to acquire the lock
      Parameters:
      waitTime - the duration to wait before throwing an exception
    • acquireLock

      boolean acquireLock()
      Acquire the lock.
      Returns:
      true if the lock was acquired, false otherwise
    • acquireLock

      boolean acquireLock(Duration lockForceAcquireAfter)
      Acquire the lock. The lockForceAcquireAfter will be used to acquire an expired lock
      Parameters:
      lockForceAcquireAfter - the amount of time after which the lock should be acquired
      Returns:
      true if the lock was acquired, false otherwise
    • releaseLock

      void releaseLock()
      Release the lock.
    • releaseAndDeleteLock

      void releaseAndDeleteLock()
      Release the lock and delete the resources for the lock if needed.
    • waitForLockRunAndRelease

      <T> T waitForLockRunAndRelease(Duration waitTime, Supplier<T> supplier)
      Wait to acquire a lock, once a lock is acquired execute the supplier and release finally the lock.
      Parameters:
      waitTime - the duration to wait before throwing an exception
      supplier - the supplier to be executed once the lock is acquired
      Returns:
      the result from the supplier