org.jgroups.stack
Class DefaultRetransmitter

java.lang.Object
  extended by org.jgroups.stack.Retransmitter
      extended by org.jgroups.stack.DefaultRetransmitter

public class DefaultRetransmitter
extends 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 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.

Author:
Bela Ban

Nested Class Summary
protected  class DefaultRetransmitter.SeqnoTask
           
 
Nested classes/interfaces inherited from class org.jgroups.stack.Retransmitter
Retransmitter.RetransmitCommand, Retransmitter.Task
 
Field Summary
 
Fields inherited from class org.jgroups.stack.Retransmitter
cmd, log, retransmit_timeouts, sender, timer, xmit_stagger_timeout
 
Constructor Summary
DefaultRetransmitter(Address sender, Retransmitter.RetransmitCommand cmd, TimeScheduler sched)
          Create a new Retransmitter associated with the given sender address
 
Method Summary
 void add(long first_seqno, long last_seqno)
          Add the given range [first_seqno, last_seqno] in the list of entries eligible for retransmission.
 void remove(long seqno)
          Remove the given sequence number from the list of seqnos eligible for retransmission.
 void remove(long seqno, boolean remove_all_below)
          Removes the given seqno and all seqnos lower than it
 void reset()
          Reset the retransmitter: clear all msgs and cancel all the respective tasks
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class org.jgroups.stack.Retransmitter
getXmitStaggerTimeout, setRetransmitTimeouts, setXmitStaggerTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultRetransmitter

public DefaultRetransmitter(Address sender,
                            Retransmitter.RetransmitCommand cmd,
                            TimeScheduler sched)
Create a new Retransmitter associated with the given sender address

Parameters:
sender - the address from which retransmissions are expected or to which retransmissions are sent
cmd - the retransmission callback reference
sched - retransmissions scheduler
Method Detail

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 instead

Specified by:
add in class Retransmitter

remove

public void 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

Specified by:
remove in class Retransmitter

remove

public void remove(long seqno,
                   boolean remove_all_below)
Removes the given seqno and all seqnos lower than it

Parameters:
seqno -
remove_all_below - If true, all seqnos below seqno are removed, too

reset

public void reset()
Reset the retransmitter: clear all msgs and cancel all the respective tasks

Specified by:
reset in class Retransmitter

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

size

public int size()
Specified by:
size in class Retransmitter


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.