public class RedissonPriorityBlockingQueue<V> extends RedissonPriorityQueue<V> implements RPriorityBlockingQueue<V>
Distributed and concurrent implementation of PriorityBlockingQueue
.
Queue size limited by Redis server memory amount. This is why remainingCapacity()
always
returns Integer.MAX_VALUE
RedissonPriorityQueue.BinarySearchResult<V>
codec, name
Modifier | Constructor and Description |
---|---|
protected |
RedissonPriorityBlockingQueue(Codec codec,
CommandExecutor commandExecutor,
String name,
RedissonClient redisson) |
protected |
RedissonPriorityBlockingQueue(CommandExecutor commandExecutor,
String name,
RedissonClient redisson) |
Modifier and Type | Method and Description |
---|---|
boolean |
clearExpire()
Clear an expire timeout or expire date for object.
|
protected RFuture<Boolean> |
clearExpireAsync(String... keys) |
int |
drainTo(Collection<? super V> c) |
int |
drainTo(Collection<? super V> c,
int maxElements) |
RFuture<Integer> |
drainToAsync(Collection<? super V> c)
Removes all available elements from this queue and adds them
to the given collection in async mode.
|
RFuture<Integer> |
drainToAsync(Collection<? super V> c,
int maxElements)
Removes at most the given number of available elements from
this queue and adds them to the given collection in async mode.
|
boolean |
expire(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object.
|
protected RFuture<Boolean> |
expireAsync(long timeToLive,
TimeUnit timeUnit,
String... keys) |
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.
|
protected RFuture<Boolean> |
expireAtAsync(long timestamp,
String... keys) |
boolean |
offer(V e,
long timeout,
TimeUnit unit) |
RFuture<Boolean> |
offerAsync(V e)
Inserts the specified element into this queue.
|
List<V> |
poll(int limit)
Retrieves and removes the head elements of this queue.
|
V |
poll(long timeout,
TimeUnit unit) |
RFuture<List<V>> |
pollAsync(int limit)
Retrieves and removes the head elements of this queue.
|
RFuture<V> |
pollAsync(long timeout,
TimeUnit unit)
Retrieves and removes the head of this queue in async mode, waiting up to the
specified wait time if necessary for an element to become available.
|
V |
pollFromAny(long timeout,
TimeUnit unit,
String... queueNames)
Retrieves and removes first available head element of any queue,
waiting up to the specified wait time if necessary for an element to become available
in any of defined queues including queue itself.
|
RFuture<V> |
pollFromAnyAsync(long timeout,
TimeUnit unit,
String... queueNames)
Retrieves and removes first available head element of any queue in async mode,
waiting up to the specified wait time if necessary for an element to become available
in any of defined queues including queue itself.
|
V |
pollLastAndOfferFirstTo(String queueName,
long timeout,
TimeUnit unit)
Retrieves and removes last available tail element of this queue and adds it at the head of
queueName ,
waiting up to the specified wait time if necessary for an element to become available. |
RFuture<V> |
pollLastAndOfferFirstToAsync(String queueName,
long timeout,
TimeUnit unit)
Retrieves and removes last available tail element of this queue and adds it at the head of
queueName ,
waiting up to the specified wait time if necessary for an element to become available. |
void |
put(V e) |
RFuture<Void> |
putAsync(V e)
Inserts the specified element into this queue in async mode, waiting if necessary
for space to become available.
|
int |
remainingCapacity() |
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
|
int |
subscribeOnElements(Consumer<V> consumer)
Subscribes on elements appeared in this queue.
|
V |
take() |
RFuture<V> |
takeAsync()
Retrieves and removes the head of this queue in async mode, waiting if necessary
until an element becomes available.
|
protected <T> void |
takeAsync(RPromise<V> result,
long delay,
long timeoutInMicro,
RedisCommand<T> command,
Object... params) |
V |
takeLastAndOfferFirstTo(String queueName)
Retrieves and removes last available tail element of any queue and adds it at the head of
queueName ,
waiting if necessary for an element to become available
in any of defined queues including queue itself. |
RFuture<V> |
takeLastAndOfferFirstToAsync(String queueName)
Retrieves and removes last available tail element of any queue and adds it at the head of
queueName ,
waiting if necessary for an element to become available
in any of defined queues including queue itself. |
void |
unsubscribe(int listenerId)
Un-subscribes defined listener.
|
add, addAll, addAsync, binarySearch, clear, clearExpireAsync, comparator, contains, containsAll, deleteAsync, element, expireAsync, expireAtAsync, getFirst, offer, peek, peekAsync, poll, pollAsync, pollLastAndOfferFirstTo, pollLastAndOfferFirstToAsync, remove, remove, removeAll, removeFirst, retainAll, toString, trySetComparator, wrapLockedAsync, wrapLockedAsync
add, addAfter, addAfterAsync, addAll, addAllAsync, addAllAsync, addAsync, addAsync, addBefore, addBeforeAsync, addListener, addListenerAsync, containsAllAsync, containsAsync, equals, fastRemove, fastRemoveAsync, fastSet, fastSetAsync, get, get, getAsync, getAsync, hashCode, indexOf, indexOfAsync, indexOfAsync, isEmpty, iterator, lastIndexOf, lastIndexOfAsync, lastIndexOfAsync, listIterator, listIterator, mapReduce, range, range, rangeAsync, rangeAsync, readAll, readAllAsync, readSort, readSort, readSort, readSort, readSort, readSort, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, remove, remove, removeAllAsync, removeAsync, removeAsync, removeAsync, removeListener, removeListenerAsync, retainAllAsync, set, setAsync, size, sizeAsync, sortTo, sortTo, sortTo, sortTo, sortTo, sortTo, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, subList, toArray, toArray, trim, trimAsync
addListener, addListenerAsync, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, removeListenersAsync, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsync
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, contains, offer, remove
comparator, pollLastAndOfferFirstTo, readAll, trySetComparator
addListener
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
clearExpire, expire, expireAt, expireAt, remainTimeToLive
copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
addListenerAsync, peekAsync, pollAsync, pollLastAndOfferFirstToAsync, readAllAsync
addAllAsync, addAsync, containsAllAsync, containsAsync, removeAllAsync, removeAsync, retainAllAsync, sizeAsync
replaceAll, sort, spliterator
protected RedissonPriorityBlockingQueue(CommandExecutor commandExecutor, String name, RedissonClient redisson)
protected RedissonPriorityBlockingQueue(Codec codec, CommandExecutor commandExecutor, String name, RedissonClient redisson)
public void put(V e) throws InterruptedException
put
in interface BlockingQueue<V>
InterruptedException
public boolean offer(V e, long timeout, TimeUnit unit) throws InterruptedException
offer
in interface BlockingQueue<V>
InterruptedException
public RFuture<V> takeAsync()
RBlockingQueueAsync
takeAsync
in interface RBlockingQueueAsync<V>
protected <T> void takeAsync(RPromise<V> result, long delay, long timeoutInMicro, RedisCommand<T> command, Object... params)
public V take() throws InterruptedException
take
in interface BlockingQueue<V>
InterruptedException
public RFuture<V> pollAsync(long timeout, TimeUnit unit)
RBlockingQueueAsync
pollAsync
in interface RBlockingQueueAsync<V>
timeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameternull
if the
specified waiting time elapses before an element is availablepublic V poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface BlockingQueue<V>
InterruptedException
public V pollFromAny(long timeout, TimeUnit unit, String... queueNames) throws InterruptedException
RBlockingQueue
pollFromAny
in interface RBlockingQueue<V>
timeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameterqueueNames
- - queue names. Queue name itself is always includednull
if the
specified waiting time elapses before an element is availableInterruptedException
- if interrupted while waitingpublic RFuture<V> pollLastAndOfferFirstToAsync(String queueName, long timeout, TimeUnit unit)
RBlockingQueueAsync
queueName
,
waiting up to the specified wait time if necessary for an element to become available.pollLastAndOfferFirstToAsync
in interface RBlockingQueueAsync<V>
queueName
- - names of destination queuetimeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameternull
if the
specified waiting time elapses before an element is availablepublic V pollLastAndOfferFirstTo(String queueName, long timeout, TimeUnit unit) throws InterruptedException
RBlockingQueue
queueName
,
waiting up to the specified wait time if necessary for an element to become available.pollLastAndOfferFirstTo
in interface RBlockingQueue<V>
queueName
- - names of destination queuetimeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameternull
if the
specified waiting time elapses before an element is availableInterruptedException
- if interrupted while waitingpublic V takeLastAndOfferFirstTo(String queueName) throws InterruptedException
RBlockingQueue
queueName
,
waiting if necessary for an element to become available
in any of defined queues including queue itself.takeLastAndOfferFirstTo
in interface RBlockingQueue<V>
queueName
- - names of destination queuenull
if the
specified waiting time elapses before an element is availableInterruptedException
- if interrupted while waitingpublic int subscribeOnElements(Consumer<V> consumer)
RBlockingQueue
RBlockingQueueAsync.takeAsync()
method to get a new element.subscribeOnElements
in interface RBlockingQueue<V>
consumer
- - queue elements listenerpublic void unsubscribe(int listenerId)
RBlockingQueue
unsubscribe
in interface RBlockingQueue<V>
listenerId
- - id of listenerpublic RFuture<V> takeLastAndOfferFirstToAsync(String queueName)
RBlockingQueueAsync
queueName
,
waiting if necessary for an element to become available
in any of defined queues including queue itself.takeLastAndOfferFirstToAsync
in interface RBlockingQueueAsync<V>
queueName
- - names of destination queuenull
if the
specified waiting time elapses before an element is availablepublic int remainingCapacity()
remainingCapacity
in interface BlockingQueue<V>
public int drainTo(Collection<? super V> c)
drainTo
in interface BlockingQueue<V>
public RFuture<Integer> drainToAsync(Collection<? super V> c)
RBlockingQueueAsync
c
may result in elements being in neither,
either or both collections when the associated exception is
thrown. Attempts to drain a queue to itself result in
IllegalArgumentException
. Further, the behavior of
this operation is undefined if the specified collection is
modified while the operation is in progress.drainToAsync
in interface RBlockingQueueAsync<V>
c
- the collection to transfer elements intopublic int drainTo(Collection<? super V> c, int maxElements)
drainTo
in interface BlockingQueue<V>
public RFuture<Integer> drainToAsync(Collection<? super V> c, int maxElements)
RBlockingQueueAsync
c
may result in elements being in neither,
either or both collections when the associated exception is
thrown. Attempts to drain a queue to itself result in
IllegalArgumentException
. Further, the behavior of
this operation is undefined if the specified collection is
modified while the operation is in progress.drainToAsync
in interface RBlockingQueueAsync<V>
c
- the collection to transfer elements intomaxElements
- the maximum number of elements to transferpublic RFuture<Boolean> offerAsync(V e)
RQueueAsync
offerAsync
in interface RQueueAsync<V>
offerAsync
in class RedissonPriorityQueue<V>
e
- the element to addtrue
if successful, or false
public RFuture<List<V>> pollAsync(int limit)
RQueueAsync
limit
param.pollAsync
in interface RQueueAsync<V>
pollAsync
in class RedissonPriorityQueue<V>
public RFuture<V> pollFromAnyAsync(long timeout, TimeUnit unit, String... queueNames)
RBlockingQueueAsync
pollFromAnyAsync
in interface RBlockingQueueAsync<V>
timeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameterqueueNames
- - queue names. Queue name itself is always includednull
if the
specified waiting time elapses before an element is availablepublic RFuture<Void> putAsync(V e)
RBlockingQueueAsync
putAsync
in interface RBlockingQueueAsync<V>
e
- the element to addpublic List<V> poll(int limit)
RQueue
limit
param.public boolean expire(long timeToLive, TimeUnit timeUnit)
RExpirable
expire
in interface RExpirable
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unittrue
if the timeout was set and false
if notpublic boolean expireAt(long timestamp)
RExpirable
expireAt
in interface RExpirable
timestamp
- - expire date in milliseconds (Unix timestamp)true
if the timeout was set and false
if notpublic boolean expireAt(Date timestamp)
RExpirable
expireAt
in interface RExpirable
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAtAsync(Date timestamp)
RExpirableAsync
expireAtAsync
in interface RExpirableAsync
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic boolean clearExpire()
RExpirable
clearExpire
in interface RExpirable
true
if timeout was removed
false
if object does not exist or does not have an associated timeoutpublic long remainTimeToLive()
RExpirable
remainTimeToLive
in interface RExpirable
public RFuture<Long> remainTimeToLiveAsync()
RExpirableAsync
remainTimeToLiveAsync
in interface RExpirableAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
Copyright © 2014–2020 Redisson. All rights reserved.