public interface IgniteQueue<T> extends BlockingQueue<T>, Closeable
Collection interface and provides all methods from collections including
Collection.addAll(Collection), Collection.removeAll(Collection), and
Collection.retainAll(Collection) methods for bulk operations. Note that all
Collection methods in the queue may throw IgniteException in case
of failure.
All queue operations have synchronous and asynchronous counterparts.
unbounded or bounded. Bounded queues can
have maximum capacity. Queue capacity can be set at creation time and cannot be
changed later. Here is an example of how to create bounded LIFO queue with
capacity of 1000 items.
IgniteQueue<String> queue = cache().queue("anyName", LIFO, 1000);
...
queue.add("item");
For bounded queues blocking operations, such as take() or put(Object)
are available. These operations will block until queue capacity changes to make the operation
possible.
collocated parameter). Non-collocated mode is provided only
for partitioned caches. If collocated parameter is true, then all queue items
will be collocated on one node, otherwise items will be distributed through all grid nodes.
Unless explicitly specified, by default queues are collocated.
Here is an example of how create unbounded queue
in non-collocated mode.
IgniteQueue<String> queue = cache().queue("anyName", 0 /*unbounded*/, false /*non-collocated*/);
...
queue.add("item");
Ignite API:
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T item) |
boolean |
addAll(Collection<? extends T> items) |
boolean |
bounded()
Returns
true if this queue is bounded. |
int |
capacity()
Gets maximum number of elements of the queue.
|
void |
clear() |
void |
clear(int batchSize)
Removes all of the elements from this queue.
|
void |
close()
Removes this queue.
|
boolean |
collocated()
Returns
true if this queue can be kept on the one node only. |
boolean |
contains(Object item) |
boolean |
containsAll(Collection<?> items) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
String |
name()
Gets queue name.
|
boolean |
offer(T item) |
boolean |
offer(T item,
long timeout,
TimeUnit unit) |
T |
peek() |
T |
poll() |
T |
poll(long timeout,
TimeUnit unit) |
void |
put(T item) |
boolean |
remove(Object item) |
boolean |
removeAll(Collection<?> items) |
boolean |
removed()
Gets status of queue.
|
boolean |
retainAll(Collection<?> items) |
int |
size() |
T |
take() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
drainTo, drainTo, remainingCapacityequals, hashCodeString name()
boolean add(T item) throws IgniteException
add in interface BlockingQueue<T>add in interface Collection<T>add in interface Queue<T>IgniteExceptionboolean offer(T item) throws IgniteException
offer in interface BlockingQueue<T>offer in interface Queue<T>IgniteExceptionboolean offer(T item, long timeout, TimeUnit unit) throws IgniteException
offer in interface BlockingQueue<T>IgniteExceptionboolean addAll(Collection<? extends T> items) throws IgniteException
addAll in interface Collection<T>IgniteExceptionboolean contains(Object item) throws IgniteException
contains in interface BlockingQueue<T>contains in interface Collection<T>IgniteExceptionboolean containsAll(Collection<?> items) throws IgniteException
containsAll in interface Collection<T>IgniteExceptionvoid clear()
throws IgniteException
clear in interface Collection<T>IgniteExceptionboolean remove(Object item) throws IgniteException
remove in interface BlockingQueue<T>remove in interface Collection<T>IgniteExceptionboolean removeAll(Collection<?> items) throws IgniteException
removeAll in interface Collection<T>IgniteExceptionboolean isEmpty()
throws IgniteException
isEmpty in interface Collection<T>IgniteExceptionIterator<T> iterator() throws IgniteException
iterator in interface Collection<T>iterator in interface Iterable<T>IgniteExceptionObject[] toArray() throws IgniteException
toArray in interface Collection<T>IgniteException<T> T[] toArray(T[] a) throws IgniteException
toArray in interface Collection<T>IgniteExceptionboolean retainAll(Collection<?> items) throws IgniteException
retainAll in interface Collection<T>IgniteExceptionint size()
throws IgniteException
size in interface Collection<T>IgniteExceptionT poll() throws IgniteException
poll in interface Queue<T>IgniteExceptionT peek() throws IgniteException
peek in interface Queue<T>IgniteExceptionvoid put(T item) throws IgniteException
put in interface BlockingQueue<T>IgniteExceptionT take() throws IgniteException
take in interface BlockingQueue<T>IgniteExceptionT poll(long timeout, TimeUnit unit) throws IgniteException
poll in interface BlockingQueue<T>IgniteExceptionvoid clear(int batchSize)
throws IgniteException
batchSize - Batch size.IgniteException - if operation failed.void close()
throws IgniteException
close in interface AutoCloseableclose in interface CloseableIgniteException - if operation failed.int capacity()
Integer.MAX_SIZE will return.boolean bounded()
true if this queue is bounded.true if this queue is bounded.boolean collocated()
true if this queue can be kept on the one node only.
Returns false if this queue can be kept on the many nodes.true if this queue is in collocated mode false otherwise.boolean removed()
true if queue was removed from cache false otherwise.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016