Interface DistributedLock
- All Superinterfaces:
Lock
- All Known Implementing Classes:
ReentrantDistributedZookeeperLock
Interface to define a lock as distributed and safe to use across nodes or JVMs.
- Author:
- Kelly Tisdell
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classRuntimeException to identify that there was an issue obtaining or otherwise releasing a distributed lock. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault property name to determine, globally, whether this environment (JVM) can obtain a lock of this type. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates if the current thread, JVM, or environment can use this lock.booleanIndicates if the current thread holds the lock.Methods inherited from interface java.util.concurrent.locks.Lock
lock, lockInterruptibly, newCondition, tryLock, tryLock, unlock
-
Field Details
-
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 theLockinterface. For example if this method returns false and someone callsLock.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
Environmentobject.- Returns:
-
currentThreadHoldsLock
boolean currentThreadHoldsLock()Indicates if the current thread holds the lock.- Returns:
-