JavaGroups
Class NakReceiverWindow

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

public class NakReceiverWindow
extends java.lang.Object

Keeps track of messages according to their sequence numbers. Allows messages to be added out of order, and with gaps between sequence numbers. Method Remove removes the first message with a sequence number that is 1 higher than next_to_remove (this variable is then incremented), or it returns null if no message is present, or if no message's sequence number is 1 higher.

Started out as a copy of SlidingWindow. Main diff: RetransmitCommand is different, and retransmission thread is only created upon detection of a gap.

Author:
Bela Ban May 27 1999

Inner Class Summary
static interface NakReceiverWindow.RetransmitCommand
          Retransmit command (see Gamma et al.) used by the sliding window table to retrieve missing messages.
 
Constructor Summary
NakReceiverWindow(java.lang.Object sender, NakReceiverWindow.RetransmitCommand command, long start_seqno)
           
 
Method Summary
 void Add(long seqno, Message msg)
          Adds a message according to its sequence number (ordered).
 void finalize()
           
 long GetHighestDelivered()
          Returns the highest sequence number of a message consumed by the application (by Remove())
 long GetHighestReceived()
          Returns the highest sequence number received so far (which may be higher than the highest seqno delivered so far
 List GetMessagesHigherThan(long seqno)
          Return messages that are higher than seqno (excluding seqno)
 List GetMessagesInRange(long lower, long upper)
          Return all messages m for which the following holds: m > lower && m <= upper (excluding lower, including upper).
static void main(java.lang.String[] args)
           
 Message Remove()
          Find the entry with seqno head.
 void Reset()
          Deletes all entries
 void SetRetransmitPeriod(long t)
           
 int Size()
           
 void Stable(long seqno)
          Delete all messages <= seqno (they are stable, that is, have been received at all members).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NakReceiverWindow

public NakReceiverWindow(java.lang.Object sender,
                         NakReceiverWindow.RetransmitCommand command,
                         long start_seqno)
Method Detail

finalize

public void finalize()

SetRetransmitPeriod

public void SetRetransmitPeriod(long t)

Add

public void Add(long seqno,
                Message msg)
Adds a message according to its sequence number (ordered). Variables head and tail mark the start and end of the messages received, but not delivered yet. When a message is received, if its seqno is smaller than head, it is discarded (already received). If it is bigger than tail, we advance tail and add empty elements. If it is between head and tail, we set the corresponding missing (or already present) element. If it is equal to tail, we advance the latter by 1 and add the message (default case).

Remove

public Message Remove()
Find the entry with seqno head. If e.msg is != null -> return it and increment head, else return null.

Stable

public void Stable(long seqno)
Delete all messages <= seqno (they are stable, that is, have been received at all members). Stop when a number > seqno is encountered (all messages are ordered on seqnos).

Reset

public void Reset()
Deletes all entries

GetHighestDelivered

public long GetHighestDelivered()
Returns the highest sequence number of a message consumed by the application (by Remove())

GetHighestReceived

public long GetHighestReceived()
Returns the highest sequence number received so far (which may be higher than the highest seqno delivered so far

GetMessagesHigherThan

public List GetMessagesHigherThan(long seqno)
Return messages that are higher than seqno (excluding seqno)

GetMessagesInRange

public List GetMessagesInRange(long lower,
                               long upper)
Return all messages m for which the following holds: m > lower && m <= upper (excluding lower, including upper). Check both msgs and delivered_msgs.

Size

public int Size()

toString

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

main

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