|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ostore.dispatch.Resender
A utility class that automatically re-dispatches events.
If an attempt to dispatch
an event throws a
SinkFullException
, the Resender
schedules the
event for a later attempt and returns a unique, opaque token. That
token can be used later to confirm or cancel delivery.
NOTE: A Resender
does not guarantee any delivery
order for events which are initially delayed. If in-order delivery is
important, do not use the automatic re-dispatching features, or avoid
this class completely.
Any stage which uses a Resender
must
Signal.register(int, java.lang.String, mdw.sandStorm.api.SinkIF)
for Signal.ALRM
signals targetted at the
name given to the Resender
constructor. The
Resender
will set its own alarms; the stage must catch the
resulting AlarmSignal
s and call process_queues()
.
Constructor Summary | |
Resender(NodeId node_id,
String stage_name)
Creates a new Resender object that uses the
default Classifier for the specified machine. |
Method Summary | |
boolean |
cancel(Object token)
Cancels the specified event. |
QueueElementIF[] |
clear(boolean all)
Cancels all events which have timed out. |
Object |
dispatch(QueueElementIF event)
Dispatches an event through the Classifier . |
Object |
dispatch(QueueElementIF event,
int num_retries,
long millis)
Dispatch the specified event, making at most num_retries additional attempts, waiting
millis milliseconds in between attempts. |
boolean |
pending(Object token)
Checks whether the specified event is scheduled for further attempts. |
void |
process_queues()
Processes the queue of pending events, sending any whose deadlines have been reaced. |
boolean |
timed_out(Object token)
Checks whether the specified event was been successfully dispatched. |
boolean |
was_sent(Object token)
Checks whether the specified event has been successfully dispatched. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Resender(NodeId node_id, String stage_name)
Resender
object that uses the
default Classifier
for the specified machine.node_id
- The ID for this machine - needed to locate the
correct Classifier
and Signal
.stage_name
- The name of the calling stage - needed to
address AlarmSignal
s properly.Method Detail |
public void process_queues()
This method should be called each time the stage receives an
AlarmSignal
.
public Object dispatch(QueueElementIF event)
Classifier
.
If the dispatch fails, the event is stored in a trash pile. Events
on the trash pile can be recovered by the clear(boolean)
method.
event
- Any event to dispatchnull
if the object was successfully dispatched.dispatch(mdw.sandStorm.api.QueueElementIF, int, long)
,
Classifier.dispatch(mdw.sandStorm.api.QueueElementIF)
public Object dispatch(QueueElementIF event, int num_retries, long millis)
num_retries
additional attempts, waiting
millis
milliseconds in between attempts.
After enough attempts have failed, the event is stored in a trash
pile. Events on the trash pile can be recovered by the
clear(boolean)
method.
event
- Any event to dispatchnum_retries
- The number (>=0) of times to try
dispatching the event if the initial attempt fails.millis
- The number of milliseconds to wait after each
attempt.- Returns:
- a token, used to reference the event later, or
null
if the object was successfully dispatched on the
first try. - See Also:
dispatch(mdw.sandStorm.api.QueueElementIF)
,
Classifier.dispatch(mdw.sandStorm.api.QueueElementIF)
public boolean cancel(Object token)
Resender
. If the event has already dispatched
successfully, this method does nothing.token
- A token returned by dispatch(mdw.sandStorm.api.QueueElementIF)
.true
iff the event has not yet been dispatched
successfully.dispatch(mdw.sandStorm.api.QueueElementIF, int, long)
public boolean timed_out(Object token)
token
- A token returned by dispatch(mdw.sandStorm.api.QueueElementIF)
.true
iff the event has timed out.dispatch(mdw.sandStorm.api.QueueElementIF, int, long)
public boolean pending(Object token)
token
- A token returned by dispatch(mdw.sandStorm.api.QueueElementIF)
.true
iff the event is on the queue for another
attempted dispatch.dispatch(mdw.sandStorm.api.QueueElementIF, int, long)
public boolean was_sent(Object token)
Equivalent to ( !pending(token) && !timed_out(token) )
.
token
- A token returned by dispatch(mdw.sandStorm.api.QueueElementIF)
.true
iff the Resender
no longer
has any memory of the token
, which dispatch(mdw.sandStorm.api.QueueElementIF, int, long)
public QueueElementIF[] clear(boolean all)
all ==
true
, also cancels all pending events.all
- true
iff pending events should also be
cancelled.dispatch(mdw.sandStorm.api.QueueElementIF, int, long)
,
cancel(java.lang.Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |