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.
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) |
<R> R |
affinityCall(IgniteCallable<R> job)
Executes given job on collocated queue on the node where the queue is located
(a.k.a. affinity co-location).
|
void |
affinityRun(IgniteRunnable job)
Executes given job on collocated queue on the node where the queue is located
(a.k.a. affinity co-location).
|
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) |
<V1> IgniteQueue<V1> |
withKeepBinary()
Returns queue that will operate with binary objects.
|
drainTo, drainTo, remainingCapacity
equals, hashCode, parallelStream, removeIf, spliterator, stream
String name()
boolean add(T item) throws IgniteException
add
in interface BlockingQueue<T>
add
in interface Collection<T>
add
in interface Queue<T>
IgniteException
boolean offer(T item) throws IgniteException
offer
in interface BlockingQueue<T>
offer
in interface Queue<T>
IgniteException
boolean offer(T item, long timeout, TimeUnit unit) throws IgniteException
offer
in interface BlockingQueue<T>
IgniteException
boolean addAll(Collection<? extends T> items) throws IgniteException
addAll
in interface Collection<T>
IgniteException
boolean contains(Object item) throws IgniteException
contains
in interface BlockingQueue<T>
contains
in interface Collection<T>
IgniteException
boolean containsAll(Collection<?> items) throws IgniteException
containsAll
in interface Collection<T>
IgniteException
void clear() throws IgniteException
clear
in interface Collection<T>
IgniteException
boolean remove(Object item) throws IgniteException
remove
in interface BlockingQueue<T>
remove
in interface Collection<T>
IgniteException
boolean removeAll(Collection<?> items) throws IgniteException
removeAll
in interface Collection<T>
IgniteException
boolean isEmpty() throws IgniteException
isEmpty
in interface Collection<T>
IgniteException
Iterator<T> iterator() throws IgniteException
iterator
in interface Collection<T>
iterator
in interface Iterable<T>
IgniteException
Object[] toArray() throws IgniteException
toArray
in interface Collection<T>
IgniteException
<T> T[] toArray(T[] a) throws IgniteException
toArray
in interface Collection<T>
IgniteException
boolean retainAll(Collection<?> items) throws IgniteException
retainAll
in interface Collection<T>
IgniteException
int size() throws IgniteException
size
in interface Collection<T>
IgniteException
T poll() throws IgniteException
poll
in interface Queue<T>
IgniteException
T peek() throws IgniteException
peek
in interface Queue<T>
IgniteException
void put(T item) throws IgniteException
put
in interface BlockingQueue<T>
IgniteException
T take() throws IgniteException
take
in interface BlockingQueue<T>
IgniteException
T poll(long timeout, TimeUnit unit) throws IgniteException
poll
in interface BlockingQueue<T>
IgniteException
void clear(int batchSize) throws IgniteException
batchSize
- Batch size.IgniteException
- if operation failed.void close() throws IgniteException
close
in interface AutoCloseable
close
in interface Closeable
IgniteException
- 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.void affinityRun(IgniteRunnable job) throws IgniteException
This is not supported for non-collocated queues.
job
- Job which will be co-located with the queue.IgniteException
- If job failed.<R> R affinityCall(IgniteCallable<R> job) throws IgniteException
This is not supported for non-collocated queues.
job
- Job which will be co-located with the queue.IgniteException
- If job failed.<V1> IgniteQueue<V1> withKeepBinary()
IgniteCache.withKeepBinary()
but
for queues.
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024