Package org.apache.ignite
Interface IgniteQueue<T>
- 
- All Superinterfaces:
- AutoCloseable,- BlockingQueue<T>,- Closeable,- Collection<T>,- Iterable<T>,- Queue<T>
 
 public interface IgniteQueue<T> extends BlockingQueue<T>, Closeable This interface provides a rich API for working with distributed queues based on In-Memory Data Grid.OverviewCache queue provides an access to cache elements using typical queue API. Cache queue also implementsCollectioninterface and provides all methods from collections includingCollection.addAll(Collection),Collection.removeAll(Collection), andCollection.retainAll(Collection)methods for bulk operations. Note that allCollectionmethods in the queue may throwIgniteExceptionin case of failure.Bounded vs UnboundedQueues can beunboundedorbounded.Boundedqueues can have maximum capacity. Queue capacity can be set at creation time and cannot be changed later. Here is an example of how to createboundedLIFOqueue with capacity of1000items.IgniteQueue<String> queue = cache().queue("anyName", LIFO, 1000); ... queue.add("item");Forboundedqueues blocking operations, such astake()orput(Object)are available. These operations will block until queue capacity changes to make the operation possible.Collocated vs Non-collocatedQueue items can be placed on one node or distributed throughout grid nodes (governed bycollocatedparameter).Non-collocatedmode is provided only for partitioned caches. Ifcollocatedparameter istrue, 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 arecollocated.Here is an example of how create unboundedqueue in non-collocated mode.IgniteQueue<String> queue = cache().queue("anyName", 0 /*unbounded*/, false /*non-collocated*/); ... queue.add("item");Creating Cache QueuesInstances of distributed cache queues can be created by calling the following method onIgniteAPI:
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanadd(T item)booleanaddAll(Collection<? extends T> items)<R> RaffinityCall(IgniteCallable<R> job)Executes given job on collocated queue on the node where the queue is located (a.k.a. affinity co-location).voidaffinityRun(IgniteRunnable job)Executes given job on collocated queue on the node where the queue is located (a.k.a. affinity co-location).booleanbounded()Returnstrueif this queue is bounded.intcapacity()Gets maximum number of elements of the queue.voidclear()voidclear(int batchSize)Removes all of the elements from this queue.voidclose()Removes this queue.booleancollocated()Returnstrueif this queue can be kept on the one node only.booleancontains(Object item)booleancontainsAll(Collection<?> items)booleanisEmpty()Iterator<T>iterator()Stringname()Gets queue name.booleanoffer(T item)booleanoffer(T item, long timeout, TimeUnit unit)Tpeek()Tpoll()Tpoll(long timeout, TimeUnit unit)voidput(T item)booleanremove(Object item)booleanremoveAll(Collection<?> items)booleanremoved()Gets status of queue.booleanretainAll(Collection<?> items)intsize()Ttake()Object[]toArray()<T> T[]toArray(T[] a)<V1> IgniteQueue<V1>withKeepBinary()Returns queue that will operate with binary objects.- 
Methods inherited from interface java.util.concurrent.BlockingQueuedrainTo, drainTo, remainingCapacity
 - 
Methods inherited from interface java.util.Collectionequals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
 
- 
 
- 
- 
- 
Method Detail- 
nameString name() Gets queue name.- Returns:
- Queue name.
 
 - 
addboolean add(T item) throws IgniteException - Specified by:
- addin interface- BlockingQueue<T>
- Specified by:
- addin interface- Collection<T>
- Specified by:
- addin interface- Queue<T>
- Throws:
- IgniteException
 
 - 
offerboolean offer(T item) throws IgniteException - Specified by:
- offerin interface- BlockingQueue<T>
- Specified by:
- offerin interface- Queue<T>
- Throws:
- IgniteException
 
 - 
offerboolean offer(T item, long timeout, TimeUnit unit) throws IgniteException - Specified by:
- offerin interface- BlockingQueue<T>
- Throws:
- IgniteException
 
 - 
addAllboolean addAll(Collection<? extends T> items) throws IgniteException - Specified by:
- addAllin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
containsboolean contains(Object item) throws IgniteException - Specified by:
- containsin interface- BlockingQueue<T>
- Specified by:
- containsin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
containsAllboolean containsAll(Collection<?> items) throws IgniteException - Specified by:
- containsAllin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
clearvoid clear() throws IgniteException- Specified by:
- clearin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
removeboolean remove(Object item) throws IgniteException - Specified by:
- removein interface- BlockingQueue<T>
- Specified by:
- removein interface- Collection<T>
- Throws:
- IgniteException
 
 - 
removeAllboolean removeAll(Collection<?> items) throws IgniteException - Specified by:
- removeAllin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
isEmptyboolean isEmpty() throws IgniteException- Specified by:
- isEmptyin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
iteratorIterator<T> iterator() throws IgniteException - Specified by:
- iteratorin interface- Collection<T>
- Specified by:
- iteratorin interface- Iterable<T>
- Throws:
- IgniteException
 
 - 
toArrayObject[] toArray() throws IgniteException - Specified by:
- toArrayin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
toArray<T> T[] toArray(T[] a) throws IgniteException- Specified by:
- toArrayin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
retainAllboolean retainAll(Collection<?> items) throws IgniteException - Specified by:
- retainAllin interface- Collection<T>
- Throws:
- IgniteException
 
 - 
sizeint size() throws IgniteException - Specified by:
- sizein interface- Collection<T>
- Throws:
- IgniteException
 
 - 
pollT poll() throws IgniteException - Specified by:
- pollin interface- Queue<T>
- Throws:
- IgniteException
 
 - 
peekT peek() throws IgniteException - Specified by:
- peekin interface- Queue<T>
- Throws:
- IgniteException
 
 - 
putvoid put(T item) throws IgniteException - Specified by:
- putin interface- BlockingQueue<T>
- Throws:
- IgniteException
 
 - 
takeT take() throws IgniteException - Specified by:
- takein interface- BlockingQueue<T>
- Throws:
- IgniteException
 
 - 
pollT poll(long timeout, TimeUnit unit) throws IgniteException - Specified by:
- pollin interface- BlockingQueue<T>
- Throws:
- IgniteException
 
 - 
clearvoid clear(int batchSize) throws IgniteExceptionRemoves all of the elements from this queue. Method is used in massive queues with huge numbers of elements.- Parameters:
- batchSize- Batch size.
- Throws:
- IgniteException- if operation failed.
 
 - 
closevoid close() throws IgniteExceptionRemoves this queue.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IgniteException- if operation failed.
 
 - 
capacityint capacity() Gets maximum number of elements of the queue.- Returns:
- Maximum number of elements. If queue is unbounded Integer.MAX_SIZEwill return.
 
 - 
boundedboolean bounded() Returnstrueif this queue is bounded.- Returns:
- trueif this queue is bounded.
 
 - 
collocatedboolean collocated() Returnstrueif this queue can be kept on the one node only. Returnsfalseif this queue can be kept on the many nodes.- Returns:
- trueif this queue is in- collocatedmode- falseotherwise.
 
 - 
removedboolean removed() Gets status of queue.- Returns:
- trueif queue was removed from cache- falseotherwise.
 
 - 
affinityRunvoid affinityRun(IgniteRunnable job) throws IgniteException Executes given job on collocated queue on the node where the queue is located (a.k.a. affinity co-location).This is not supported for non-collocated queues. - Parameters:
- job- Job which will be co-located with the queue.
- Throws:
- IgniteException- If job failed.
 
 - 
affinityCall<R> R affinityCall(IgniteCallable<R> job) throws IgniteException Executes given job on collocated queue on the node where the queue is located (a.k.a. affinity co-location).This is not supported for non-collocated queues. - Type Parameters:
- R- Type of the job result.
- Parameters:
- job- Job which will be co-located with the queue.
- Returns:
- Job result.
- Throws:
- IgniteException- If job failed.
 
 - 
withKeepBinary<V1> IgniteQueue<V1> withKeepBinary() Returns queue that will operate with binary objects. This is similar toIgniteCache.withKeepBinary()but for queues.- Type Parameters:
- V1- Type of the queued binary objects.
- Returns:
- New queue instance for binary objects.
 
 
- 
 
-