Interface DistributedLock

All Superinterfaces:
Lock
All Known Implementing Classes:
ReentrantDistributedZookeeperLock

public interface DistributedLock extends Lock
Interface to define a lock as distributed and safe to use across nodes or JVMs.
Author:
Kelly Tisdell
  • Field Details

    • GLOBAL_ENV_CAN_OBTAIN_LOCK_PROPERTY_NAME

      static final String GLOBAL_ENV_CAN_OBTAIN_LOCK_PROPERTY_NAME
      Default property name to determine, globally, whether this environment (JVM) can obtain a lock of this type.
  • Method Details

    • canParticipate

      boolean canParticipate()
      Indicates if the current thread, JVM, or environment can use this lock. Callers may call this method to know whether they can obtain a lock. Internally, implementations must continue to respect the normal lock semantics provided by the Lock interface. For example if this method returns false and someone calls Lock.lockInterruptibly(), then the thread must block interruptably, but should never provide a lock. Similarly, a call to {@link DistributedLock#tryLock(5000L, TimeUnit.MILLISECONDS)}, then the thread must block for 5000 milliseconds, and then return false.

      This allows someone to determine if a Thread, a JVM, an environment, etc. can ever obtain a lock. Implementations are typically driven by a property, e.g. provided by Spring's Environment object.

      Returns:
    • currentThreadHoldsLock

      boolean currentThreadHoldsLock()
      Indicates if the current thread holds the lock.
      Returns: