Package com.coditory.sherlock
Class RxDistributedLockMock
java.lang.Object
com.coditory.sherlock.RxDistributedLockMock
- All Implemented Interfaces:
RxDistributedLock
-
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.Single<com.coditory.sherlock.connector.AcquireResult>acquire()Try to acquire the lock.io.reactivex.Single<com.coditory.sherlock.connector.AcquireResult>Try to acquire the lock for a given duration.static RxDistributedLockMockstatic RxDistributedLockMockacquiredInMemoryLock(String lockId) static RxDistributedLockMockstatic RxDistributedLockMockacquiredReentrantInMemoryLock(String lockId) io.reactivex.Single<com.coditory.sherlock.connector.AcquireResult>Try to acquire the lock without expiring date.intgetId()Return the lock id.static RxDistributedLockMocklockStub(boolean result) static RxDistributedLockMocklockStub(boolean acquireResult, boolean releaseResult) static RxDistributedLockMockstatic RxDistributedLockMockintintio.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult>release()Try to release the lock.static RxDistributedLockMockstatic RxDistributedLockMockreleasedInMemoryLock(String lockId) static RxDistributedLockMockstatic RxDistributedLockMockreleasedReentrantInMemoryLock(String lockId) intreleases()static RxDistributedLockMockstatic RxDistributedLockMocksequencedLock(List<Boolean> acquireResults, List<Boolean> releaseResults) intintbooleanbooleanbooleanbooleanbooleanbooleanbooleanMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.coditory.sherlock.RxDistributedLock
acquireAndExecute, acquireAndExecute, acquireForeverAndExecute, releaseAndExecute
-
Method Details
-
releasedInMemoryLock
-
acquiredInMemoryLock
-
releasedInMemoryLock
-
acquiredInMemoryLock
-
releasedReentrantInMemoryLock
-
acquiredReentrantInMemoryLock
-
releasedReentrantInMemoryLock
-
acquiredReentrantInMemoryLock
-
lockStub
-
lockStub
-
lockStub
-
lockStub
public static RxDistributedLockMock lockStub(String lockId, boolean acquireResult, boolean releaseResult) -
sequencedLock
public static RxDistributedLockMock sequencedLock(List<Boolean> acquireResults, List<Boolean> releaseResults) -
sequencedLock
-
getId
Description copied from interface:RxDistributedLockReturn the lock id.- Specified by:
getIdin interfaceRxDistributedLock- Returns:
- the lock id
-
acquire
public io.reactivex.Single<com.coditory.sherlock.connector.AcquireResult> acquire()Description copied from interface:RxDistributedLockTry to acquire the lock. Lock is acquired for a pre configured duration.- Specified by:
acquirein interfaceRxDistributedLock- Returns:
AcquireResult.SUCCESSif lock is acquired
-
acquire
public io.reactivex.Single<com.coditory.sherlock.connector.AcquireResult> acquire(Duration duration) Description copied from interface:RxDistributedLockTry to acquire the lock for a given duration.- Specified by:
acquirein interfaceRxDistributedLock- Parameters:
duration- how much time must pass for the acquired lock to expire- Returns:
AcquireResult.SUCCESSif lock is acquired
-
acquireForever
public io.reactivex.Single<com.coditory.sherlock.connector.AcquireResult> acquireForever()Description copied from interface:RxDistributedLockTry to acquire the lock without expiring date.It is potentially dangerous. Lookout for a situation when the lock owning instance goes down with out releasing the lock.
- Specified by:
acquireForeverin interfaceRxDistributedLock- Returns:
AcquireResult.SUCCESSif lock is acquired
-
release
public io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult> release()Description copied from interface:RxDistributedLockTry to release the lock.- Specified by:
releasein interfaceRxDistributedLock- Returns:
ReleaseResult.SUCCESSif lock was released by this method invocation. If lock has expired or was released earlier thenReleaseResult.FAILUREis returned.
-
successfulReleases
public int successfulReleases()- Returns:
- the count of successful releases
-
successfulAcquisitions
public int successfulAcquisitions()- Returns:
- the count of successful acquisitions
-
releases
public int releases()- Returns:
- the count of all releases (successful and unsuccessful)
-
acquisitions
public int acquisitions()- Returns:
- the count of all acquisitions (successful and unsuccessful)
-
rejectedReleases
public int rejectedReleases()- Returns:
- the count of rejected releases
-
rejectedAcquisitions
public int rejectedAcquisitions()- Returns:
- the count of rejected acquisitions
-
wasAcquired
public boolean wasAcquired()- Returns:
- true if lock was successfully acquired at least once
-
wasReleased
public boolean wasReleased()- Returns:
- true if lock was successfully released at least once
-
wasAcquiredAndReleased
public boolean wasAcquiredAndReleased()- Returns:
- true if lock was successfully acquired and released
-
wasAcquireRejected
public boolean wasAcquireRejected()- Returns:
- true if lock was acquired without success at least once
-
wasReleaseRejected
public boolean wasReleaseRejected()- Returns:
- true if lock was released without success at least once
-
wasAcquireInvoked
public boolean wasAcquireInvoked()- Returns:
- true if acquire operation was invoked at least once
-
wasReleaseInvoked
public boolean wasReleaseInvoked()- Returns:
- true if release operation was invoked at least once
-