Package com.coditory.sherlock
Class ReactorSherlockStub
- java.lang.Object
-
- com.coditory.sherlock.ReactorSherlockStub
-
- All Implemented Interfaces:
ReactorSherlock
public final class ReactorSherlockStub extends java.lang.Object implements ReactorSherlock
Use to stubReactorSherlock
in tests.
-
-
Constructor Summary
Constructors Constructor Description ReactorSherlockStub()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock>
createLock()
Creates a distributed lock.com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock>
createOverridingLock()
Create a distributed overriding lock.com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock>
createReentrantLock()
Creates a distributed reentrant lock.reactor.core.publisher.Mono<com.coditory.sherlock.connector.ReleaseResult>
forceReleaseAllLocks()
Force releases all acquired locks.reactor.core.publisher.Mono<com.coditory.sherlock.connector.InitializationResult>
initialize()
Initializes underlying infrastructure.static ReactorSherlockStub
withAcquiredLocks()
Make the stub produce acquired locks by defaultReactorSherlockStub
withLock(ReactorDistributedLock lock)
Make the stub produce return a predefined lock.static ReactorSherlockStub
withReleasedLocks()
Make the stub produce released locks by default-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.coditory.sherlock.ReactorSherlock
createLock, createOverridingLock, createReentrantLock, forceReleaseLock
-
-
-
-
Method Detail
-
withReleasedLocks
public static ReactorSherlockStub withReleasedLocks()
Make the stub produce released locks by default- Returns:
- the instance
-
withAcquiredLocks
public static ReactorSherlockStub withAcquiredLocks()
Make the stub produce acquired locks by default- Returns:
- the instance
-
withLock
public ReactorSherlockStub withLock(ReactorDistributedLock lock)
Make the stub produce return a predefined lock.- Parameters:
lock
- returned when creating a lock with the same id- Returns:
- the instance
-
initialize
public reactor.core.publisher.Mono<com.coditory.sherlock.connector.InitializationResult> initialize()
Description copied from interface:ReactorSherlock
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.
- Specified by:
initialize
in interfaceReactorSherlock
- Returns:
InitializationResult.SUCCESS
if initialization was successful, otherwiseInitializationResult.FAILURE
is returned
-
createLock
public com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock> createLock()
Description copied from interface:ReactorSherlock
Creates a distributed lock. Created lock may be acquired only once by the same owner:assert lock.acquire() == true assert lock.acquire() == false
- Specified by:
createLock
in interfaceReactorSherlock
- Returns:
- the lock builder
-
createReentrantLock
public com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock> createReentrantLock()
Description copied from interface:ReactorSherlock
Creates a distributed reentrant lock. Reentrant lock may be acquired multiple times by the same owner:assert reentrantLock.acquire() == true assert reentrantLock.acquire() == true
- Specified by:
createReentrantLock
in interfaceReactorSherlock
- Returns:
- the reentrant lock builder
-
createOverridingLock
public com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock> createOverridingLock()
Description copied from interface:ReactorSherlock
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.
- Specified by:
createOverridingLock
in interfaceReactorSherlock
- Returns:
- the overriding lock builder
-
forceReleaseAllLocks
public reactor.core.publisher.Mono<com.coditory.sherlock.connector.ReleaseResult> forceReleaseAllLocks()
Description copied from interface:ReactorSherlock
Force releases all acquired locks.It could be used for administrative actions.
- Specified by:
forceReleaseAllLocks
in interfaceReactorSherlock
- Returns:
ReleaseResult.SUCCESS
if lock was released, otherwiseReleaseResult.FAILURE
is returned
-
-