Package org.jgroups.stack
Class Retransmitter
java.lang.Object
org.jgroups.stack.Retransmitter
Maintains a pool of sequence numbers of messages that need to be retransmitted. Messages
are aged and retransmission requests sent according to age (configurable backoff). If a
TimeScheduler instance is given to the constructor, it will be used, otherwise Reransmitter
will create its own. The retransmit timeouts have to be set first thing after creating an instance.
The
Changes Aug 2007 (bela): the retransmitter was completely rewritten. Entry was removed, instead all tasks are directly placed into a hashmap, keyed by seqnos. When a message has been received, we simply remove the task from the hashmap and cancel it. This simplifies the code and avoids having to iterate through the (previous) message list linearly on removal. Performance is about the same, or slightly better in informal tests.
add()
method adds the sequence numbers of messages to be retransmitted. The
remove()
method removes a sequence number again, cancelling retransmission requests for it.
Whenever a message needs to be retransmitted, the RetransmitCommand.retransmit()
method is called.
It can be used e.g. by an ack-based scheme (e.g. AckSenderWindow) to retransmit a message to the receiver, or
by a nak-based scheme to send a retransmission request to the sender of the missing message.Changes Aug 2007 (bela): the retransmitter was completely rewritten. Entry was removed, instead all tasks are directly placed into a hashmap, keyed by seqnos. When a message has been received, we simply remove the task from the hashmap and cancel it. This simplifies the code and avoids having to iterate through the (previous) message list linearly on removal. Performance is about the same, or slightly better in informal tests.
- Version:
- $Revision: 1.23.2.1.2.1 $
- Author:
- Bela Ban
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Retransmit command (see Gamma et al.) used to retrieve missing messages -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRetransmitter
(Address sender, Retransmitter.RetransmitCommand cmd) Create a new Retransmitter associated with the given sender addressRetransmitter
(Address sender, Retransmitter.RetransmitCommand cmd, TimeScheduler sched) Create a new Retransmitter associated with the given sender address -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long first_seqno, long last_seqno) Add the given range [first_seqno, last_seqno] in the list of entries eligible for retransmission.int
remove
(long seqno) Remove the given sequence number from the list of seqnos eligible for retransmission.void
reset()
Reset the retransmitter: clear all msgs and cancel all the respective tasksvoid
setRetransmitTimeouts
(Interval interval) int
size()
void
stop()
Stop the rentransmition and clear all pending msgs.toString()
-
Field Details
-
log
protected static final org.apache.commons.logging.Log log
-
-
Constructor Details
-
Retransmitter
Create a new Retransmitter associated with the given sender address- Parameters:
sender
- the address from which retransmissions are expected or to which retransmissions are sentcmd
- the retransmission callback referencesched
- retransmissions scheduler
-
Retransmitter
Create a new Retransmitter associated with the given sender address- Parameters:
sender
- the address from which retransmissions are expected or to which retransmissions are sentcmd
- the retransmission callback reference
-
-
Method Details
-
setRetransmitTimeouts
-
add
public void add(long first_seqno, long last_seqno) Add the given range [first_seqno, last_seqno] in the list of entries eligible for retransmission. If first_seqno > last_seqno, then the range [last_seqno, first_seqno] is added insteadIf retransmitter thread is suspended, wake it up
-
remove
public int remove(long seqno) Remove the given sequence number from the list of seqnos eligible for retransmission. If there are no more seqno intervals in the respective entry, cancel the entry from the retransmission scheduler and remove it from the pending entries -
reset
public void reset()Reset the retransmitter: clear all msgs and cancel all the respective tasks -
stop
public void stop()Stop the rentransmition and clear all pending msgs.If this retransmitter has been provided an externally managed scheduler, then just clear all msgs and the associated tasks, else stop the scheduler. In this case the method blocks until the scheduler's thread is dead. Only the owner of the scheduler should stop it.
-
toString
-
size
public int size()
-