|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | 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, seda.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. |
|
Resender(NodeId node_id,
String stage_name,
boolean debug)
Creates a new Resender object that uses the
default Classifier for the specified machine. |
Method Summary | |
---|---|
QueueElementIF |
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. |
Object |
remember(QueueElementIF event,
long millis)
Waits millis milliseconds, then stores the event in the
trash pile. |
Object |
remember(QueueElementIF event,
long millis,
Map map,
Object key)
Waits millis milliseconds, then stores the event in the
trash pile. |
Object |
remember(QueueElementIF event,
long millis,
Map map,
Set keys)
Waits millis milliseconds, then stores the event in the
trash pile. |
Object |
resend(QueueElementIF event,
int num_retries,
long millis)
Repeatedly dispatches the specified event, num_retries
times, waiting millis milliseconds in between attempts.
|
Object |
resend(QueueElementIF event,
int num_retries,
long millis,
Map map,
Object key)
Repeatedly dispatches the specified event, num_retries
times, waiting millis milliseconds in between attempts.
|
Object |
resend(QueueElementIF event,
int num_retries,
long millis,
Map map,
Set keys)
Repeatedly dispatches the specified event, num_retries
times, waiting millis milliseconds in between attempts.
|
Object |
send(QueueElementIF event,
long millis)
Dispatches the specified event, waits millis
milliseconds, then stores the event in the trash pile.
|
Object |
send(QueueElementIF event,
long millis,
Map map,
Object key)
Dispatches the specified event, waits millis
milliseconds, then stores the event in the trash pile.
|
Object |
send(QueueElementIF event,
long millis,
Map map,
Set keys)
Dispatches the specified event, waits millis
milliseconds, then stores the event in the trash pile.
|
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.public Resender(NodeId node_id, String stage_name, boolean debug)
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 dispatch
null
if the object was successfully dispatched.dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
Classifier.dispatch(seda.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(seda.sandStorm.api.QueueElementIF)
,
resend(seda.sandStorm.api.QueueElementIF, int, long)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object resend(QueueElementIF event, int num_retries, long millis)
num_retries
times, 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.
Unlike dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
this method resends the event even if it dispatches correctly.
It is therefore slightly more expensive and should be used only when
these semantics are required.
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.
- See Also:
dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object resend(QueueElementIF event, int num_retries, long millis, Map map, Object key)
num_retries
times, 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.
Unlike dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
this method resends the event even if it dispatches correctly.
It is therefore slightly more expensive and should be used only when
these semantics are required.
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.map
- Map used to record state by the stagekey
- Key to store token in the map.
- Returns:
- a token, used to reference the event later.
- See Also:
dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object resend(QueueElementIF event, int num_retries, long millis, Map map, Set keys)
num_retries
times, 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.
Unlike dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
this method resends the event even if it dispatches correctly.
It is therefore slightly more expensive and should be used only when
these semantics are required.
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.map
- Map used to record state by the stagekeys
- Set of keys to store the same token
in the map.
- Returns:
- a token, used to reference the event later.
- See Also:
dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object send(QueueElementIF event, long millis)
millis
milliseconds, then stores the event in the trash pile.
Events on the trash pile can be recovered by the clear(boolean)
method.
Unlike dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
this method remembers the event even if it dispatches correctly.
Unlike resend(seda.sandStorm.api.QueueElementIF, int, long)
,
this method does not try to resend the event.
Use that method instead if the event may be lost (e.g. a
NetworkMessage
) and duplicate messages are acceptable.
event
- Any event to dispatchmillis
- The number of milliseconds to wait before
trashing the event.
resend(seda.sandStorm.api.QueueElementIF, int, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object send(QueueElementIF event, long millis, Map map, Object key)
millis
milliseconds, then stores the event in the trash pile.
Events on the trash pile can be recovered by the clear(boolean)
method.
Unlike dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
this method remembers the event even if it dispatches correctly.
Unlike resend(seda.sandStorm.api.QueueElementIF, int, long)
,
this method does not try to resend the event.
Use that method instead if the event may be lost (e.g. a
NetworkMessage
) and duplicate messages are acceptable.
event
- Any event to dispatchmillis
- The number of milliseconds to wait before
trashing the event.map
- Map used to record state by the stagekey
- Key to store token in the map.
resend(seda.sandStorm.api.QueueElementIF, int, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object send(QueueElementIF event, long millis, Map map, Set keys)
millis
milliseconds, then stores the event in the trash pile.
Events on the trash pile can be recovered by the clear(boolean)
method.
Unlike dispatch(seda.sandStorm.api.QueueElementIF, int, long)
,
this method remembers the event even if it dispatches correctly.
Unlike resend(seda.sandStorm.api.QueueElementIF, int, long)
,
this method does not try to resend the event.
Use that method instead if the event may be lost (e.g. a
NetworkMessage
) and duplicate messages are acceptable.
event
- Any event to dispatchmillis
- The number of milliseconds to wait before
trashing the event.map
- Map used to record state by the stagekeys
- Set of keys to store same token in
the map.
resend(seda.sandStorm.api.QueueElementIF, int, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object remember(QueueElementIF event, long millis)
millis
milliseconds, then stores the event in the
trash pile. Events on the trash pile can be recovered by the
clear(boolean)
method.
Unlike the other methods, this one never tries to send the event. It is provided as a convenient interface to the internal timeout support.
event
- Any event to remembermillis
- The number of milliseconds to wait before
trashing the event.
resend(seda.sandStorm.api.QueueElementIF, int, long)
,
send(seda.sandStorm.api.QueueElementIF, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object remember(QueueElementIF event, long millis, Map map, Object key)
millis
milliseconds, then stores the event in the
trash pile. Events on the trash pile can be recovered by the
clear(boolean)
method.
Unlike the other methods, this one never tries to send the event. It is provided as a convenient interface to the internal timeout support.
event
- Any event to remembermillis
- The number of milliseconds to wait before
trashing the event.map
- Map used to record state by the stagekey
- Key to store token in the map.
resend(seda.sandStorm.api.QueueElementIF, int, long)
,
send(seda.sandStorm.api.QueueElementIF, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public Object remember(QueueElementIF event, long millis, Map map, Set keys)
millis
milliseconds, then stores the event in the
trash pile. Events on the trash pile can be recovered by the
clear(boolean)
method.
Unlike the other methods, this one never tries to send the event. It is provided as a convenient interface to the internal timeout support.
event
- Any event to remembermillis
- The number of milliseconds to wait before
trashing the event.map
- Map used to record state by the stagekeys
- Set of keys to store the same token
in the map.
resend(seda.sandStorm.api.QueueElementIF, int, long)
,
send(seda.sandStorm.api.QueueElementIF, long)
,
cancel(Object)
,
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)
public QueueElementIF cancel(Object token)
Resender
. If the event has already dispatched
successfully, this method does nothing.
token
- A token returned by dispatch(seda.sandStorm.api.QueueElementIF)
.
null
.dispatch(seda.sandStorm.api.QueueElementIF, int, long)
public boolean timed_out(Object token)
token
- A token returned by dispatch(seda.sandStorm.api.QueueElementIF)
.
true
iff the event has timed out.dispatch(seda.sandStorm.api.QueueElementIF, int, long)
public boolean pending(Object token)
token
- A token returned by dispatch(seda.sandStorm.api.QueueElementIF)
.
true
iff the event is on the queue for another
attempted dispatch.dispatch(seda.sandStorm.api.QueueElementIF, int, long)
public boolean was_sent(Object token)
Equivalent to ( !pending(token) && !timed_out(token) )
.
token
- A token returned by dispatch(seda.sandStorm.api.QueueElementIF)
.
true
iff the Resender
no longer
has any memory of the token
, which dispatch(seda.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(seda.sandStorm.api.QueueElementIF, int, long)
,
cancel(java.lang.Object)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |