public class NotificationInputSequencer extends java.lang.Object implements Notifiable
NotificationOutputSequencer.publish(Notification)
or NotificationOutputSequencer.tagNotification(Notification)
).
Notifications published through an output sequencer are
tagged with a sequence id, identifying that
output sequencer, and therefore the logical sequence, and a
sequence number, identifying a particular message within
the same logical sequence.
An input sequencer acts as a wrapper for a subscriber, intercepting notifications destined to the subscriber, and forwarding them on to the subscriber so as to guarantee the sequential ordering of messages within each sequence. In particular, an input sequencer maintains a table containing a buffer and some additional information for each active sequence. The input sequencer then processes incoming notifications as follows:
In order to support multiple sequences, an input sequencer
maintains a buffer and a counter for each sequence. The buffer
and couter for sequence S are created as soon as the
sequencer receives the first notification tagged with sequence id
S. Since the sequencer can not determine when a sequence
is no longer active, the sequencer deallocates buffers and
counters by running a garbage-collection function at regular
intervals. This fuction destroys sequence buffers and counters
that have not been used for a configurable amount of time (see
setCleanupInterval(int)
and
setCleanupTimeout(long)
.)
Example:
Siena siena;
Filter f;
Notifiable n;
// ...
// siena = new ...
// f = new Filter();
// f.addConstraint ...
// n = ...
// ...
NotificationInputSequencer sequencer;
sequencer = new NotificationInputSequencer(n);
siena.subscribe(f, sequencer);
// ...
NotificationOutputSequencer
,
Notifiable
Modifier and Type | Field and Description |
---|---|
static int |
DefaultBufferSize
default size for notification buffers.
|
static int |
DefaultCleanupInterval
default interval before sequencer cleans up its buffers table.
|
static long |
DefaultCleanupTimeout
default timeout before a sequence is considered dead.
|
static long |
DefaultLatency
default maximum latency for buffered notifications
Initial value is 10000ms (i.e., 10 seconds).
|
Constructor and Description |
---|
NotificationInputSequencer(Notifiable c)
creates an input sequencer that wraps the given notifiable
|
Modifier and Type | Method and Description |
---|---|
void |
notify(Notification n)
sends a
Notification to this Notifable
Since version 1.0.1 of the Siena API it is safe to modify the
Notification object received through this method. |
void |
notify(Notification[] s)
sends a sequence of
Notification s to this
Notifable
Since version 1.0.1 of the Siena API it is safe to modify the
Notification objects received through this method. |
void |
setBufferSize(int s)
sets the size of sequence buffers
The sequencer stores out-of-sequence notifications in sequence
buffers, waiting for notifications to come in to fill the
sequence gaps.
|
void |
setCleanupInterval(int i)
sets the number of new sequences seen before a table cleanup
The sequencer runs a periodic cleanup function to deallocate
buffers and counters for inactive sequences.
|
void |
setCleanupTimeout(long t)
sets the amount of idle time before a sequence buffer is
considered inactive.
|
void |
setLatency(long l)
sets the maximum latency for queued notifications
Notifications that would create a gap in their sequence are
buffered by the sequencer.
|
public static int DefaultBufferSize
setBufferSize(int)
public static long DefaultLatency
setLatency(long)
public static int DefaultCleanupInterval
A negative value means infinite, that means that the cleanup function is never executed. Initial value is 16.
setCleanupInterval(int)
public static long DefaultCleanupTimeout
setCleanupTimeout(long)
public NotificationInputSequencer(Notifiable c)
public void setLatency(long l)
DefaultLatency
public void setBufferSize(int s)
DefaultBufferSize
public void setCleanupInterval(int i)
setCleanupTimeout(long)
.) This parameter determines
how often this cleanup function is executed by the sequencer.
In particular, the cleanup function is executed before a new
sequence is activated, every i new sequences.DefaultCleanupInterval
public void setCleanupTimeout(long t)
DefaultCleanupTimeout
public void notify(Notification n) throws SienaException
Notifiable
Notification
to this Notifable
Since version 1.0.1 of the Siena API it is safe to modify the
Notification object received through this method. Note that:
notify
in interface Notifiable
n
- notification passed to the notifiableSienaException
Siena.subscribe(Filter,Notifiable)
public void notify(Notification[] s) throws SienaException
Notifiable
Notification
s to this
Notifable
Since version 1.0.1 of the Siena API it is safe to modify the
Notification objects received through this method. Please
read the notes in the above documentation of Notifiable.notify(Notification)
, which apply to this method as well.notify
in interface Notifiable
s
- sequence of notifications passed to the notifiableSienaException
Siena.subscribe(Pattern,Notifiable)
Copyright © 2005-2011 Antonio Carzaniga.
This documentation is maintained by Antonio Carzaniga