JavaGroups
Class AckSenderWindow

java.lang.Object
  |
  +--JavaGroups.AckSenderWindow

public class AckSenderWindow
extends java.lang.Object
implements java.lang.Runnable

ACK-based sliding window for a sender. Messages are added to the window according to message IDs. When an ACK is received, the corresponding entry is marked and the window advanced as much as possible. A retransmission thread continously iterates over the entries, retransmitting messages for which no ACK has been received in timeout time.


Inner Class Summary
static interface AckSenderWindow.RetransmitCommand
           
 
Constructor Summary
AckSenderWindow(AckSenderWindow.RetransmitCommand com, long initial_seqno)
          Creates a new instance.
 
Method Summary
 void Ack(long seqno)
          Marks one message as received.
 void Add(long seqno, Message msg)
          Add a new message.
 long GetNextSeqno()
           
 long GetTimeout()
           
static void main(java.lang.String[] args)
           
 void Reset()
           
 void run()
          Iterate over msgs.
 void SetTimeout(long timeout)
           
 void Start()
          Starts the retransmission thread (will not be started automatically !).
 void Stop()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AckSenderWindow

public AckSenderWindow(AckSenderWindow.RetransmitCommand com,
                       long initial_seqno)
Creates a new instance. Thre retransmission thread has to be started separately with Start.
Parameters:
com - If not null, its method Retransmit will be called when a message needs to be retransmitted (called by the retransmitter thread).
initial_seqno - The first sequence number to expect an ACK for.
Method Detail

GetNextSeqno

public long GetNextSeqno()

GetTimeout

public long GetTimeout()

SetTimeout

public void SetTimeout(long timeout)

Start

public void Start()
Starts the retransmission thread (will not be started automatically !). The thread scans over the messages sent and requests retransmission for those that haven't received an ACK for a certain period of time.

Stop

public void Stop()

Reset

public void Reset()

Add

public void Add(long seqno,
                Message msg)
Add a new message. seqno should always be 1 higher than the previous one. Messages will be ordered according to seqno. Note that msg must be a copy of the message, otherwise the entry stored in this table might be modified by the message traveling down the stack (e.g. addition of headers) !

Ack

public void Ack(long seqno)
Marks one message as received. Removes as many messages as possible (removing them also from retransmission), sets next_seqno correspondingly.

run

public void run()
Iterate over msgs. For entries that haven't received an ACK within timeout time, issue a retransmission command.
Specified by:
run in interface java.lang.Runnable

toString

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

main

public static void main(java.lang.String[] args)