Interface LockService
- All Superinterfaces:
Distributable
- All Known Implementing Classes:
DefaultLocalJvmLockService
Basic LockService interface, specifically to be used by the Index processes to ensure that no
other threads or nodes can start a specific full index process.
- Author:
- Kelly Tisdell (ktisdell)
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanisLocked(com.broadleafcommerce.search.api.type.IndexableType indexableType) Uses the providedIndexableTypeto find the lock.booleanChecks to see if a lock has already been acquired for the referenced object.default StringDeprecated.default LockobtainLockInstance(com.broadleafcommerce.search.api.type.IndexableType indexableType) Provides a lock instance for the name provided by the providedIndexableType.obtainLockInstance(String lockName) This returns an instance ofLock, specifically for use with the specified lock name.default voidDeprecated.Methods inherited from interface com.broadleafcommerce.search.index.core.Distributable
isDistributed
-
Method Details
-
isLocked
Checks to see if a lock has already been acquired for the referenced object.- Parameters:
lockName- the lock to check- Returns:
- whether the lock has already been acquired
-
isLocked
default boolean isLocked(@NonNull com.broadleafcommerce.search.api.type.IndexableType indexableType) Uses the providedIndexableTypeto find the lock. By default, this uses theIndexableType.getTopLevelAncestor()to determine the lock name. -
lock
Deprecated.Attempts to create a lock based on the lock name. This does not necessarily synchronize or otherwise block threads. It just creates a lock reference for the for the specified lock name. Additional attempts to create a lock with the same name will fail until a call is made to the unlock method to unlock the lock for the specific lock name.- Parameters:
lockName- the lock to create- Returns:
- the key for the created lock
- Throws:
LockException- if a lock could not be obtained- See Also:
-
unlock
@Deprecated default void unlock(@NonNull String lockName, @NonNull String lockKey) throws LockException Deprecated.Attempts to unlock the lock for the given lock name.- Parameters:
lockName- the lock to unlocklockKey- the key for the lock- Throws:
LockException- if the lock could not be unlocked- See Also:
-
obtainLockInstance
This 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.- Parameters:
lockName- the unique name for which to obtain a lock- Returns:
- a shared
Lockinstance - See Also:
-
ReentrantLockReentrantDistributedZookeeprLockIgniteLock
-
obtainLockInstance
default Lock obtainLockInstance(@NonNull com.broadleafcommerce.search.api.type.IndexableType indexableType) Provides a lock instance for the name provided by the providedIndexableType. In particular, ifIndexableType.getTopLevelAncestor()is not null, then the parent's type will be used. Otherwise, the original argument's type will be used.- Parameters:
indexableType- the provided type- Returns:
- a shared
Lockinstance
-