|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjconch.pipeline.PipeLink<T>
public class PipeLink<T>
A link in the stages of the pipeline. This class takes responsibility for all of the concurrency handling during hand-offs between pipelines. Furthermore, it abstracts the nature of the preceeding and succeeding elements -- as long as something feeds into this class or reads out of this class, it can be merged into a standard pipeline.
This class has a concept of a "fetch timeout" (getFetchTimeout()/setFetchTimeout(long)).
Although adding new elements will always be accepted, it is possible that a
stall might cause a delay in processing. The fetch timeout is the amount of
time to wait before the stall is detected. The default value is
0, which means to not wait at all, but act in pass-through
mode.
The link requires at least one source and one sink to
be registered before add(Object) and get() are usable. A
source will place elements into the link, and a sink will draw elements from
it. These registries are used for tracking status.
| Constructor Summary | |
|---|---|
protected |
PipeLink(BlockingQueue<T> queue)
Constructor. |
| Method Summary | |
|---|---|
boolean |
add(T in)
Adds an element into the link, if at all possible. |
void |
breakLink()
Breaks the link completely and permanently. |
void |
clearQueue()
Drops all elements from this link. |
T |
get()
Removes an element from the link, if any is available. |
long |
getAddTimeout()
Gets the timeout on add operations of the instance. |
long |
getFetchTimeout()
Gets the timeout on fetch operations of the instance. |
int |
getQueueLength()
Provides the number of elements currently in the queue. |
int |
getRemainingCapacity()
Provides an estimate of the number of elements the queue could additionally hold. |
void |
registerSource(Producer<T> source)
Registers a source for this pipe link. |
void |
setAddTimeout(long timeout)
Sets the add timeout of the instance. |
void |
setFetchTimeout(long newFetchTimeout)
Sets the fetch timeout of the instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected PipeLink(BlockingQueue<T> queue)
queue - The queue to use.
org.apache.commons.lang.NullArgumentException - If the argument is null| Method Detail |
|---|
public void registerSource(Producer<T> source)
source -
org.apache.commons.lang.NullArgumentException - If the argument is nullpublic boolean add(T in)
in - The element to add.
true if the add succeeded
org.apache.commons.lang.NullArgumentException - If the argument is nullpublic long getFetchTimeout()
public void setFetchTimeout(long newFetchTimeout)
fetchTimeout - the fetch timeout to set
IllegalArgumentException - If the argument is < 0.public T get()
getFetchTimeout() milliseconds for a value to
become available.
null if the link is empty.public long getAddTimeout()
public void setAddTimeout(long timeout)
fetchTimeout - the add timeout to set
IllegalArgumentException - If the argument is < 0.public int getQueueLength()
Integer.MAX_VALUEpublic int getRemainingCapacity()
Integer.MAX_VALUE if it is unbounded.public void clearQueue()
public void breakLink()
add(Object)
or get() calls will fail after calling this method.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||