|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.camel.processor.resequencer.ResequencerEngine<E>
public class ResequencerEngine<E>
Resequences elements based on a given SequenceElementComparator.
This resequencer is designed for resequencing element streams. Resequenced
elements are added to an output Queue. The resequencer is configured
via the timeout and capacity properties.
timeout. Defines the timeout (in milliseconds) for a
given element managed by this resequencer. An out-of-sequence element can
only be marked as ready-for-delivery if it either times out or if it
has an immediate predecessor (in that case it is in-sequence). If an
immediate predecessor of a waiting element arrives the timeout task for the
waiting element will be cancelled (which marks it as ready-for-delivery).
If the maximum out-of-sequence time between elements within a stream is
known, the timeout value should be set to this value. In this
case it is guaranteed that all elements of a stream will be delivered in
sequence to the output queue. However, large timeout values
might require a very high resequencer capacity which might be
in conflict with available memory resources. The lower the
timeout value is compared to the out-of-sequence time between
elements within a stream the higher the probability is for out-of-sequence
elements delivered by this resequencer.
capacity. The capacity of this resequencer.
The resequencer remembers the last-delivered element. If an element arrives
which is the immediate successor of the last-delivered element it will be
delivered immediately and the last-delivered element is adjusted accordingly.
If the last-delivered element is null i.e. the resequencer was
newly created the first arriving element will wait timeout
milliseconds for being delivered to the output queue.
| Constructor Summary | |
|---|---|
ResequencerEngine(SequenceElementComparator<E> comparator)
Creates a new resequencer instance with a default timeout of 2000 milliseconds. |
|
ResequencerEngine(SequenceElementComparator<E> comparator,
int capacity)
Creates a new resequencer instance with a default timeout of 2000 milliseconds. |
|
| Method Summary | |
|---|---|
void |
add(E o)
Adds an element to this resequencer throwing an exception if the maximum capacity is reached. |
Queue<E> |
getOutQueue()
Returns the output queue. |
long |
getTimeout()
Returns this resequencer's timeout value. |
void |
put(E o)
Adds an element to this resequencer waiting, if necessary, until capacity becomes available. |
void |
setOutQueue(Queue<E> outQueue)
Sets the output queue. |
void |
setTimeout(long timeout)
Sets this sequencer's timeout value. |
void |
stop()
Stops this resequencer (i.e. |
void |
timeout(Timeout timout)
Handles a timeout notification by starting a delivery attempt. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResequencerEngine(SequenceElementComparator<E> comparator)
Integer.MAX_VALUE.
comparator - a sequence element comparator.
public ResequencerEngine(SequenceElementComparator<E> comparator,
int capacity)
comparator - a sequence element comparator.capacity - the capacity of this resequencer.| Method Detail |
|---|
public void stop()
Timer instance).
public Queue<E> getOutQueue()
public void setOutQueue(Queue<E> outQueue)
outQueue - output queue.public long getTimeout()
public void setTimeout(long timeout)
timeout - the timeout in milliseconds.public void timeout(Timeout timout)
timeout in interface TimeoutHandlertimout - timeout task that caused the notification.public void add(E o)
o - element to be resequenced.
IllegalStateException - if the element cannot be added at this time
due to capacity restrictions.
public void put(E o)
throws InterruptedException
o - element to be resequenced.
InterruptedException - if interrupted while waiting.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||