|
Keel 2.1RC2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.excalibur.event.impl.LossyMultiCastSink
This is a org.apache.excalibur.event.seda.event.Sink implementation that multicasts enqueue operations to the contained and concrete sink objects. Compared to the regular org.apache.excalibur.event.seda.event.impl.MultiCastSink this sink works in that it delivers zero, one or more sinks. It can be configured to fail when less than one sink was delivered to.
| Nested Class Summary | |
private static class |
LossyMultiCastSink.DefaultPreparedEnqueueA prepared enqueue object that holds other prepared enqueue objects and allows to perform a commit / abort on all of these objects. |
| Field Summary | |
private boolean |
m_oneSuccessindicates if at least one enqueue operation must succeed. |
private java.util.Collection |
m_sinksA collection of sink arrays representing the sinks to enqueue the element to. |
private int |
m_sizeThe size of the sink. |
| Fields inherited from interface org.apache.excalibur.event.Sink |
ROLE |
| Constructor Summary | |
LossyMultiCastSink(java.util.Collection sinks)This constructor creates a failure tolerant sink based on the collection of sink arrays. |
|
LossyMultiCastSink(java.util.Collection sinks, boolean oneSuccess)This constructor creates a failure tolerant sink based on the collection of sink arrays. |
|
| Method Summary | |
int |
canAccept()Returns the number of elements it can currently accept. |
void |
enqueue(java.lang.Object element)Enqueues the given element onto the Sink. |
void |
enqueue(java.lang.Object[] elements)Given an array of elements, atomically enqueues all of the elements in the array. |
boolean |
isFull()Returns true if this sink has reached its threshold; false otherwise. |
int |
maxSize()Returns the length threshold of the sink. |
PreparedEnqueue |
prepareEnqueue(java.lang.Object[] elements)Support for transactional enqueue. |
int |
size()Returns the number of elements waiting in this Sink. |
boolean |
tryEnqueue(java.lang.Object element)Tries to enqueue an event, but instead of throwing exceptions, it returns a boolean value of whether the attempt was successful. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private final java.util.Collection m_sinks
private final int m_size
private final boolean m_oneSuccess
| Constructor Detail |
public LossyMultiCastSink(java.util.Collection sinks)
sinks - A collection of sink arrays for each stage.
public LossyMultiCastSink(java.util.Collection sinks,
boolean oneSuccess)
sinks - A collection of sink arrays for each stage.| Method Detail |
public int canAccept()
Sinksize() and maxSize(). It will return -1 if the sink is unbounded.
canAccept in interface SinkSink.canAccept()public boolean isFull()
SinkisFull in interface SinkSink.isFull()public int maxSize()
SinkmaxSize in interface SinkSink.maxSize()
public void enqueue(java.lang.Object element)
throws SinkException
Sinkenqueue in interface Sinkelement - The elements to enqueueSinkExceptionSink.enqueue(Object)
public void enqueue(java.lang.Object[] elements)
throws SinkException
Sinkenqueue in interface Sinkelements - The element array to enqueueSinkExceptionSink.enqueue(Object[])public boolean tryEnqueue(java.lang.Object element)
SinktryEnqueue in interface Sinkelement - The element to attempt to enqueuetrue if successful, false if not.Sink.tryEnqueue(Object)
public PreparedEnqueue prepareEnqueue(java.lang.Object[] elements)
throws SinkException
SinkThis method allows a client to provisionally enqueue a number of elements onto the queue, and then later commit the enqueue (with a commitEnqueue call), or abort (with an abortEnqueue call). This mechanism can be used to perform "split-phase" enqueues, where a client first enqueues a set of elements on the queue and then performs some work to "fill in" those elements before performing a commit. This can also be used to perform multi-queue transactional enqueue operations, with an "all-or-nothing" strategy for enqueueing events on multiple Sinks.
This method would generally be used in the following manner:
PreparedEnqueue enqueue = sink.prepareEnqueue(someElements);
if (canCommit) {
enqueue.commit();
} else {
enqueue.abort();
}
Note that this method does not protect against "dangling prepares" -- that is, a prepare without an associated commit or abort operation. This method should be used with care. In particular, be sure that all code paths (such as exceptions) after a prepare include either a commit or an abort.
prepareEnqueue in interface Sinkelements - The element array to provisionally enqueuePreparedEnqueue that may be used to commit or abort the provisional enqueueSinkExceptionSink.prepareEnqueue(Object[])public int size()
SinkImportant: The contract for this method was updated to account for any elements that were prepared for enqueueing. It provides a more predictable and consistent environment, as well as making it easier for EnqueuePredicates to account for those elements.
size in interface SinkSink.size()
|
Keel 2.1RC2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||