Package com.coditory.sherlock
Class ReactorDistributedLockMock
- java.lang.Object
-
- com.coditory.sherlock.ReactorDistributedLockMock
-
- All Implemented Interfaces:
ReactorDistributedLock
public final class ReactorDistributedLockMock extends java.lang.Object implements ReactorDistributedLock
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description reactor.core.publisher.Mono<com.coditory.sherlock.connector.AcquireResult>
acquire()
Try to acquire the lock.reactor.core.publisher.Mono<com.coditory.sherlock.connector.AcquireResult>
acquire(java.time.Duration duration)
Try to acquire the lock for a given duration.static ReactorDistributedLockMock
acquiredInMemoryLock()
static ReactorDistributedLockMock
acquiredInMemoryLock(java.lang.String lockId)
static ReactorDistributedLockMock
acquiredReentrantInMemoryLock()
static ReactorDistributedLockMock
acquiredReentrantInMemoryLock(java.lang.String lockId)
reactor.core.publisher.Mono<com.coditory.sherlock.connector.AcquireResult>
acquireForever()
Try to acquire the lock without expiring date.int
acquisitions()
java.lang.String
getId()
Return the lock id.static ReactorDistributedLockMock
lockStub(boolean result)
static ReactorDistributedLockMock
lockStub(boolean acquireResult, boolean releaseResult)
static ReactorDistributedLockMock
lockStub(java.lang.String lockId, boolean result)
static ReactorDistributedLockMock
lockStub(java.lang.String lockId, boolean acquireResult, boolean releaseResult)
int
rejectedAcquisitions()
int
rejectedReleases()
reactor.core.publisher.Mono<com.coditory.sherlock.connector.ReleaseResult>
release()
Try to release the lock.static ReactorDistributedLockMock
releasedInMemoryLock()
static ReactorDistributedLockMock
releasedInMemoryLock(java.lang.String lockId)
static ReactorDistributedLockMock
releasedReentrantInMemoryLock()
static ReactorDistributedLockMock
releasedReentrantInMemoryLock(java.lang.String lockId)
int
releases()
static ReactorDistributedLockMock
sequencedLock(java.lang.String lockId, java.util.List<java.lang.Boolean> acquireResults, java.util.List<java.lang.Boolean> releaseResults)
static ReactorDistributedLockMock
sequencedLock(java.util.List<java.lang.Boolean> acquireResults, java.util.List<java.lang.Boolean> releaseResults)
int
successfulAcquisitions()
int
successfulReleases()
boolean
wasAcquired()
boolean
wasAcquiredAndReleased()
boolean
wasAcquireInvoked()
boolean
wasAcquireRejected()
boolean
wasReleased()
boolean
wasReleaseInvoked()
boolean
wasReleaseRejected()
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.coditory.sherlock.ReactorDistributedLock
acquireAndExecute, acquireAndExecute, acquireForeverAndExecute, releaseAndExecute
-
-
-
-
Method Detail
-
releasedInMemoryLock
public static ReactorDistributedLockMock releasedInMemoryLock()
-
acquiredInMemoryLock
public static ReactorDistributedLockMock acquiredInMemoryLock()
-
releasedInMemoryLock
public static ReactorDistributedLockMock releasedInMemoryLock(java.lang.String lockId)
-
acquiredInMemoryLock
public static ReactorDistributedLockMock acquiredInMemoryLock(java.lang.String lockId)
-
releasedReentrantInMemoryLock
public static ReactorDistributedLockMock releasedReentrantInMemoryLock()
-
acquiredReentrantInMemoryLock
public static ReactorDistributedLockMock acquiredReentrantInMemoryLock()
-
releasedReentrantInMemoryLock
public static ReactorDistributedLockMock releasedReentrantInMemoryLock(java.lang.String lockId)
-
acquiredReentrantInMemoryLock
public static ReactorDistributedLockMock acquiredReentrantInMemoryLock(java.lang.String lockId)
-
lockStub
public static ReactorDistributedLockMock lockStub(boolean result)
-
lockStub
public static ReactorDistributedLockMock lockStub(boolean acquireResult, boolean releaseResult)
-
lockStub
public static ReactorDistributedLockMock lockStub(java.lang.String lockId, boolean result)
-
lockStub
public static ReactorDistributedLockMock lockStub(java.lang.String lockId, boolean acquireResult, boolean releaseResult)
-
sequencedLock
public static ReactorDistributedLockMock sequencedLock(java.util.List<java.lang.Boolean> acquireResults, java.util.List<java.lang.Boolean> releaseResults)
-
sequencedLock
public static ReactorDistributedLockMock sequencedLock(java.lang.String lockId, java.util.List<java.lang.Boolean> acquireResults, java.util.List<java.lang.Boolean> releaseResults)
-
getId
public java.lang.String getId()
Description copied from interface:ReactorDistributedLock
Return the lock id.- Specified by:
getId
in interfaceReactorDistributedLock
- Returns:
- the lock id
-
acquire
public reactor.core.publisher.Mono<com.coditory.sherlock.connector.AcquireResult> acquire()
Description copied from interface:ReactorDistributedLock
Try to acquire the lock. Lock is acquired for a pre configured duration.- Specified by:
acquire
in interfaceReactorDistributedLock
- Returns:
AcquireResult.SUCCESS
if lock is acquired
-
acquire
public reactor.core.publisher.Mono<com.coditory.sherlock.connector.AcquireResult> acquire(java.time.Duration duration)
Description copied from interface:ReactorDistributedLock
Try to acquire the lock for a given duration.- Specified by:
acquire
in interfaceReactorDistributedLock
- Parameters:
duration
- how much time must pass for the acquired lock to expire- Returns:
AcquireResult.SUCCESS
if lock is acquired
-
acquireForever
public reactor.core.publisher.Mono<com.coditory.sherlock.connector.AcquireResult> acquireForever()
Description copied from interface:ReactorDistributedLock
Try 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:
acquireForever
in interfaceReactorDistributedLock
- Returns:
AcquireResult.SUCCESS
if lock is acquired
-
release
public reactor.core.publisher.Mono<com.coditory.sherlock.connector.ReleaseResult> release()
Description copied from interface:ReactorDistributedLock
Try to release the lock.- Specified by:
release
in interfaceReactorDistributedLock
- Returns:
ReleaseResult.SUCCESS
if lock was released by this method invocation. If lock has expired or was released earlier thenReleaseResult.FAILURE
is 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
-
-