|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.netflix.curator.framework.recipes.queue.DistributedQueue<T>
public class DistributedQueue<T>
An implementation of the Distributed Queue ZK recipe. Items put into the queue are guaranteed to be ordered (by means of ZK's PERSISTENT_SEQUENTIAL node).
Guarantees:
LeaderSelector to nominate a single consumer.QueueBuilder.lockPath(String) is used, there is only guaranteed processing of each message to the point of receipt by a given instance.
If an instance receives an item from the queue but dies while processing it, the item will be lost. If you need message recoverability, use
a QueueBuilder.lockPath(String)
| Nested Class Summary | |
|---|---|
protected static class |
DistributedQueue.ProcessType
|
| Method Summary | |
|---|---|
void |
close()
|
boolean |
flushPuts(long waitTime,
java.util.concurrent.TimeUnit timeUnit)
Wait until any pending puts are committed |
protected java.util.List<java.lang.String> |
getChildren()
|
protected long |
getDelay(java.lang.String itemNode)
|
int |
getLastMessageCount()
Return the most recent message count from the queue. |
com.netflix.curator.framework.listen.ListenerContainer<QueuePutListener<T>> |
getPutListenerContainer()
Return the manager for put listeners |
protected boolean |
processWithLockSafety(java.lang.String itemNode,
DistributedQueue.ProcessType type)
|
void |
put(T item)
Add an item into the queue. |
boolean |
put(T item,
int maxWait,
java.util.concurrent.TimeUnit unit)
Same as put(Object) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems. |
void |
putMulti(MultiItem<T> items)
Add a set of items into the queue. |
boolean |
putMulti(MultiItem<T> items,
int maxWait,
java.util.concurrent.TimeUnit unit)
Same as putMulti(MultiItem) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems. |
void |
setErrorMode(ErrorMode newErrorMode)
Used when the queue is created with a QueueBuilder.lockPath(String). |
protected void |
sortChildren(java.util.List<java.lang.String> children)
|
void |
start()
Start the queue. |
protected boolean |
tryRemove(java.lang.String itemNode)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public void start()
throws java.lang.Exception
start in interface QueueBase<T>java.lang.Exception - startup errors
public void close()
throws java.io.IOException
close in interface java.io.Closeablejava.io.IOExceptionpublic com.netflix.curator.framework.listen.ListenerContainer<QueuePutListener<T>> getPutListenerContainer()
getPutListenerContainer in interface QueueBase<T>public void setErrorMode(ErrorMode newErrorMode)
QueueBuilder.lockPath(String). Determines
the behavior when the queue consumer throws an exception
setErrorMode in interface QueueBase<T>newErrorMode - the new error mode (the default is ErrorMode.REQUEUE
public boolean flushPuts(long waitTime,
java.util.concurrent.TimeUnit timeUnit)
throws java.lang.InterruptedException
flushPuts in interface QueueBase<T>waitTime - max wait timetimeUnit - time unit
java.lang.InterruptedException - if thread was interrupted
public void put(T item)
throws java.lang.Exception
QueueBuilder.maxItems, this method will
block until there is available space in the queue.
item - item to add
java.lang.Exception - connection issues
public boolean put(T item,
int maxWait,
java.util.concurrent.TimeUnit unit)
throws java.lang.Exception
put(Object) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems.
item - item to addmaxWait - maximum waitunit - wait unit
java.lang.Exception
public void putMulti(MultiItem<T> items)
throws java.lang.Exception
QueueBuilder.maxItems, this method will
block until there is available space in the queue.
items - items to add
java.lang.Exception - connection issues
public boolean putMulti(MultiItem<T> items,
int maxWait,
java.util.concurrent.TimeUnit unit)
throws java.lang.Exception
putMulti(MultiItem) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems.
items - items to addmaxWait - maximum waitunit - wait unit
java.lang.Exceptionpublic int getLastMessageCount()
getLastMessageCount in interface QueueBase<T>protected void sortChildren(java.util.List<java.lang.String> children)
protected java.util.List<java.lang.String> getChildren()
throws java.lang.Exception
java.lang.Exceptionprotected long getDelay(java.lang.String itemNode)
protected boolean tryRemove(java.lang.String itemNode)
throws java.lang.Exception
java.lang.Exception
protected boolean processWithLockSafety(java.lang.String itemNode,
DistributedQueue.ProcessType type)
throws java.lang.Exception
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||