Package com.coditory.sherlock
Interface ReactiveSherlock
-
public interface ReactiveSherlockManages distributed locks using reactive api.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description com.coditory.sherlock.DistributedLockBuilder<ReactiveDistributedLock>createLock()Creates a distributed lock.default ReactiveDistributedLockcreateLock(java.lang.String lockId)Creates a lock with default configuration.com.coditory.sherlock.DistributedLockBuilder<ReactiveDistributedLock>createOverridingLock()Create a distributed overriding lock.default ReactiveDistributedLockcreateOverridingLock(java.lang.String lockId)Creates an overriding lock with default configuration.com.coditory.sherlock.DistributedLockBuilder<ReactiveDistributedLock>createReentrantLock()Creates a distributed reentrant lock.default ReactiveDistributedLockcreateReentrantLock(java.lang.String lockId)Creates a reentrant lock with default configuration.java.util.concurrent.Flow.Publisher<ReleaseResult>forceReleaseAllLocks()Force releases all acquired locks.default java.util.concurrent.Flow.Publisher<ReleaseResult>forceReleaseLock(java.lang.String lockId)Force releases a lock.java.util.concurrent.Flow.Publisher<InitializationResult>initialize()Initializes underlying infrastructure.
-
-
-
Method Detail
-
initialize
java.util.concurrent.Flow.Publisher<InitializationResult> 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.
- Returns:
InitializationResult.SUCCESSif initialization was successful, otherwiseInitializationResult.FAILUREis returned
-
createLock
com.coditory.sherlock.DistributedLockBuilder<ReactiveDistributedLock> 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
default ReactiveDistributedLock createLock(java.lang.String lockId)
Creates a lock with default configuration.- Parameters:
lockId- lock identifier- Returns:
- the lock
- See Also:
createLock()
-
createReentrantLock
com.coditory.sherlock.DistributedLockBuilder<ReactiveDistributedLock> 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
default ReactiveDistributedLock createReentrantLock(java.lang.String lockId)
Creates a reentrant lock with default configuration.- Parameters:
lockId- lock identifier- Returns:
- the reentrant lock
- See Also:
createReentrantLock()
-
createOverridingLock
com.coditory.sherlock.DistributedLockBuilder<ReactiveDistributedLock> 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() == trueIt could be used for administrative actions.
- Returns:
- the overriding lock builder
-
createOverridingLock
default ReactiveDistributedLock createOverridingLock(java.lang.String lockId)
Creates an overriding lock with default configuration.- Parameters:
lockId- lock identifier- Returns:
- the overriding lock
- See Also:
createOverridingLock()
-
forceReleaseAllLocks
java.util.concurrent.Flow.Publisher<ReleaseResult> forceReleaseAllLocks()
Force releases all acquired locks.It could be used for administrative actions.
- Returns:
ReleaseResult.SUCCESSif lock was released, otherwiseReleaseResult.FAILUREis returned
-
forceReleaseLock
default java.util.concurrent.Flow.Publisher<ReleaseResult> forceReleaseLock(java.lang.String lockId)
Force releases a lock.It could be used for administrative actions.
- Parameters:
lockId- lock identifier- Returns:
ReleaseResult.SUCCESSif lock was released, otherwiseReleaseResult.FAILUREis returned
-
-