Package com.broadleafcommerce.search.api
Interface DistributedLock
- All Superinterfaces:
- Lock
Interface to indicate a distributed lock, or one that can be shared across JVMs. Implementors of
 this interface must use the lock semantics of the 
Lock interface, but must guarantee them
 in a distributed environment - typically with the Lock backed by a database, cache, ZooKeeper,
 shared file system, etc.- Author:
- Kelly Tisdell (ktisdell)
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringDefault property name to determine, globally, whether this environment (JVM) can obtain a lock of this type.
- 
Method SummaryModifier 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.Locklock, lockInterruptibly, newCondition, tryLock, tryLock, unlock
- 
Field Details- 
GLOBAL_ENV_CAN_OBTAIN_LOCK_PROPERTY_NAMEDefault property name to determine, globally, whether this environment (JVM) can obtain a lock of this type.
 
- 
- 
Method Details- 
canParticipateboolean 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, java.util.concurrent.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'sEnvironmentobject.- Returns:
- whether or not this environment can participate in acquiring this lock. If not, normal lock semantics apply, but the lock will never be acquired.
 
- 
currentThreadHoldsLockboolean currentThreadHoldsLock()Indicates if the current thread holds the lock.- Returns:
- returns true if the current thread holds this lock. false, otherwise.
 
 
-