public class RedissonPermitExpirableSemaphore extends RedissonObject implements RPermitExpirableSemaphore
codec| Constructor and Description |
|---|
RedissonPermitExpirableSemaphore(CommandAsyncExecutor commandExecutor,
String name,
SemaphorePubSub semaphorePubSub) |
| Modifier and Type | Method and Description |
|---|---|
String |
acquire()
Acquires a permit from this semaphore, blocking until one is
available, or the thread is interrupted.
|
String |
acquire(long leaseTime,
TimeUnit timeUnit)
Acquires a permit with defined lease time from this semaphore,
blocking until one is available,
or the thread is interrupted.
|
RFuture<String> |
acquireAsync()
Acquires a permit from this semaphore, blocking until one is
available, or the thread is interrupted.
|
RFuture<String> |
acquireAsync(long leaseTime,
TimeUnit timeUnit)
Acquires a permit with defined lease time from this semaphore,
blocking until one is available,
or the thread is interrupted.
|
void |
addPermits(int permits)
Increases or decreases the number of available permits by defined value.
|
RFuture<Void> |
addPermitsAsync(int permits)
Increases or decreases the number of available permits by defined value.
|
int |
availablePermits()
Returns the current number of available permits.
|
RFuture<Integer> |
availablePermitsAsync()
Returns the current number of available permits.
|
boolean |
clearExpire()
Clear an expire timeout or expire date for object.
|
RFuture<Boolean> |
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.
|
RFuture<Boolean> |
deleteAsync()
Delete object in async mode
|
boolean |
expire(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object.
|
RFuture<Boolean> |
expireAsync(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object in async mode.
|
boolean |
expireAt(Date timestamp)
Set an expire date for object.
|
boolean |
expireAt(long timestamp)
Set an expire date for object.
|
RFuture<Boolean> |
expireAtAsync(Date timestamp)
Set an expire date for object in async mode.
|
RFuture<Boolean> |
expireAtAsync(long timestamp)
Set an expire date for object in async mode.
|
protected String |
generateId() |
static String |
getChannelName(String name) |
void |
release(String permitId)
Releases a permit by its id, returning it to the semaphore.
|
RFuture<Void> |
releaseAsync(String permitId)
Releases a permit by its id, returning it to the semaphore.
|
long |
remainTimeToLive()
Remaining time to live of Redisson object that has a timeout
|
RFuture<Long> |
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeout
|
String |
tryAcquire()
Acquires a permit only if one is available at the
time of invocation.
|
String |
tryAcquire(long waitTime,
long ttl,
TimeUnit unit)
Acquires a permit with defined lease time from this semaphore,
if one becomes available
within the given waiting time and the current thread has not
been interrupted.
|
String |
tryAcquire(long waitTime,
TimeUnit unit)
Acquires a permit from this semaphore, if one becomes available
within the given waiting time and the current thread has not
been interrupted.
|
RFuture<String> |
tryAcquireAsync()
Acquires a permit only if one is available at the
time of invocation.
|
RFuture<String> |
tryAcquireAsync(int permits,
long timeoutDate) |
RFuture<String> |
tryAcquireAsync(long waitTime,
long ttl,
TimeUnit unit)
Acquires a permit with defined lease time from this semaphore,
if one becomes available
within the given waiting time and the current thread has not
been interrupted.
|
RFuture<String> |
tryAcquireAsync(long waitTime,
TimeUnit unit)
Acquires a permit from this semaphore, if one becomes available
within the given waiting time and the current thread has not
been interrupted.
|
boolean |
tryRelease(String permitId)
Releases a permit by its id, returning it to the semaphore.
|
RFuture<Boolean> |
tryReleaseAsync(String permitId)
Releases a permit by its id, returning it to the semaphore.
|
boolean |
trySetPermits(int permits)
Sets number of permits.
|
RFuture<Boolean> |
trySetPermitsAsync(int permits)
Sets number of permits.
|
await, copy, copyAsync, delete, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getName, getName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, rename, renameAsync, renamenx, renamenxAsync, suffixName, toSeconds, touch, touchAsync, unlink, unlinkAsyncclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclearExpire, expire, expireAt, expireAt, remainTimeToLivecopy, delete, getCodec, getName, isExists, migrate, move, rename, renamenx, touch, unlinkexpireAtAsync, remainTimeToLiveAsynccopyAsync, isExistsAsync, migrateAsync, moveAsync, renameAsync, renamenxAsync, touchAsync, unlinkAsyncpublic RedissonPermitExpirableSemaphore(CommandAsyncExecutor commandExecutor, String name, SemaphorePubSub semaphorePubSub)
public String acquire() throws InterruptedException
RPermitExpirableSemaphoreAcquires a permit, if one is available and returns its id, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
RPermitExpirableSemaphore.release(java.lang.String) method for this
semaphore and the current thread is next to be assigned a permit; or
acquire in interface RPermitExpirableSemaphoreInterruptedException - if the current thread is interruptedpublic String acquire(long leaseTime, TimeUnit timeUnit) throws InterruptedException
RPermitExpirableSemaphoreAcquires a permit, if one is available and returns its id, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
RPermitExpirableSemaphore.release(java.lang.String) method for this
semaphore and the current thread is next to be assigned a permit; or
acquire in interface RPermitExpirableSemaphoreleaseTime - - permit lease timetimeUnit - - time unitInterruptedException - if the current thread is interruptedpublic RFuture<String> acquireAsync(long leaseTime, TimeUnit timeUnit)
RPermitExpirableSemaphoreAsyncAcquires a permit, if one is available and returns its id, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
RPermitExpirableSemaphoreAsync.releaseAsync(java.lang.String) method for this
semaphore and the current thread is next to be assigned a permit; or
acquireAsync in interface RPermitExpirableSemaphoreAsyncleaseTime - - permit lease timetimeUnit - - time unitpublic RFuture<String> acquireAsync()
RPermitExpirableSemaphoreAsyncAcquires a permit, if one is available and returns its id, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
RPermitExpirableSemaphoreAsync.releaseAsync(String) method for this
semaphore and the current thread is next to be assigned a permit; or
acquireAsync in interface RPermitExpirableSemaphoreAsyncpublic String tryAcquire()
RPermitExpirableSemaphoreAcquires a permit, if one is available and returns immediately, with the permit id, reducing the number of available permits by one.
If no permit is available then this method will return
immediately with the value null.
tryAcquire in interface RPermitExpirableSemaphorenull
otherwisepublic RFuture<String> tryAcquireAsync()
RPermitExpirableSemaphoreAsyncAcquires a permit, if one is available and returns immediately, with the permit id, reducing the number of available permits by one.
If no permit is available then this method will return
immediately with the value null.
tryAcquireAsync in interface RPermitExpirableSemaphoreAsyncnull
otherwiseprotected String generateId()
public RFuture<String> tryAcquireAsync(long waitTime, TimeUnit unit)
RPermitExpirableSemaphoreAsyncAcquires a permit, if one is available and returns immediately, with the permit id, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
RPermitExpirableSemaphoreAsync.releaseAsync(String) method for this
semaphore and the current thread is next to be assigned a permit; or
If a permit is acquired then the permit id is returned.
If the specified waiting time elapses then the value null
is returned. If the time is less than or equal to zero, the method
will not wait at all.
tryAcquireAsync in interface RPermitExpirableSemaphoreAsyncwaitTime - the maximum time to wait for a permitunit - the time unit of the timeout argumentnull
if the waiting time elapsed before a permit was acquiredpublic String tryAcquire(long waitTime, long ttl, TimeUnit unit) throws InterruptedException
RPermitExpirableSemaphoreAcquires a permit, if one is available and returns immediately, with the permit id, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
RPermitExpirableSemaphore.release(java.lang.String) method for this
semaphore and the current thread is next to be assigned a permit; or
If a permit is acquired then the permit id is returned.
If the specified waiting time elapses then the value null
is returned. If the time is less than or equal to zero, the method
will not wait at all.
tryAcquire in interface RPermitExpirableSemaphorewaitTime - the maximum time to wait for a permitttl - permit lease timeunit - the time unit of the timeout argumentnull
if the waiting time elapsed before a permit was acquiredInterruptedException - if the current thread is interruptedpublic RFuture<String> tryAcquireAsync(long waitTime, long ttl, TimeUnit unit)
RPermitExpirableSemaphoreAsyncAcquires a permit, if one is available and returns immediately, with the permit id, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
RPermitExpirableSemaphoreAsync.releaseAsync(String) method for this
semaphore and the current thread is next to be assigned a permit; or
If a permit is acquired then the permit id is returned.
If the specified waiting time elapses then the value null
is returned. If the time is less than or equal to zero, the method
will not wait at all.
tryAcquireAsync in interface RPermitExpirableSemaphoreAsyncwaitTime - the maximum time to wait for a permitttl - permit lease timeunit - the time unit of the timeout argumentnull
if the waiting time elapsed before a permit was acquiredpublic String tryAcquire(long waitTime, TimeUnit unit) throws InterruptedException
RPermitExpirableSemaphoreAcquires a permit, if one is available and returns immediately, with the permit id, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
RPermitExpirableSemaphore.release(java.lang.String) method for this
semaphore and the current thread is next to be assigned a permit; or
If a permit is acquired then the permit id is returned.
If the specified waiting time elapses then the value null
is returned. If the time is less than or equal to zero, the method
will not wait at all.
tryAcquire in interface RPermitExpirableSemaphorewaitTime - the maximum time to wait for a permitunit - the time unit of the timeout argumentnull
if the waiting time elapsed before a permit was acquiredInterruptedException - if the current thread is interruptedpublic void release(String permitId)
RPermitExpirableSemaphoreReleases 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 RPermitExpirableSemaphore.acquire().
Correct usage of a semaphore is established by programming convention
in the application.
Throws an exception if permit id doesn't exist or has already been release
release in interface RPermitExpirableSemaphorepermitId - - permit idpublic boolean tryRelease(String permitId)
RPermitExpirableSemaphoreReleases 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 RPermitExpirableSemaphore.acquire().
Correct usage of a semaphore is established by programming convention
in the application.
tryRelease in interface RPermitExpirableSemaphorepermitId - - permit idtrue if a permit has been released and false
otherwisepublic RFuture<Boolean> tryReleaseAsync(String permitId)
RPermitExpirableSemaphoreAsyncReleases 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 RPermitExpirableSemaphoreAsync.acquireAsync().
Correct usage of a semaphore is established by programming convention
in the application.
tryReleaseAsync in interface RPermitExpirableSemaphoreAsyncpermitId - - permit idtrue if a permit has been released and false
otherwisepublic RFuture<Boolean> deleteAsync()
RObjectAsyncdeleteAsync in interface RObjectAsyncdeleteAsync in class RedissonObjecttrue if object was deleted false if notpublic RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
RExpirableAsyncexpireAsync in interface RExpirableAsynctimeToLive - - timeout before object will be deletedtimeUnit - - timeout time unittrue if the timeout was set and false if notpublic RFuture<Boolean> expireAtAsync(long timestamp)
RExpirableAsyncexpireAtAsync in interface RExpirableAsynctimestamp - - expire date in seconds (Unix timestamp)true if the timeout was set and false if notpublic RFuture<Boolean> clearExpireAsync()
RExpirableAsyncclearExpireAsync in interface RExpirableAsynctrue if the timeout was cleared and false if notpublic RFuture<Void> releaseAsync(String permitId)
RPermitExpirableSemaphoreAsyncReleases 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 RPermitExpirableSemaphoreAsync.acquireAsync().
Correct usage of a semaphore is established by programming convention
in the application.
Throws an exception if permit id doesn't exist or has already been release
releaseAsync in interface RPermitExpirableSemaphoreAsyncpermitId - - permit idpublic int availablePermits()
RPermitExpirableSemaphoreavailablePermits in interface RPermitExpirableSemaphorepublic RFuture<Integer> availablePermitsAsync()
RPermitExpirableSemaphoreAsyncavailablePermitsAsync in interface RPermitExpirableSemaphoreAsyncpublic boolean trySetPermits(int permits)
RPermitExpirableSemaphoretrySetPermits in interface RPermitExpirableSemaphorepermits - - number of permitstrue if permits has been set successfully, otherwise false.public RFuture<Boolean> trySetPermitsAsync(int permits)
RPermitExpirableSemaphoreAsynctrySetPermitsAsync in interface RPermitExpirableSemaphoreAsyncpermits - - number of permitstrue if permits has been set successfully, otherwise false.public void addPermits(int permits)
RPermitExpirableSemaphoreaddPermits in interface RPermitExpirableSemaphorepermits - - number of permits to add/removepublic RFuture<Void> addPermitsAsync(int permits)
RPermitExpirableSemaphoreAsyncaddPermitsAsync in interface RPermitExpirableSemaphoreAsyncpermits - - number of permits to add/removepublic boolean expire(long timeToLive,
TimeUnit timeUnit)
RExpirableexpire in interface RExpirabletimeToLive - - timeout before object will be deletedtimeUnit - - timeout time unittrue if the timeout was set and false if notpublic boolean expireAt(long timestamp)
RExpirableexpireAt in interface RExpirabletimestamp - - expire date in milliseconds (Unix timestamp)true if the timeout was set and false if notpublic boolean expireAt(Date timestamp)
RExpirableexpireAt in interface RExpirabletimestamp - - expire datetrue if the timeout was set and false if notpublic RFuture<Boolean> expireAtAsync(Date timestamp)
RExpirableAsyncexpireAtAsync in interface RExpirableAsynctimestamp - - expire datetrue if the timeout was set and false if notpublic boolean clearExpire()
RExpirableclearExpire in interface RExpirabletrue if timeout was removed
false if object does not exist or does not have an associated timeoutpublic long remainTimeToLive()
RExpirableremainTimeToLive in interface RExpirablepublic RFuture<Long> remainTimeToLiveAsync()
RExpirableAsyncremainTimeToLiveAsync in interface RExpirableAsyncCopyright © 2014–2018 The Redisson Project. All rights reserved.