Package com.coditory.sherlock
Interface Sherlock
- All Known Implementing Classes:
SherlockStub
public interface Sherlock
Manages distributed locks.
-
Method Summary
Modifier and TypeMethodDescriptioncom.coditory.sherlock.DistributedLockBuilder<DistributedLock>
Creates a distributed lock.default DistributedLock
createLock
(String lockId) Creates a lock with default configuration.com.coditory.sherlock.DistributedLockBuilder<DistributedLock>
Create a distributed overriding lock.default DistributedLock
createOverridingLock
(String lockId) Creates an overriding lock with default configuration.com.coditory.sherlock.DistributedLockBuilder<DistributedLock>
Creates a distributed reentrant lock.default DistributedLock
createReentrantLock
(String lockId) Creates a reentrant lock with default configuration.boolean
Force releases all acquired locks.default boolean
forceReleaseLock
(String lockId) Force releases a lock.void
Initializes underlying infrastructure.
-
Method Details
-
initialize
void initialize()Initializes underlying infrastructure. If this method is not invoked explicitly then it can be invoked implicitly when acquiring or releasing a lock for the first time.Most often initialization is related with creating indexes and tables.
-
createLock
com.coditory.sherlock.DistributedLockBuilder<DistributedLock> createLock()Creates a distributed lock. Created lock may be acquired only once by the same owner:assert lock.acquire() == true assert lock.acquire() == false
- Returns:
- the lock builder
-
createLock
Creates a lock with default configuration.- Parameters:
lockId
- lock identifier- Returns:
- the lock
- See Also:
-
createReentrantLock
com.coditory.sherlock.DistributedLockBuilder<DistributedLock> createReentrantLock()Creates a distributed reentrant lock. Reentrant lock may be acquired multiple times by the same owner:assert reentrantLock.acquire() == true assert reentrantLock.acquire() == true
- Returns:
- the reentrant lock builder
-
createReentrantLock
Creates a reentrant lock with default configuration.- Parameters:
lockId
- lock identifier- Returns:
- the reentrant lock
- See Also:
-
createOverridingLock
com.coditory.sherlock.DistributedLockBuilder<DistributedLock> createOverridingLock()Create a distributed overriding lock. Returned lock may acquire or release any other lock without checking its state:assert someLock.acquire() == true assert overridingLock.acquire() == true
It could be used for administrative actions.
- Returns:
- the overriding lock builder
-
createOverridingLock
Creates an overriding lock with default configuration.- Parameters:
lockId
- lock identifier- Returns:
- the overriding lock
- See Also:
-
forceReleaseAllLocks
boolean forceReleaseAllLocks()Force releases all acquired locks.It could be used for administrative actions.
- Returns:
- true if any lock was released
-
forceReleaseLock
Force releases a lock.It could be used for administrative actions.
- Parameters:
lockId
- lock identifier- Returns:
- true if lock was released
-