JavaGroups
Class AckMcastSenderWindow

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

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

Keeps track of ACKs from receivers for each message. When a new message is sent, it is tagged with a sequence number and the receiver set (set of members to which the message is sent) and added to a hashtable (key = sequence number, val = message + receiver set). Each incoming ACK is noted and when all ACKs for a specific sequence number haven been received, the corresponding entry is removed from the hashtable. A retransmission thread periodically re-sends the message point-to-point to all receivers from which no ACKs have been received yet. A view change or suspect message causes the corresponding non-existing receivers to be removed from the hashtable.

This class may need flow control in order to avoid needless retransmissions because of timeouts.

Author:
Bela Ban June 9 1999

Inner Class Summary
static interface AckMcastSenderWindow.RetransmitCommand
          Called by retransmitter thread whenever a message needs to be re-sent to a destination.
 
Constructor Summary
AckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand command)
           
 
Method Summary
 void Ack(long seqno, java.lang.Object sender)
          An ACK has been received from sender.
 void Add(long seqno, Message msg, java.util.Vector receivers)
          Adds a new message to the hash table.
 java.util.Vector GetStableMessages()
          Returns copy of stable messages, or null (if non available).
static void main(java.lang.String[] args)
           
 void Remove(java.lang.Object obj)
          Remove obj from all receiver sets and wake up retransmission thread.
 void Reset()
          Remove all entries from the hashtable.
 void run()
          Retransmitter thread.
 long Size()
           
 void Start()
           
 void Stop()
           
 void Suspect(java.lang.Object suspected)
          Process with address suspected is suspected: remove it from all receiver sets.
 java.lang.String toString()
           
 void WaitUntilAllAcksReceived(long timeout)
          Waits until all outstanding messages have been ACKed by all receivers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AckMcastSenderWindow

public AckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand command)
Method Detail

GetStableMessages

public java.util.Vector GetStableMessages()
Returns copy of stable messages, or null (if non available). Removes all stable messages afterwards

Size

public long Size()

Add

public void Add(long seqno,
                Message msg,
                java.util.Vector receivers)
Adds a new message to the hash table.
Parameters:
seqno - The sequence number associated with the message
msg - The message (should be a copy !)
receivers - The set of addresses to which the message was sent and from which consequently an ACK is expected

Ack

public void Ack(long seqno,
                java.lang.Object sender)
An ACK has been received from sender. Tag the sender in the hash table as 'received'. If all ACKs have been received, remove the entry altogether.
Parameters:
seqno - The sequence number of the message for which an ACK has been received.
sender - The sender which sent the ACK

Remove

public void Remove(java.lang.Object obj)
Remove obj from all receiver sets and wake up retransmission thread.

Suspect

public void Suspect(java.lang.Object suspected)
Process with address suspected is suspected: remove it from all receiver sets. This means that no ACKs are expected from this process anymore.
Parameters:
suspected - The suspected process

Reset

public void Reset()
Remove all entries from the hashtable. Stop the retransmitter thread

WaitUntilAllAcksReceived

public void WaitUntilAllAcksReceived(long timeout)
Waits until all outstanding messages have been ACKed by all receivers. Takes into account suspicions and view changes. Returns when there are no entries left in the hashtable. While waiting, no entries can be added to the hashtable (they will be discarded).
Parameters:
timeout - Miliseconds to wait. 0 means wait indefinitely.

run

public void run()
Retransmitter thread. While there are messages available for which not all ACKs have been received yet, retransmit those without ACKs.
Specified by:
run in interface java.lang.Runnable

toString

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

Start

public void Start()

Stop

public void Stop()

main

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