public abstract class GridCacheQueueAdapter<T> extends AbstractCollection<T> implements GridCacheQueue<T>
GridCacheQueue implementation.| Modifier and Type | Class and Description |
|---|---|
protected static class |
GridCacheQueueAdapter.AddClosure |
protected static class |
GridCacheQueueAdapter.ClearClosure |
protected static class |
GridCacheQueueAdapter.PollClosure |
protected static class |
GridCacheQueueAdapter.RemoveClosure |
| Modifier and Type | Field and Description |
|---|---|
protected GridCacheAdapter |
cache
Cache.
|
protected GridCacheContext<?,?> |
cctx
Cache context.
|
protected GridUuid |
id
Queue unique ID.
|
protected GridLogger |
log
Logger.
|
protected static int |
MAX_UPDATE_RETRIES |
protected static long |
QUEUE_REMOVED_IDX
Value returned by closure updating queue header indicating that queue was removed.
|
protected GridCacheQueueHeaderKey |
queueKey
Queue header key.
|
protected String |
queueName
Queue name.
|
protected static long |
RETRY_DELAY |
| Modifier | Constructor and Description |
|---|---|
protected |
GridCacheQueueAdapter(String queueName,
GridCacheQueueHeader hdr,
GridCacheContext<?,?> cctx) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T item) |
boolean |
bounded()
Returns
true if this queue is bounded. |
int |
capacity()
Gets maximum number of elements of the queue.
|
protected void |
checkRemoved(GridCacheQueueHeader hdr)
Checks queue state, throws
GridCacheDataStructureRemovedRuntimeException if queue was removed. |
protected void |
checkRemoved(Long idx)
Checks result of closure modifying queue header, throws
GridCacheDataStructureRemovedRuntimeException
if queue was removed. |
void |
clear(int batchSize)
Removes all of the elements from this queue.
|
boolean |
collocated()
Returns
true if this queue can be kept on the one node only. |
int |
drainTo(Collection<? super T> c) |
int |
drainTo(Collection<? super T> c,
int maxElements) |
T |
element() |
boolean |
equals(Object o) |
int |
hashCode() |
protected org.gridgain.grid.kernal.processors.cache.datastructures.GridCacheQueueItemKey |
itemKey(Long idx) |
Iterator<T> |
iterator() |
String |
name()
Gets queue name.
|
boolean |
offer(T item,
long timeout,
TimeUnit unit) |
T |
peek() |
T |
poll(long timeout,
TimeUnit unit) |
void |
put(T item) |
int |
remainingCapacity() |
T |
remove() |
boolean |
removed()
Gets status of queue.
|
protected abstract void |
removeItem(long rmvIdx)
Removes item with given index from queue.
|
int |
size() |
T |
take() |
String |
toString() |
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayprotected static final long QUEUE_REMOVED_IDX
protected static final int MAX_UPDATE_RETRIES
protected static final long RETRY_DELAY
protected final GridLogger log
protected final GridCacheContext<?,?> cctx
protected final GridCacheAdapter cache
protected final String queueName
protected final GridCacheQueueHeaderKey queueKey
protected final GridUuid id
protected GridCacheQueueAdapter(String queueName, GridCacheQueueHeader hdr, GridCacheContext<?,?> cctx)
queueName - Queue name.hdr - Queue hdr.cctx - Cache context.public String name()
name in interface GridCacheQueue<T>public boolean add(T item)
add in interface Collection<T>add in interface BlockingQueue<T>add in interface Queue<T>add in interface GridCacheQueue<T>add in class AbstractCollection<T>public 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.collocated in interface GridCacheQueue<T>true if this queue is in collocated mode false otherwise.public int capacity()
throws GridException
capacity in interface GridCacheQueue<T>Integer.MAX_SIZE will return.GridException - If operation failed.public boolean bounded()
true if this queue is bounded.bounded in interface GridCacheQueue<T>true if this queue is bounded.public int size()
size in interface Collection<T>size in interface GridCacheQueue<T>size in class AbstractCollection<T>@Nullable public T peek() throws GridRuntimeException
peek in interface Queue<T>peek in interface GridCacheQueue<T>GridRuntimeExceptionpublic Iterator<T> iterator()
iterator in interface Iterable<T>iterator in interface Collection<T>iterator in interface GridCacheQueue<T>iterator in class AbstractCollection<T>public void put(T item) throws GridRuntimeException
put in interface BlockingQueue<T>put in interface GridCacheQueue<T>GridRuntimeExceptionpublic boolean offer(T item, long timeout, TimeUnit unit) throws GridRuntimeException
offer in interface BlockingQueue<T>offer in interface GridCacheQueue<T>GridRuntimeException@Nullable public T take() throws GridRuntimeException
take in interface BlockingQueue<T>take in interface GridCacheQueue<T>GridRuntimeException@Nullable public T poll(long timeout, TimeUnit unit) throws GridRuntimeException
poll in interface BlockingQueue<T>poll in interface GridCacheQueue<T>GridRuntimeExceptionpublic int remainingCapacity()
remainingCapacity in interface BlockingQueue<T>public void clear(int batchSize)
throws GridRuntimeException
clear in interface GridCacheQueue<T>batchSize - Batch size.GridRuntimeException - if operation failed.public int drainTo(Collection<? super T> c)
drainTo in interface BlockingQueue<T>public int drainTo(Collection<? super T> c, int maxElements)
drainTo in interface BlockingQueue<T>public boolean removed()
removed in interface GridCacheQueue<T>true if queue was removed from cache false otherwise.protected final void checkRemoved(Long idx)
GridCacheDataStructureRemovedRuntimeException
if queue was removed.idx - Result of closure execution.protected final void checkRemoved(@Nullable GridCacheQueueHeader hdr)
GridCacheDataStructureRemovedRuntimeException if queue was removed.hdr - Queue hdr.protected abstract void removeItem(long rmvIdx)
throws GridException
rmvIdx - Index of item to be removed.GridException - If failed.protected org.gridgain.grid.kernal.processors.cache.datastructures.GridCacheQueueItemKey itemKey(Long idx)
idx - Item index.public boolean equals(Object o)
equals in interface Collection<T>equals in class Objectpublic int hashCode()
hashCode in interface Collection<T>hashCode in class Objectpublic String toString()
toString in class AbstractCollection<T>Copyright © 2014. All rights reserved.