Interface LockService
-
- All Superinterfaces:
Distributable
- All Known Implementing Classes:
DefaultLocalJvmLockService
public interface LockService extends Distributable
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
isLocked(String lockName)
Checks to see if a lock has already been acquired for the referenced object.String
lock(String lockName)
Attempts to create a lock based on the lock name.void
unlock(String lockName, String lockKey)
Attempts to unlock the lock for the given lock name.-
Methods inherited from interface com.broadleafcommerce.search.index.core.Distributable
isDistributed
-
-
-
-
Method Detail
-
isLocked
boolean isLocked(@NonNull String lockName)
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
-
lock
String lock(@NonNull String lockName) throws LockException
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
-
unlock
void unlock(@NonNull String lockName, @NonNull String lockKey) throws LockException
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
-
-