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 booleanIndicates if this component is designed for use across JVMs.booleanChecks 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 ReentrantLockobtainLockInterally(String lockName) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:DistributableIndicates if this component is designed for use across JVMs.- Specified by:
isDistributedin interfaceDistributable- Returns:
- whether this component can be distributed across JVMs
-
isLocked
Description copied from interface:LockServiceChecks to see if a lock has already been acquired for the referenced object.- Specified by:
isLockedin interfaceLockService- Parameters:
lockName- the lock to check- Returns:
- whether the lock has already been acquired
-
obtainLockInstance
Description copied from interface:LockServiceThis returns an instance ofLock, specifically for use with the specified lock name. This method should not lock or unlock, but should provide a sharedLockinstance 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 aLockimplementation, but users of the lock are responsible for locking and unlocking it.- Specified by:
obtainLockInstancein interfaceLockService- Parameters:
lockName- the unique name for which to obtain a lock- Returns:
- a shared
Lockinstance - See Also:
-
ReentrantLockReentrantDistributedZookeeprLockIgniteLock
-
obtainLockInterally
-