Class DefaultLocalJvmLockService
java.lang.Object
com.broadleafcommerce.search.index.core.DefaultLocalJvmLockService
- All Implemented Interfaces:
Distributable
,LockService
This component allows for the tracking of a lock reference for a single process ID or reference.
By definition, this implementation is non-distributed and only works in a single JVM. Callers
should obtain a lock and then call lock.tryLock()
or equivalent. All, locks must be
unlocked. The exact number of unlock calls must be made for successful lock
and
tryLock
calls. By default, this returns a ReentrantLock
, which is not
distributed, and therefore not for use when there are multiple Indexer application nodes.
However, ReentrantLock
can be used for testing or when there is guaranteed to be only 1
Indexer node.
- Author:
- Kelly Tisdell (ktisdell)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates if this component is designed for use across JVMs.boolean
Checks to see if a lock has already been acquired for the referenced object.obtainLockInstance
(String lockName) This returns an instance ofLock
, specifically for use with the specified lock name.protected ReentrantLock
obtainLockInterally
(String lockName) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.search.index.core.LockService
isLocked, lock, obtainLockInstance, unlock
-
Constructor Details
-
DefaultLocalJvmLockService
public DefaultLocalJvmLockService()
-
-
Method Details
-
isDistributed
public final boolean isDistributed()Description copied from interface:Distributable
Indicates if this component is designed for use across JVMs.- Specified by:
isDistributed
in interfaceDistributable
- Returns:
- whether this component can be distributed across JVMs
-
isLocked
Description copied from interface:LockService
Checks to see if a lock has already been acquired for the referenced object.- Specified by:
isLocked
in interfaceLockService
- Parameters:
lockName
- the lock to check- Returns:
- whether the lock has already been acquired
-
obtainLockInstance
Description copied from interface:LockService
This returns an instance ofLock
, specifically for use with the specified lock name. This method should not lock or unlock, but should provide a sharedLock
instance that can be used across threads. This method MUST return a lock with reentrant capabilities, meaning that a thread can lock the lock more than once before unlocking it. It is important, though, that a lock is unlocked as many times as it is locked. This method returns a particular instance of aLock
implementation, but users of the lock are responsible for locking and unlocking it.- Specified by:
obtainLockInstance
in interfaceLockService
- Parameters:
lockName
- the unique name for which to obtain a lock- Returns:
- a shared
Lock
instance - See Also:
-
ReentrantLock
ReentrantDistributedZookeeprLock
IgniteLock
-
obtainLockInterally
-