Package org.jgroups.stack
Class AckReceiverWindow
- java.lang.Object
-
- org.jgroups.stack.AckReceiverWindow
-
public class AckReceiverWindow extends java.lang.ObjectCounterpart of AckSenderWindow. Simple FIFO buffer. Every message received is ACK'ed (even duplicates) and added to a hashmap keyed by seqno. The next seqno to be received is stored innext_to_remove. When a message with a seqno less than next_to_remove is received, it will be discarded. Theremove()method removes and returns a message whose seqno is equal to next_to_remove, or null if not found.
Change May 28 2002 (bela): replaced TreeSet with HashMap. Keys do not need to be sorted, and adding a key to a sorted set incurs overhead.- Version:
- $Id: AckReceiverWindow.java,v 1.25.2.4.2.2 2009/04/28 11:31:50 belaban Exp $
- Author:
- Bela Ban
-
-
Constructor Summary
Constructors Constructor Description AckReceiverWindow(long initial_seqno)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(long seqno, Message msg)Adds a new message.java.util.concurrent.locks.ReentrantLockgetLock()booleanhasMessagesToRemove()java.lang.StringprintDetails()Messageremove()Removes a message whose seqno is equal tonext_to_remove, increments the latter.MessageremoveOOBMessage()voidreset()intsize()booleansmallerThanNextToRemove(long seqno)java.lang.StringtoString()
-
-
-
Method Detail
-
getLock
public java.util.concurrent.locks.ReentrantLock getLock()
-
add
public boolean add(long seqno, Message msg)Adds a new message. Message cannot be null- Returns:
- True if the message was added, false if not (e.g. duplicate, message was already present)
-
remove
public Message remove()
Removes a message whose seqno is equal tonext_to_remove, increments the latter. Returns message that was removed, or null, if no message can be removed. Messages are thus removed in order.
-
removeOOBMessage
public Message removeOOBMessage()
-
hasMessagesToRemove
public boolean hasMessagesToRemove()
-
smallerThanNextToRemove
public boolean smallerThanNextToRemove(long seqno)
-
reset
public void reset()
-
size
public int size()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
printDetails
public java.lang.String printDetails()
-
-