public class RedissonSemaphoreReactive extends Object implements RSemaphoreReactive
Constructor and Description |
---|
RedissonSemaphoreReactive(CommandReactiveExecutor connectionManager,
String name,
SemaphorePubSub semaphorePubSub) |
Modifier and Type | Method and Description |
---|---|
org.reactivestreams.Publisher<Void> |
acquire()
Acquires a permit from this semaphore.
|
org.reactivestreams.Publisher<Void> |
acquire(int permits)
Acquires the given number of permits, if they are available,
and returns immediately, reducing the number of available permits
by the given amount.
|
org.reactivestreams.Publisher<Boolean> |
clearExpire()
Clear an expire timeout or expire date for object in mode.
|
protected RLockAsync |
createLock(CommandAsyncExecutor connectionManager,
String name,
UUID id) |
org.reactivestreams.Publisher<Boolean> |
delete()
Delete object in mode
|
protected void |
encode(Collection<Object> params,
Collection<?> values) |
protected io.netty.buffer.ByteBuf |
encode(Object value) |
protected io.netty.buffer.ByteBuf |
encodeMapKey(Object value) |
protected io.netty.buffer.ByteBuf |
encodeMapValue(Object value) |
org.reactivestreams.Publisher<Boolean> |
expire(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object in mode.
|
org.reactivestreams.Publisher<Boolean> |
expireAt(Date timestamp)
Set an expire date for object in mode.
|
org.reactivestreams.Publisher<Boolean> |
expireAt(long timestamp)
Set an expire date for object in mode.
|
Codec |
getCodec() |
String |
getName() |
org.reactivestreams.Publisher<Boolean> |
isExists()
Check object existence
|
org.reactivestreams.Publisher<Void> |
migrate(String host,
int port,
int database)
Transfer a object from a source Redis instance to a destination Redis instance
in mode
|
org.reactivestreams.Publisher<Boolean> |
move(int database)
Move object to another database in mode
|
protected <V> reactor.core.publisher.Mono<V> |
newSucceeded(V result) |
<R> org.reactivestreams.Publisher<R> |
reactive(Supplier<RFuture<R>> supplier) |
org.reactivestreams.Publisher<Void> |
reducePermits(int permits)
Shrinks the number of available permits by the indicated
reduction.
|
org.reactivestreams.Publisher<Void> |
release()
Releases a permit, returning it to the semaphore.
|
org.reactivestreams.Publisher<Void> |
release(int permits)
Releases the given number of permits, returning them to the semaphore.
|
org.reactivestreams.Publisher<Long> |
remainTimeToLive()
Get remaining time to live of object in milliseconds.
|
org.reactivestreams.Publisher<Void> |
rename(String newName)
Rename current object key to
newName
in mode |
org.reactivestreams.Publisher<Boolean> |
renamenx(String newName)
Rename current object key to
newName
in mode only if new key is not exists |
org.reactivestreams.Publisher<Boolean> |
tryAcquire()
Acquires a permit only if one is available at the
time of invocation.
|
org.reactivestreams.Publisher<Boolean> |
tryAcquire(int permits)
Acquires the given number of permits only if all are available at the
time of invocation.
|
org.reactivestreams.Publisher<Boolean> |
tryAcquire(int permits,
long waitTime,
TimeUnit unit)
Acquires the given number of permits only if all are available
within the given waiting time.
|
org.reactivestreams.Publisher<Boolean> |
tryAcquire(long waitTime,
TimeUnit unit)
Acquires a permit, if one is available and returns immediately,
with the value
true ,
reducing the number of available permits by one. |
org.reactivestreams.Publisher<Boolean> |
trySetPermits(int permits)
Sets number of permits.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearExpire, expire, expireAt, expireAt, remainTimeToLive
public RedissonSemaphoreReactive(CommandReactiveExecutor connectionManager, String name, SemaphorePubSub semaphorePubSub)
protected RLockAsync createLock(CommandAsyncExecutor connectionManager, String name, UUID id)
public org.reactivestreams.Publisher<Boolean> tryAcquire()
RSemaphoreReactive
Acquires a permit, if one is available and returns immediately,
with the value true
,
reducing the number of available permits by one.
If no permit is available then this method will return
immediately with the value false
.
tryAcquire
in interface RSemaphoreReactive
true
if a permit was acquired and false
otherwisepublic org.reactivestreams.Publisher<Boolean> tryAcquire(int permits)
RSemaphoreReactive
Acquires a permits, if all are available and returns immediately,
with the value true
,
reducing the number of available permits by given number of permits.
If no permits are available then this method will return
immediately with the value false
.
tryAcquire
in interface RSemaphoreReactive
permits
- the number of permits to acquiretrue
if a permit was acquired and false
otherwisepublic org.reactivestreams.Publisher<Void> acquire()
RSemaphoreReactive
Acquires a permit, if one is available and returns immediately, reducing the number of available permits by one.
acquire
in interface RSemaphoreReactive
public org.reactivestreams.Publisher<Void> acquire(int permits)
RSemaphoreReactive
acquire
in interface RSemaphoreReactive
permits
- the number of permits to acquirepublic org.reactivestreams.Publisher<Void> release()
RSemaphoreReactive
Releases a permit, increasing the number of available permits by one. If any threads of Redisson client are trying to acquire a permit, then one is selected and given the permit that was just released.
There is no requirement that a thread that releases a permit must
have acquired that permit by calling RSemaphoreReactive.acquire()
.
Correct usage of a semaphore is established by programming convention
in the application.
release
in interface RSemaphoreReactive
public org.reactivestreams.Publisher<Void> release(int permits)
RSemaphoreReactive
Releases the given number of permits, increasing the number of available permits by the given number of permits. If any threads of Redisson client are trying to acquire a permits, then next threads is selected and tries to acquire the permits that was just released.
There is no requirement that a thread that releases a permits must
have acquired that permit by calling RSemaphoreReactive.acquire()
.
Correct usage of a semaphore is established by programming convention
in the application.
release
in interface RSemaphoreReactive
permits
- amountpublic org.reactivestreams.Publisher<Boolean> trySetPermits(int permits)
RSemaphoreReactive
trySetPermits
in interface RSemaphoreReactive
permits
- - number of permitstrue
if permits has been set successfully, otherwise false
.public org.reactivestreams.Publisher<Boolean> tryAcquire(long waitTime, TimeUnit unit)
RSemaphoreReactive
Acquires a permit, if one is available and returns immediately,
with the value true
,
reducing the number of available permits by one.
If a permit is acquired then the value true
is returned.
If the specified waiting time elapses then the value false
is returned. If the time is less than or equal to zero, the method
will not wait at all.
tryAcquire
in interface RSemaphoreReactive
waitTime
- the maximum time to wait for a permitunit
- the time unit of the timeout
argumenttrue
if a permit was acquired and false
if the waiting time elapsed before a permit was acquiredpublic org.reactivestreams.Publisher<Boolean> tryAcquire(int permits, long waitTime, TimeUnit unit)
RSemaphoreReactive
Acquires a permits, if all are available and returns immediately,
with the value true
,
reducing the number of available permits by one.
If a permits is acquired then the value true
is returned.
If the specified waiting time elapses then the value false
is returned. If the time is less than or equal to zero, the method
will not wait at all.
tryAcquire
in interface RSemaphoreReactive
permits
- amountwaitTime
- the maximum time to wait for a available permitsunit
- the time unit of the timeout
argumenttrue
if a permit was acquired and false
if the waiting time elapsed before a permit was acquiredpublic org.reactivestreams.Publisher<Void> reducePermits(int permits)
RSemaphoreReactive
RSemaphoreReactive.acquire()
in that it does not block
waiting for permits to become available.reducePermits
in interface RSemaphoreReactive
permits
- - reduction the number of permits to removepublic org.reactivestreams.Publisher<Boolean> expire(long timeToLive, TimeUnit timeUnit)
RExpirableReactive
expire
in interface RExpirableReactive
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unittrue
if the timeout was set and false
if notpublic org.reactivestreams.Publisher<Boolean> expireAt(long timestamp)
RExpirableReactive
expireAt
in interface RExpirableReactive
timestamp
- - expire date in milliseconds (Unix timestamp)true
if the timeout was set and false
if notpublic org.reactivestreams.Publisher<Boolean> expireAt(Date timestamp)
RExpirableReactive
expireAt
in interface RExpirableReactive
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic org.reactivestreams.Publisher<Boolean> clearExpire()
RExpirableReactive
clearExpire
in interface RExpirableReactive
true
if the timeout was cleared and false
if notpublic org.reactivestreams.Publisher<Long> remainTimeToLive()
RExpirableReactive
remainTimeToLive
in interface RExpirableReactive
protected <V> reactor.core.publisher.Mono<V> newSucceeded(V result)
public String getName()
getName
in interface RObjectReactive
public Codec getCodec()
getCodec
in interface RObjectReactive
protected void encode(Collection<Object> params, Collection<?> values)
protected io.netty.buffer.ByteBuf encode(Object value)
protected io.netty.buffer.ByteBuf encodeMapKey(Object value)
protected io.netty.buffer.ByteBuf encodeMapValue(Object value)
public org.reactivestreams.Publisher<Void> rename(String newName)
RObjectReactive
newName
in moderename
in interface RObjectReactive
newName
- - new name of objectpublic org.reactivestreams.Publisher<Void> migrate(String host, int port, int database)
RObjectReactive
migrate
in interface RObjectReactive
host
- - destination hostport
- - destination portdatabase
- - destination databasepublic org.reactivestreams.Publisher<Boolean> move(int database)
RObjectReactive
move
in interface RObjectReactive
database
- - number of Redis databasetrue
if key was moved false
if notpublic org.reactivestreams.Publisher<Boolean> renamenx(String newName)
RObjectReactive
newName
in mode only if new key is not existsrenamenx
in interface RObjectReactive
newName
- - new name of objecttrue
if object has been renamed successfully and false
otherwisepublic org.reactivestreams.Publisher<Boolean> delete()
RObjectReactive
delete
in interface RObjectReactive
true
if object was deleted false
if notpublic org.reactivestreams.Publisher<Boolean> isExists()
RObjectReactive
isExists
in interface RObjectReactive
true
if object exists and false
otherwiseCopyright © 2014–2017 The Redisson Project. All rights reserved.