Package com.coditory.sherlock
Class RxSherlockStub
java.lang.Object
com.coditory.sherlock.RxSherlockStub
- All Implemented Interfaces:
RxSherlock
Use to stub
RxSherlock in tests.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>Creates a distributed lock.com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>Create a distributed overriding lock.com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>Creates a distributed reentrant lock.io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult>Force releases all acquired locks.io.reactivex.Single<com.coditory.sherlock.connector.InitializationResult>Initializes underlying infrastructure.static RxSherlockStubMake the stub produce acquired locks by defaultwithLock(RxDistributedLock lock) Make the stub produce return a predefined lock.static RxSherlockStubMake the stub produce released locks by defaultMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.coditory.sherlock.RxSherlock
createLock, createOverridingLock, createReentrantLock, forceReleaseLock
-
Constructor Details
-
RxSherlockStub
public RxSherlockStub()
-
-
Method Details
-
withReleasedLocks
Make the stub produce released locks by default- Returns:
- the instance
-
withAcquiredLocks
Make the stub produce acquired locks by default- Returns:
- the instance
-
withLock
Make the stub produce return a predefined lock.- Parameters:
lock- returned when creating a lock with the same id- Returns:
- the instance
-
initialize
public io.reactivex.Single<com.coditory.sherlock.connector.InitializationResult> initialize()Description copied from interface:RxSherlockInitializes 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:
initializein interfaceRxSherlock- Returns:
InitializationResult.SUCCESSif initialization was successful, otherwiseInitializationResult.FAILUREis returned
-
createLock
Description copied from interface:RxSherlockCreates a distributed lock. Created lock may be acquired only once by the same owner:assert lock.acquire() == true assert lock.acquire() == false- Specified by:
createLockin interfaceRxSherlock- Returns:
- the lock builder
-
createReentrantLock
Description copied from interface:RxSherlockCreates 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:
createReentrantLockin interfaceRxSherlock- Returns:
- the reentrant lock builder
-
createOverridingLock
Description copied from interface:RxSherlockCreate 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.
- Specified by:
createOverridingLockin interfaceRxSherlock- Returns:
- the overriding lock builder
-
forceReleaseAllLocks
public io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult> forceReleaseAllLocks()Description copied from interface:RxSherlockForce releases all acquired locks.It could be used for administrative actions.
- Specified by:
forceReleaseAllLocksin interfaceRxSherlock- Returns:
ReleaseResult.SUCCESSif lock was released, otherwiseReleaseResult.FAILUREis returned
-