|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.netflix.curator.framework.recipes.queue.BlockingQueueConsumer<T>
public class BlockingQueueConsumer<T>
Utility - a queue consumer that provides behavior similar to a BlockingQueue
| Constructor Summary | |
|---|---|
BlockingQueueConsumer(ConnectionStateListener connectionStateListener)
Creates with capacity of Integer.MAX_VALUE |
|
BlockingQueueConsumer(ConnectionStateListener connectionStateListener,
BlockingQueue<T> queue)
Wrap the given blocking queue |
|
BlockingQueueConsumer(ConnectionStateListener connectionStateListener,
int capacity)
|
|
| Method Summary | |
|---|---|
void |
consumeMessage(T message)
Process a message from the queue |
int |
drainTo(Collection<? super T> c)
Removes all available elements from this queue and adds them to the given collection. |
List<T> |
getItems()
Return any currently queued items without removing them from the queue |
int |
size()
Returns the number of currently queue items |
void |
stateChanged(CuratorFramework client,
ConnectionState newState)
|
T |
take()
Take the next item from the queue, blocking until there is an item available |
T |
take(int time,
TimeUnit unit)
Take the next item from the queue, waiting up to the specified time for an available item. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BlockingQueueConsumer(ConnectionStateListener connectionStateListener)
Integer.MAX_VALUE
connectionStateListener - listener for connection state changes
public BlockingQueueConsumer(ConnectionStateListener connectionStateListener,
int capacity)
capacity - max capacity (i.e. puts block if full)connectionStateListener - listener for connection state changes
public BlockingQueueConsumer(ConnectionStateListener connectionStateListener,
BlockingQueue<T> queue)
queue - queue to useconnectionStateListener - listener for connection state changes| Method Detail |
|---|
public void consumeMessage(T message)
throws Exception
QueueConsumer
consumeMessage in interface QueueConsumer<T>message - message to process
Exception - any errorspublic List<T> getItems()
public int size()
public T take()
throws InterruptedException
InterruptedException - thread interruption
public T take(int time,
TimeUnit unit)
throws InterruptedException
null is returned.
time - amount of time to blockunit - time unit
InterruptedException - thread interruptionpublic int drainTo(Collection<? super T> c)
c - the collection to transfer elements into
UnsupportedOperationException - if addition of elements
is not supported by the specified collection
ClassCastException - if the class of an element of this queue
prevents it from being added to the specified collection
NullPointerException - if the specified collection is null
IllegalArgumentException - if the specified collection is this
queue, or some property of an element of this queue prevents
it from being added to the specified collection
public void stateChanged(CuratorFramework client,
ConnectionState newState)
stateChanged in interface ConnectionStateListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||